Given n points (x_i, y_i) with a collection of CPUs of processing time p_{ij}.
You are asked to answer q queries ONLINE. Each query contains a point (x, y), and you should associate it with an unused CPU, and the cost is \sqrt{(x-x_i)^2+(y-y_i)^2}+p_{ij}. Once a CPU of processing time p_{ij} is associated, it cannot be used until p_{ij} seconds passes.
QUICK EXPLANATION:
There is a good enough greedy method, which is that we choose the minimal cost CPU that is unused currently.
EXPLANATION:
In order to follow the greedy method declared in QUICK EXPLANATION, we can just use a k-d tree to find the nearest point.
More precisely, the CPUs are considered to be a 3-dimensional point (x_i, y_i, p_{ij}) with the meanings corresponding to the above, while each query point can be regarded as (x, y, 0). The distance between two points is defined by
I was not able to get a high score for a very stupid reason. Initially I did not know about the k-d tree structure. So I spent a LOT of submissions adjusting my solution based on clustering. When I came to know about k-d trees and implemented it this morning, I also came to know there is a submission limit of 200 and I had exhausted it
@meooow I found that I couldn’t reply you unless I post another answer. I’m sorry to hear that you reached the submission limit. However, I remember that the limit is 500, isn’t it?
I tried another greedy approach. For each query we choose the nearest server to the query task that has an available CPU. Kept getting WAs
so I had to implement an easier solution that got 51 pts.
I have read quite a lot of the sources (not all of course). I haven’t seen any Voronoi implementation. I must confess that I haven’t even thought about it. Nice idea. Congrats for having it.
@prakhariitd I think it implies that your code runs in time for all test cases (or it will show TLE), however, the worst case of your code appears in the hidden test cases.
Codechef will run everybody’s challenge code with all the test data during the active contest, but will not display the situation of hidden test cases. It is because it must guarantee that everyone’s AC code must be AC at the end of the contest.