Monday, April 6, 2009

UVa World Finals Warmup II

Yesterday we partook in the second part of the world finals warmup. Rather than a time-based recap, I'll do a question-based recap:
A, Convex Orthoganal Polygon -- this looks like quite an intimidating question. After playing around with it on paper for a bit, I realized that it wasn't as difficult as I originally thought. Given A0, An, and B0, we had to find n. (Not very descriptive, but I'm trying to be brief.) I thought it would be an O(An) at the minimum, but it turns out the problem can be solved in O(sqrt(B0)), which is quite fast. I coded it up and submitted it -- time limit exceeded (TLE). I made more optimizations and continued getting TLE. We never did solve the problem. After the competition finished, though John used an analyzer to look at the problem. It turns out the code to run this algorithm was taking almost no time. All the time was taken in reading the input and printing the output. So my code couldn't really have run much quicker -- it is just that there was such a massive amount of IO that Java was too slow with it.
B, Spanning Subtrees -- for this one, you have a graph of n nodes, and you must figure out the maximum # of ways they can be connected without any of the ways having the same vertex as each other. The number couln't be any bigger than n/2, and intuitively it seemed like n/2 would work, so we tried it. Success. Yay for reading the input and dividing by 2!
C, Optimal Segments -- this was fairly challenging and we couldn't figure out a trick to solve it other than brute-force (which would take far too long).
D, Triangle and Polynomial -- what was going on with this? We had no idea, and it looked fairly complicated even if we could figure out what the question was asking.
E, Masud Rana -- we actually forgot to print this one off. It is fairly challenging and we wouldn't have solved it in the amount of time of the competition. I'm still trying to find a solution, though.
F, Avoiding Overlaps -- Curt took this one. He did a good job with it. The jist with this is that you are given rectangles on a grid and you have to print them if they don't overlap with a pervious rectangle. He tried storing all the printed ones in a linked list, but that was too slow. So he changed it and just had a 2D array of bits representing the grid and toggled them when the rectangle was being printed. Sucess!
G, SMS for the blind -- is there any way to solve this other than brute force? And is there any way brute force could solve it within a reasonable time?
H, It's all about the bandwidth -- We need to practice some more on the maximum flow problems.
I, General Sultan -- this was a fairly complicated problem, which I didn't think was very solvable. John took it and made it into a Huffman-tree type problem (which I had a hunch would be part of the solution but had no idea how). He ended up not solving it in time because he had an error which would have required a significant re-write of his code.

Result:
2 officially (B & F), 1 unofficially (A -- I'm still quite unhappy that UVA had such a time constraint that I didn't have time for I/O.)

2 comments:

  1. Hopefully you guys are getting in the weight room so you can solve those brute force questions!
    Either way, you guys are neat.

    K. Sas

    ReplyDelete
  2. Sas, you are ridiculous like always :)

    ReplyDelete