Hamilton
시간 제한1초메모리 제한1024 MB
대칭 0/1 행렬이 주어질 때, 순환 순서에서 간선 라벨이 많아야 한 번만 바뀌는 정점 순열을 찾는다.
문제
Bobo has an symmetric matrix consisting of zeros and ones. For a permutation of , let
The permutation is almost monochromatic if and only if the number of indices () where is at most one.
Find an almost monochromatic permutation for the given matrix .
입력
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains an integer .
For the following lines, the -th line contains integers .
출력
For each test case, if there exists an almost monochromatic permutation, output integers which denote the permutation. Otherwise, output .
If there are multiple almost monochromatic permutations, any of them is considered correct.
제한
- for each
- for each
- for each
- In each input, the sum of does not exceed .
힌트
For the first test case, , , . Only when , . Therefore, the permutation is an almost monochromatic permutation.