YahiaSherif's blog

By YahiaSherif, history, 3 years ago, In English

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.

  • Vote: I like it
  • +40
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +79 Vote: I do not like it

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

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +20 Vote: I do not like it

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

    (*)languages

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it
      fun fact
      • »
        »
        »
        »
        3 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        then it's your fun opinion, not fun fact.

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          It think it has some credance as it read it off on Wikipedia once

          • »
            »
            »
            »
            »
            »
            3 years ago, # ^ |
            Rev. 3   Vote: I like it +1 Vote: I do not like it

            then show me the source. also, you said "i think", that means it's clearly your opinion, not a fact. a fact needs evidences.

            anyway, this is actually a fact: Animal Farm reflected the situation happened in the November Revolution.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it -37 Vote: I do not like it

    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 years ago, # ^ |
      Rev. 2   Vote: I like it +2 Vote: I do not like it

      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 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

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

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it +32 Vote: I do not like it

          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 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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 years ago, # ^ |
              Vote: I like it -16 Vote: I do not like it

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

»
3 years ago, # |
  Vote: I like it +10 Vote: I do not like it

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 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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 years ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      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 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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 years ago, # ^ |
          Vote: I like it +8 Vote: I do not like it

        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 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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 years ago, # |
  Vote: I like it +30 Vote: I do not like it

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.