#P3561. [POI 2017] Turysta
[POI 2017] Turysta
Problem Description
You are given a directed graph with vertices. Between any two vertices, there is exactly one directed edge.
For each vertex , find a simple path starting from that visits the maximum number of vertices, and does not visit any vertex twice or more.
Input Format
The first line contains a positive integer , the number of vertices.
The next lines follow. The -th of these lines contains numbers.
If the -th number is , it means there is a directed edge . If it is , it means there is a directed edge .
Output Format
Output lines. On the -th line, first output a positive integer , the number of vertices on an optimal path starting from vertex .
Then output positive integers, in order, representing each vertex on the path.
If there are multiple optimal solutions, output any one.
This problem uses SPJ (made by Claris).
4
1
1 1
1 0 1
4 1 2 3 4
3 2 3 4
3 3 4 2
3 4 2 3
Hint
For of the testdata, .
Translated by ChatGPT 5