Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

The_Royalty's blog

By The_Royalty, 12 years ago, In English

Hello, I've been trying to solve this problem Jobbery but my code gets TLE on test 50.

Could someone help me to improve my algorithm? I think it's O(M+N) because I'm using Tarjan's algorithm

My code

Thanks

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

Nobody?

»
11 years ago, hide # |
← Rev. 2  
Vote: I like it +3 Vote: I do not like it

What you have written does not look like a linear algorithm. To understand what is wrong with it, please explain as clearly as you can (at least to yourself) what the lines 63 – 71 do and — specifically — what purpose the variable S serves.

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

stupid site -_-, I'm still waiting for some judge ID to submit the problem !!

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

Oh, but it passes :). Just change cin,cout to scanf,printf and send to Visual C++ 2010 B-). For some reason other combinations don't work.