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

25940번 - Longest Path 스페셜 저지다국어

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

문제

You are visiting a lovely garden, with several points of interest. Every pair of points of interest have a single, one way path (edge) connecting them. (The paths are one way so that guests don't get upset having to deal with other guests walking in the opposite direction.) Luckily, you get to decide which point of interest to begin from. Naturally, to get your money's worth, you'd like to visit as many of the points of interest as possible without revisiting any point of interest, since that would be a waste of time. Determine a walking path that allows you to visit the maximal number of points of interest without repeating any of them.

Given a directed graph containing exactly one edge (path) between every pair of vertices (points of interest), determine a walking path of maximal length that doesn't revisit any vertex.

입력

The first input line contains a positive integer, n (n ≤ 100), indicating the number of gardens to check. The input for each garden follows. Each set starts with a line with a single integer, v (1 ≤ v ≤ 500), the number of points of interest for that case. The following v lines will contain v space separated integers each. The j th (1 ≤ j ≤ v) of these integers on the i th (1 ≤ i ≤ v) line is 1 if there is a path from point i to point j, or 0 if there is a directed path from point j to point i instead. The i th integer on the i th line will always be 0. It is guaranteed that the input information is consistent - if the jth integer on the ith line is 1 then the ith integer on the jth line is 0, and vice versa.

출력

For each garden, on a line by itself, output a space separated list of any maximal length sequence of unique points of interest to visit.

제한

예제 입력 1

2
4
0 1 1 0
0 0 0 1
0 1 0 0
1 0 1 0
3
0 1 1
0 0 1
0 0 0

예제 출력 1

1 2 4 3
1 2 3

힌트

출처

University > University of Central Florida > 2015 Local Programming Contest 9번

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

출처

대학교 대회

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

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