PivotOJ

Forest for the Trees

시간 제한: 2000ms메모리 제한: 1024MB출처: ICPC Greater New York 2023BOJ 30530

문제

You have sent a robot out into the forest, and it has gotten lost. It has a sensor that will detect all the trees around itself regardless of any occlusions, but unfortunately in this forest, all trees look alike. You do have a map of all trees in the forest, represented as (x,y)(x,y) points. Conveniently, since this used to be a tree farm, all trees are at integer coordinates, though not all coordinates are occupied. The robot's sensor tells you the xx and yy distance to each tree within range, relative to the front of the robot. However, the robot is heading in an unknown direction relative to the map, so each sensor reading is given as a tuple of (distance to the right of the robot, distance forward of the robot) and either value can be negative since the robot can sense in all directions. Helpfully, the robot will always place itself at integer coordinates and aligned to the positive or negative xx or yy axis, and will never be at the same location as a tree. Can you find out where the robot is?

입력

The first line of input contains three integers: ntn_t, the number of trees in the forest, nsn_s, the number of trees sensed by the robot, and rmaxr_{max}, the maximum Manhattan distance (sum of xx and yy distances) of any sensor reading. The next ntn_t lines each contain two integers representing the (x,y)(x,y) locations of all the trees relative to a global coordinate system. The final nsn_s lines each contain two integers. The first integer in the ithi^{th} sensor reading, si,xs_{i,x}, represents the distance to the tree along the axis perpendicular to the robot's heading and the second integer si,ys_{i,y} represents the distance along the axis parallel to the robot's heading. You can assume that si,x+si,yrmax|s_{i,x}|+|s_{i,y}| \leq r_{max} for all ii. You may also assume 0<nt50000 < n_t \leq 5000, 0<ns10000 < n_s \leq 1000, 0<rmax10000 < r_{max} \leq 1000, and all tree locations have xx and yy coordinates 100,000x,y100,000-100,000 \leq x,y \leq 100,000.

출력

Print one of the following: the x,yx,y location of the robot, printed as two integers separated by a space; "Impossible" if there is no location in the map that could produce the given sensor values, or "Ambiguous" if two or more distinct locations and/or orientations could produce the given sensor values.

예제

예제 1

입력
4 4 100
1 1
2 2
2 1
3 3
0 1
0 2
-1 2
-2 3
출력
0 1
코드를 제출하려면 로그인하세요.