Блог пользователя YahiaSherif

Автор YahiaSherif, история, 3 года назад, По-английски

I am wondering if problem setters test their time limits with java. Doesn't seem like it. Most C++ solution today in problem E barely passed the time limit which means it's virtually impossible to accepted in java. Not the first time this has happened in a cf round. Very frustrating.

  • Проголосовать: нравится
  • +40
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится +79 Проголосовать: не нравится

IMO languages aren't created equal and if you decide to participate with a language you must accept its ups and downs.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +20 Проголосовать: не нравится

    One of my favorite quotes of all time: "all animals(*) are equal but some are more equal than others" ~ Animal Farm

    (*)languages

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится -37 Проголосовать: не нравится

    I think it's ok when you use some allowed in CF language and should somehow optimize solution to get it accepted.
    But I think it's not ok when language is allowed but solution in that language CAN'T be accepted in ANY way

    • »
      »
      »
      3 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +2 Проголосовать: не нравится

      It is absolutely impossible ti make it the way you describe unless we have different time limits for different languages and I am strongly against such a thing

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Authors can reduce list of allowed languages by checked ones that are guaranteed to pass time limit with proper time&space complexity

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится +32 Проголосовать: не нравится

          That's a ridiculous amount of work to ask of authors. In practice what you would get is that every language other than C++ will be disabled.

          • »
            »
            »
            »
            »
            »
            3 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            To expand on that: in most problems you can get AC using Java or Python. However that doesn't mean the average author would know how to do that. I might not be able to get AC in some problem with Python, but I'm sure pajenegod would be. Because just as in C++ there are some tricks and other things you have to know, so are there in Java or Python.

            So a contest author should ask someone who regularly codes in Java and someone who regularly codes in Python to enable or disable the language?

            And this is just Java and Python. I haven't even touched on Scala, Ruby, JavaScript, PHP, Haskell, Kotlin and whatever else Codeforces allows.

          • »
            »
            »
            »
            »
            »
            3 года назад, # ^ |
              Проголосовать: нравится -16 Проголосовать: не нравится

            So there are testers who can help, right? Authors can choose testers who use different languages

»
3 года назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

When you choose java, you make a tradeoff between performance and convenience of development. This includes competitive programming as well.

Don't whine that you couldn't get ac in some E in java. With java you can easily get AC in plenty of problems in which most other languages fail and you don't whine about it. And you know what people do when they cannot get AC in their favorite language? They switch to some other language for the specific problem they're solving

Tbh, I find this post ridiculous. And Lately I often see some ridiculous posts from people who achieved orange or red and are supposed to be very smart. Either this or complains that their 1999.9ms passed solution got TLE FST after the round or claiming that we don't need timely editorials. I just don't get it

  • »
    »
    3 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    IMO the convenience difference between Java and CPP is so small that it turns out to be totally subjective. It's not like Java is a super 'smart' language (such as python) that gives an unfair advantage to its competitors. In fact, the only library 'advantage' it has over CPP is the BigInteger class.

    I believe the main reason I and other people use Java, is because we are familiar with it, and adapting to another language (to a competitive level) takes practice and time. Personally, in my free time, I prefer to learn/implement new algorithms over practicing a new language.

    Also, it's not always clear whether Java will TLE for a given problem. Usually, you need to submit in order to find out and after that having to translate the code to CPP wastes time and mentality, which is indeed really frustrating. In general having an optimal solution and missing the whole problem for such a reason is always frustrating, I don't understand how you "don't get it".

    To sum up, in my opinion adding one more second to a problem that the time limit seems to be quite strict in CPP doesn't hurt in any way. It's not like O(n^2) solutions will pass when O(NlogN) is expected, and trying to cut off O(NlogN) solutions expecting O(n) complexity is pointless anyway...

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится +15 Проголосовать: не нравится

      If the time limit is tight there might be a reason for it. The prospect of $$$O(n^2)$$$ solutions passing where $$$O(n \log n)$$$ is expected is more likely than you seem to think, especially if such $$$O(n^2)$$$ solutions have good constant, break early etc.

    • »
      »
      »
      3 года назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      There is problem with java in CodeForces. Java sorting of integer array uses QuickSort — which in worst cases degrades to n^2 performance. And so perfectly valid solutions fail on slow sort. It happened with me several times ((((( C++ is lucky — their sort is more stable. I didn't investigae other languages, may be we have Java problem in other languages ??? It is inconvenient to not be able to run sort in your progrm ((((

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится +8 Проголосовать: не нравится

        when sorting an array of primitives (int,char,long,...) shuffle the array before sorting to avoid getting the n ^ 2 worst case of Arrays.sort()

        • »
          »
          »
          »
          »
          3 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          May be this advice makes sence. I tried using alternative sort routines — it worked, but it is annoying to remember, and leads to failed submissions (((((.

»
3 года назад, # |
  Проголосовать: нравится +30 Проголосовать: не нравится

Every round I was a problem author in, we made sure to write Java solutions to make sure the time limits weren’t tight for Java users. It’s not a requirement, but some contest creators are kind enough to account for Java.