RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00269

Rotacije

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(7^{th}\) round (Croatian Olympiad in Informatics), April \(6^{th}\), 2013

The famous archaeologist Diana Jones has discovered a secret passageway leading to hidden treasure
near Nowhere, Kansas. The passageway is blocked by a stone gate which has an ancient unlocking
mechanism chiselled into it. Fortunately, she has immediately recognized the chiselled symbols:
1. The unlocking mechanism is a table with R rows and C columns. Each cell contains a unique
positive integer between 1 and \(R*C\), inclusive. At first glance, the numbers appear to be
ordered randomly.
2. The mechanism contains cogwheels which Diana can use to rearrange the table cells. In one
move, she can rotate any \(2-by-2\) group of adjacent cells clockwise by 90 degrees.
3. The gate will be unlocked when the numbers are rearranged in sorted r\(ow-ma\)jor order (the
upper left cell must contain 1, the cell to the right of it 2, and so on until the lower right cell,
which must contain \(R*C\)).
For example, for the initial arrangement shown in the first picture, two moves are sufficient to unlock
the mechanism:
3
2
6
1
4
5


1
3
6
4
2
5


1
2
3
4
5
6

Write a program that, given the initial arrangement of cells, finds a sequence of moves that unlocks
the mechanism. The number of moves needn't be optimal, however it must not exceed 100 000.

제약

In test data worth a total of 40 points, \(R*C\) will be at most 9.
In test data worth a total of 40 points, R will be equal to 2.
In test data worth a total of 60 points, at least one of the two constraints above will hold.
\(7^{th}\) round (Croatian Olympiad in Informatics), April \(6^{th}\), 2013

입력 형식

The first line of input contains the two positive integers R and C (\(2 \le R \le C \le 25\)).
Each of the following R lines contains C positive integers Z_{ij} (\(1 \le Z_{ij} \le R*C\)), the numbers chiselled
into the corresponding mechanism cells, which describes the initial arrangement.

출력 형식

The output must contain the required sequence of moves, one per line. For each move, output two
positive integers M and N (\(1 \le M \le R-1\), \(1 \le N \le C-1\)) representing the row and column index of the
upper left cell in the \(2-by-2\) group rotated in that move.
Note: For the given input data, a solution, not necessarily unique, will always exist.

예제 1
입력
2 3
3 2 6
1 4 5
출력
1 1
1 2
예제 2
입력
3 3
1 2 3
4 6 9
7 5 8
출력
2 2
예제 3
입력
2 4
1 2 7 3
5 6 8 4
출력
1 3
1 3
1 3
설명

Clarification of the first example: According to the picture in the problem description, the initial
arrangement can be ordered in two moves: we first rotate the group with the upper left corner in row 1
and column 1, and then the group with the upper left corner in row 1 and column 2.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2012/2013 Olympiad

평가 및 의견

Rotacije

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Rotacije

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8