Logo
(追記) (追記ここまで)

27183번 - Magnetic Games 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB123325.000%

문제

Vova has a magnet which is his favorite toy. Vova likes to play with it on a big field which can be represented as rectangle of $n$ cells height and $m$ cells width.

One day he came to the field with his magnet and lost it in one of the cells. Vova was frustrated, but found a solution --- he puts a compass in each cell of the field. Compass arrow may be oriented in one of the following 8 directions. Each direction has its own number:

Arrows take direction close to the direction to the magnet: if the magnet is strictly along the diagonal to the compass, arrow of this compass points diagonally, otherwise --- it points in the closest of the vertical and the horizontal direction to the magnet. Arrow of the compass in the cell with the magnet may be directed anywhere.

Illustration for the sample test, arrows of all compasses point to the magnet.

Vova was ready to start searching, but suddenly recalled that there is an anomaly at the field, that inverts compasses along one horizontal and one vertical line. Arrows of the comapasses in the anomaly zone point in the opposite direction to the correct one.

Illustration for the sample, readings of some of the compasses are inverted.

Now Vova doesn't know how to find his magnet and asks you for help.

입력

The first line of the input contains two integers $n$ and $m$ --- size of the field (2ドル \le n, m \le 1500, nm \ge 6$).

The following $n$ lines contain information about compasses on the field.

The $i$-th line contains $m$ integers $a_{i,j}$ (1ドル \le a_{i,j} \le 8$), the $j$-th number on the $i$-th line describes the direction of the compass arrow in the $j$-th cell on the $i$-th line.

출력

The first line of output should contain two integers $x$ and $y$ --- the row and the column of the cell where the magnet is.

The second line must contain two integers $a$ and $b$ --- which the horizontal and which vertical line are affected by the anomaly.

제한

예제 입력 1

3 4
5 6 3 7
3 7 3 7
5 4 3 3

예제 출력 1

2 1
3 3

노트

The magnet in sample input is in the cell $(2, 1),ドル the anomaly inverts horizontal number 3ドル$ and vertical number 3ドル$.

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2022 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /