Gaspiboy's blog

By Gaspiboy, history, 6 weeks ago, In English

102694A - 3 - Circumference of a Tree - my code : 93116273

hi guys, i have trouble to pass this problem. My code seems to work but it is too slow ( i have the error: Time limit exceeded on test 4) the thing is that the complexity is already O(n) and i really don't know how to make it faster. I use python and i know that this language is slower than the others, but i saw that other people succeeded to do this challenge with pypy3. Do you have any tips for me ?

Thank you very much !!

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it +22 Vote: I do not like it

Use C++

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

you can get AC by using fast input-output template and using bfs even i got TLE Without fast input-output. you can have look at my code .may be it will help. link to my submission: https://codeforces.com/gym/102694/submission/93129030

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    thank you for your answer ! im going to look a this !

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Python is slower than c++ . But we can make it somewhat faster by submitting that same code in PyPy . It is 4.2 time faster than python 3.7.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Use the template of Pyrival for python always- Template

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Read other people python code which got accepted :D