Buttons
시간 제한2초메모리 제한512 MB
각 격자 칸에 0 이상 10^9 이하의 정수 시각을 부여해 모든 인접한 두 칸이 t_kl + a_ij <= t_ij <= t_kl + b_ij를 만족하도록 하거나, 불가능하면 -1을 출력한다.
문제
There is an grid, with one button in each cell. Initially, all buttons are off. You will push them and turn them on.
Your task is to find a "good" timing of pressing the buttons. Let be the timing to push the button of row and column . The timing is said to be "good" if and only if the following conditions are satisfied.
- is an integer between and for all and .
- for every cell which is a horizontal or vertical neighbor of the cell , i.e., .
Write a program to output a "good" timing for the given and . If there are several possible timings, you can output any of them. If there is no "good" timing, you should output .
입력
The input consists of a single test case of the following format.
and represent the height and width of the given grid (). and represent the range of time differences for the button of row and column ().
출력
If there is a "good" timing, output it in the following format.
is an integer representing the timing to push the button of row and column . The timings should satisfy the conditions defined in the problem statement. If there are multiple correct answers, you can print any of them.
If there is no "good" timing, you should output instead.