Statement
Ana and Bogdan each draw lattice points (with integer coordinates) in the plane. Ana's points are denoted , and Bogdan's points are denoted .
Bogdan notices an interesting property: for every from to , his point is the centroid of the triangle formed by Ana's point and two other points of his own, and (where ).
In a moment of carelessness, Ana erases the points drawn by Bogdan. Now he must reconstruct them, knowing only the coordinates of the points and the relations described above (the pairs of indices and ).
Requirement
Given the points and the pairs of indices for each , determine the coordinates of the points .
Implementation Details
You must implement a single function:
std::vector<std::pair<long long, long long>> solve(
int N,
std::vector<std::pair<long long, long long>> p,
std::vector<int> a, std::vector<int> b);
The solve function is called by the judge exactly once and receives as parameters:
- : the number of points drawn by Ana;
- : the coordinates of the points drawn by Ana (indexed from );
- and : representing the pairs of indices for each property
and must return a sequence of pairs, given by the coordinates of the points .
Constraints
- , for
- , , for
- All unordered pairs are pairwise distinct
- coordinates of points , for
- coordinates of points , for
- It is guaranteed that the triangles from the properties are not degenerate
- It can be proven that there exists a unique solution for determining the points
- The sides (the bases of the triangles) together form a single continuous geometric figure.
A geometric figure is continuous if, for any two points and we choose, there exists a sequence of points satisfying the following properties:
- , ;
- For every , there exists an unordered pair in the input that coincides with .
| # | Score | Constraints |
|---|---|---|
| 1 | 2 | |
| 2 | 7 | |
| 3 | 14 | |
| 4 | 12 | coordinates , , for |
| 5 | 24 | is odd, the sides form a polygon |
| 6 | 22 | Randomly generated input data |
| 7 | 19 | No additional restrictions. |
Example 1
input
4
3 2
7 3
6 7
2 6
2 3
3 0
0 1
output
4 4
5 4
5 5
4 5
Explanation
For the first example, the drawing is shown in the image below.
Ana's points are denoted , and Bogdan's points are denoted .

Example 2
input
3
399999993 599999990
1 200000002
200000017 26
1 2
2 0
0 1
output
250000001 350000002
150000003 250000005
200000007 200000011