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

11177번 - Join My Team 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB308726.923%

문제

You are putting together a competition similar to IDI Open where the major difference is team selection. The participants are asked to order the other participants according to whom they would like the most to be on their team. The first person on their list is the person they would like the most to be on their team, and the last person is the one they would like the least to be on their team.

Your task is to assign all competitors into teams of two, in such a way that they are happy with the assignment. They are happy with any assignment unless there exists four competitors, A, B, C and D, where A is on C’s team, B is on D’s team, A prefers B to C, and B prefers A to D.

입력

The first line of the input consists of a single integer, T, the number of test cases. Each of the following T cases begins with a line with a single integer, N, the number of participants.

The next N lines each have N − 1 integers, Pij, giving the preference list of participant number i, separated by spaces.

  • 1 ≤ T ≤ 20
  • 2 ≤ N ≤ 100
  • 1 ≤ Pij ≤ N
  • Pij ≠ i

출력

For each test case, output one possible solution that the participants are happy with, given by a list of teams on the form i:j (i is on a team with j), where each team is separated by a space. There may be many such lists, but any of them will be accepted. If there is no solution, output NO SOLUTION.

제한

예제 입력 1

3
4
2 3 4
3 1 4
1 2 4
1 2 3
8
2 5 4 6 7 8 3
3 6 1 7 8 5 4
4 7 2 8 5 6 1
1 8 3 5 6 7 2
6 1 8 2 3 4 7
7 2 5 3 4 1 8
8 3 6 4 1 2 5
5 4 7 1 2 3 6
6
4 6 2 5 3
6 3 5 1 4
4 5 1 6 2
2 6 5 1 3
4 2 3 6 1
5 1 4 2 3

예제 출력 1

NO SOLUTION
1:4 2:3 5:6 7:8
1:6 2:3 4:5

힌트

출처

Contest > IDI Open Contest > IDI Open 2014 J번

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

출처

대학교 대회

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

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