Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
LSFIGHT - Đấu trường VM08 |
English | Vietnamese |
The VM08 arena
In this year Marathon '08, the vCoders have to play in a knock-out tournament. After the qualification round, the board of directors has selected N competitors of highest scores and numbered them from 1 to N. These competitors have to stand in order along a circle (so that the nth person is beside the first one). Then the board selects a random two ajdacent competitors to compete with each other. The loser is eliminated and has to go out of the circle. The tournament continues in this way until there is only one competitor left. This competitor will be the ultimate champion.
Knowing in advance the winners in all matches, help the board to determine who have chance to be the champion.
Input
- The first line: an integer N (3 ≤ N ≤ 500).
- In the next N lines there is a matrix A[i, j], in which A[i, j] = 0 if the ith competitor will lose over the jth competitor and A[i, j] = 1 if the ith competitor will win over the jth competitor. It is guaranteed that A[i, i] = 1 for all i and A[i, j] + A[j, i] = 1 for i <> j. The numbers are separated by at least one space.
Output
- The first line: a positive integer M - the number of competitors that have chance to be the champion.
- In each line in the next M lines, print M numbers that are the indexes of the competitors that have chance to be the champion. The indexes should be printed in ascending order.
Example
Input 7 1 1 1 1 1 0 1 0 1 0 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 0 0 0 0 1 Output 3 1 3 6
Được gửi lên bởi: | Bare & Simple |
Ngày: | 2008-08-07 |
Thời gian chạy: | 0.100s-0.600s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE |
Nguồn bài: | VNOI Marathon '08 - Round 9/DivB Problem Setter: Tô Quang Phúc Origin:POI6 |