Search found 5 matches

by csprajeeth
Sat Dec 28, 2013 11:04 pm
Forum: Volume 101 (10100-10199)
Topic: 10158 - War
Replies: 23
Views: 9129

Re: 10158 - War

For those getting runtime error.... most likely you are overflowing the stack (due to unbounded recursion). Check if you are introducing cycles in your disjoint set data structure.
by csprajeeth
Mon Dec 23, 2013 10:27 pm
Forum: Volume 113 (11300-11399)
Topic: 11354 - Bond
Replies: 13
Views: 6531

Re:

When constructing the union-find tree, add weight info to the edge in the union-find tree. For query(a,b): query(a,b) := max(the last edge weight of path a -> LCA(a,b), the last edge weight of path b -> LCA(a,b)); LCA(a,b) is LCA of a,b in union-find tree. The hight of tree is O(logn), so you could...
by csprajeeth
Wed Dec 18, 2013 7:19 pm
Forum: Volume 6 (600-699)
Topic: 615 - Is It A Tree?
Replies: 71
Views: 23052

Re: 615 - Is It A Tree?

Some corner cases. INPUT 6 8 5 3 5 2 6 4 5 6 0 0 6 8 5 3 5 2 6 4 5 6 5 3 0 0 8 1 7 3 6 2 8 9 7 5 7 4 7 8 7 6 0 0 3 8 6 8 6 4 5 3 5 6 5 2 0 0 1 2 3 3 0 0 99006 700002 700002 880002 880002 1000001 1000001 1234567890 1234567890 22 0 0 0 0 -1 -1 OUTPUT Case 1 is a tree. Case 2 is not a tree. Case 3 is a...
by csprajeeth
Sun May 27, 2012 2:19 pm
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 37451

Re: 10226 - Hardwood Species

Just optimize ur IO for this problem.
gets(), printf() .. and you should be fine
by csprajeeth
Sat May 26, 2012 7:28 pm
Forum: Volume 109 (10900-10999)
Topic: 10935 - Throwing cards away I
Replies: 15
Views: 9919

Re: 10935 - Throwing cards away I

For those who still get WA after passing for the input cases posted above...You need a blank line at the end of output !

i thought
No leading or trailing spaces
means no blank line at end of input. But no..u need one.

Hope this helps.

Go to advanced search