It works for the given sample inputs and uses dynamic programming, which I started to find much easier for these kind of problems. The code is up to no standard and I didn’t expect it to be, but its readable and has proper indentation(which is all I care). So here’s the code.
The answer to problem X, in IEEEXtreme 5.0 and I didn’t even read it properly in the competition trying to do other problems, and without a fresh mind to think it through this one slipped out too. Anyways, did it now and C++ really boosts your development time. I don’t care what others say, I’ve used Java and C enough to make a comparison between these languages. For C the hard work is awarded with performance, for Java you get a knowledge in Java API which would also change from Java version to version and drop dead slow applications. This is not a rant, but a conclusion. And here’s the answer!
This is the answer for problem H of IEEEXtreme 5.0, I did not attempt this one on the competition and now feel bad about it! Nevertheless it can have defects still. If you find any please let me know. I haven’t completely finished it as a submission, so please make sure of these before you use the source.
1. Make sure you make a “ball” object for every ball.
2. Make sure you push_back those balls on to the list in a sorted manner from South most(position=0) ball to the North most ball; it only checks the nearest balls for collisions.
PS: All of the balls’ positions are updated even though the question asks for only a specified ball’s position.
This answer is for the question C in IEEEXtreme 5.0, is based partially on my answer at the actual competition(still don’t feel like giving up on this one, it kept on getting errors back then). It features a timer too, I need you to run it(by compiling the original version by me, ofcause) and get it hanged or get it to run for more than 5 seconds and send me the input!
Note: The time is displayed in micro-seconds for your inconvenience.
This is my answer to problem J of IEEEXtreme 5.0(problem set), I was there too but this problem slipped my team. And I was thinking of it after the competition, and found out on designing that for circuits like unbalanced(when there is a current flowing in the central resistor) Wheatstone Bridge, sequential and parallel systems of simplifying resistor circuits are some what hard to apply in an automated manner(I personally failed to even find any automated solution other than solving the equations themselves!).
Then I saw it! The problem says itself that it’ll only check resistor systems that are parallel or sequential. So here’s the code. It might be the slowest way to get it done, but it gets it done.