DoctorLai's blog

By DoctorLai, 11 years ago, In English

I am new here. and I do not know fully how the contests work, up to now, including round 162, i have only participated three times in online contests.

I didn't know the tests during the contest are just a small portion (there are more difficult tests after contest ends), so the 'Accepted' shown during contests are just temp, the system will retest with harder tests.

The point i want to make here is , I am lazy, i choose Python because I can code shorter, but not executes faster... If I rewrite my solution in C++/C, it will pass all tests instead of the fact that Python gives me TL...

When I got 'accepted' with Python on problem D 'good sequence' (Dynamic Programming), I should have provided the same implementation in C++, or I should have used C++ in the first place...

I have learned from the lesson, and will definitely get a higher rating next time...

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

| Write comment?
»
11 years ago, # |
  Vote: I like it +1 Vote: I do not like it

I'm not sure since I don't know Python, but I think the problem with your solution to D was that it had a complexity which wasn't good enough (N^2 while N or something like N * log N was needed).

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

    for Problem D, yes, you are right, but for the last round, problem D 'Cycle of Graph', I have implemented the same algorithm (DFS) using Python and Java, the Java easily passes all the tests, but the Python gives me RE on test 17. So I guess, the chance of using other languages passing the tests on same algorithm is higher than using Python.

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

Python itself is not a good language for contests. Aside from TLE, RE seems rather frequent (or so it seemed for me, while I was using it for contests), probably because it uses more memory per structure than C/C++. Overall, some of its operations are too slow, and you need to know the structures very well to choose one that has the desired asymptotic complexity (it's the same in C++, though :D), so contest programming in Python is quite tricky.