INOI 2016 Discussion

Yep thats N^2 , I did that too and didn’t bother with optimising cause it passed … It would work for 10^5 for most cases but one :frowning:

For a randomly generated tree, the height is usually proportional to lg(n)

but they will have worst case inputs as well…

Maybe you should read the date of the answer before copying from quora :wink:

so it should be “past 4-5 years” now :stuck_out_tongue:

Actually Agnishom it would be log_k(N) where , K is the lowest number of children per node … lg(N) is only applicable to binary trees … And trust me manual testing mein they would only consider the WORST CASE (you should’ve read the instructions, ) (even I should’ve :stuck_out_tongue: ) dude move on !!!

Does anyone have any idea about the limit for the stack size to cause an overflow (is it included in the 512 MB)? I am getting a segmentation fault in test case 2_10 for wealth disparity.

You were right

How do you get 130? o.O

Heaven knows how: http://i.share.pho.to/ea3b73f1_o.png

iii, jjj
nice loop variable names there _ /\ _

3 Likes

@agnishom great man!!!

@warhawk_123, my solution - #include <stdio.h>#include <iostream>#include <vector>#include <algorithm> - Pastebin.com

I just wish I had thought of this during the test. I manually tested in on the test cases and it passed all with the longest one taking about 0.45 seconds.

The tester code is half baked just to get the stuff done in C# - using System;using System.Collections.Generic;using System.Linq;using Syst - Pastebin.com

Here’s my solution. I know its very messy but I was only focused on getting it right during the exam - /* Archit Rungta, 37004, Wealth Disparity*/#include <vector>#include <stdio. - Pastebin.com

@archit129 cool man…!! wow your pointer skills are way better than me…

Change what?

doesnt matter , n^2 will not even work with 10 seconds and O(n) will work with even in 1 second

There was an answer before this answer which @shauryaagg has now deleted

thanks archit

Here’s mine, 3CX73s - Online C++ Compiler & Debugging Tool - Ideone.com