#707
Unrated
Table Recovery
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie has an N×NN\times N (1N10001\le N\le 1000) addition table where the integer in the cell at row rr and column cc is r+cr+c, for all 1r,cN1\le r,c\le N. For example, for N=3N=3, the table would look like this:

2 3 4 3 4 5 4 5 6

Unfortunately, Elsie got ahold of the table and permuted it by performing the following three types of operations as many times as she wanted.

Swap two rowsSwap two columnsSelect two values aa and bb that are both present in the table, then simultaneously change every occurrence of aa to bb and every occurrence of bb to aa.

Elsie will always perform operations in increasing order of type; that is, she performs as many operations as she likes (possibly none) first of type 11, then of type 22, and finally of type 33.

Help Bessie recover a possible state of the table after Elsie finished applying all of her operations of types 11 and 22, but before applying any operations of type 33. There may be multiple possible answers, in which case you should output the lexicographically smallest one.

To compare two tables lexicographically, compare the first entries at which they differ, when reading both tables in the natural order (rows from top to bottom, left to right within a row).

입력

The first line contains NN.

The next NN lines each contain NN integers, representing Bessie's addition table after Elsie has permuted it.

출력

The lexicographically minimum possible state of the table after all operations of types 1 and 2, but before any operations of type 3. It is guaranteed that the answer exists.

예제 입력 1

1
2

예제 출력 1

2

예제 입력 2

3
3 4 2
5 2 3
6 3 5

예제 출력 2

4 2 3
5 3 4
6 4 5

예제 입력 3

6
8 10 5 6 7 4
12 11 10 4 8 2
5 4 6 7 9 8
10 2 4 8 5 12
6 8 7 9 3 5
4 12 8 5 6 10

예제 출력 3

7 5 8 9 10 6
4 2 5 6 7 3
8 6 9 10 11 7
5 3 6 7 8 4
9 7 10 11 12 8
6 4 7 8 9 5

점수

Inputs 4-5: N6N\le 6Inputs 6-7: N8N\le 8Inputs 8-11: N100N\le 100Inputs 12-15: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.