시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB70231930.645%

문제

Ernesto and Penelope are playing a board game on an infinite grid. Instead of rolling dice, both of them have generated a random number, and now they have to move their pieces that number of times. A single move consists of placing the piece in an adjacent cell; moving diagonally or waiting in place are not legal moves. However, it is permitted to move the piece in the direction it just came from in the previous move.

Ernesto and Penelope are trying to move in such a way that their pieces will end up in the same cell. Is there a cell for which this is possible?

Figure M.1: Visualisation of the first sample, including possible paths for the given output.

입력

The input consists of two lines, both containing three integers x, y (−1012 ≤ x, y ≤ 1012) and d (0 ≤ d ≤ 1012), giving for either player the pieces’ initial coordinates and the randomly generated number.

출력

If there is a cell that both players can end up on, output its coordinates. If there are multiple valid solutions, any will be accepted. If there is no valid cell, output impossible.

예제 입력 1

1 -2 5
-3 3 8

예제 출력 1

-3 -1

예제 입력 2

0 -1000000000000 0
0 -1000000000000 0

예제 출력 2

0 -1000000000000

예제 입력 3

-5 -426 932111
83 -870 478692

예제 출력 3

impossible

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2019 M번

  • 문제를 만든 사람: Philipp Reger