Banach
Time limit3sMemory limit512 MB
Assign N vectors to N points so that no pairwise distance shrinks after translation, maximizing the sum of squared pairwise distances.
Problem
Stefan, David and Felix are preparing an ACM-style programming contest. Stefan proposes the following task.
Given points on a plane and movement vectors, find a one-to-one correspondence between vectors and points such that, if each point is translated by its corresponding vector, the distance between every pair of points does not decrease.
David solved this problem quickly and claims it is too easy to include in the problem set. To convince him, Felix proposes an update. Among all valid solutions, choose the one that maximizes the sum of squares of all resulting pairwise distances.
David still thinks the problem is easy. Do you agree?
Input
The first line contains a single integer , the number of points and vectors ().
The next lines describe the points. Each line contains two integers and ().
The following lines describe the vectors. Each line contains two integers and ().
Output
If a correspondence exists such that all pairwise distances do not decrease, print Yes on the first line. On the next line, print distinct integers from to , where the -th number is the vector assigned to the -th point.
The answer must maximize the sum of squares of all resulting pairwise distances. If several answers tie, print any of them.
If no such correspondence exists, print No on a single line.
Hint
In the first example, there are only two correspondences, "1 2" and "2 1". In both, the distance between every pair of points does not decrease. The sum of squares is 9 for the first and 25 for the second, so the only correct answer is "2 1".
In the second example, there are again only two correspondences. Both keep every pairwise distance, and the sum of squares is 0 in both cases, so either answer is correct.