zeddie's blog

By zeddie, history, 4 years ago, In English

I was solving the last question (1433G - Уменьшение стоимости доставки) of the last Div3 round, and I got TLE at test case 3

Here is a link to the TLE solution by me : link

Here is link to ACCEPTED solution by icecuber : link

I even followed his code, so as to make different changes and make our code similar, but still, all I have is TLE. Please HELP!!

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

| Write comment?
»
4 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Umm.. Because The url of icecuber code is missing, i can't see what exactly that code works.

But =Because of floid-warsher code Time Complexity, i think you get TLE

i suggest you to optimizate floid-warsher parts or use Dijkstrat ( TIme complextiy O(ElogV) )

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Take out #define int long long and it might work. long long is slow...

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

Operations on long are costlier than int. Use long long only when needed, submission.

Also use \n rather than endl.

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

    Shit, I didn't know that. Thanks a lot.