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

Автор satyaki3794, 10 лет назад, По-английски

I recently tried the problem 294E - Шаасс Великий and my submission is 10704270.

I am getting TLE on test 8 which is a maxtest (5000 nodes). I am unable to figure out my mistake. Could someone please take a look at it and guide me in the right direction, if they can figure out what my mistake is?

My logic is as follows: I used a n^2 algorithm. One by one, I selected each edge as the one I will delete and found the optimal vertices in the two trees created (optimal means has the least sum of distances to other vertices in the same tree). Then I join those two to get the answer and compare it with the global answer.

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

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

I think that this is a correct solution. I've got the same problem. When I looked at accepted solutions they were running for > 2s. And the problem is that the package was not updated, so they took the execution time of your program and simply multiply it by 2. There is a good chance that your solution runs > 2s and that's why it is judged as TLE (after multiplication), because time limit is 4 s for this problem.

Edit: For my case changing from MS VS to Gnu C++ 11 solved the issue, but it looks like you are already using GNU C++ 11, so maybe you would like to try a different version of GNU C++?