eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Infiltration

Infiltration

Good morning, agent W-12. Your mission, should you choose to accept it, is as follows. We are infiltrating the ever so insidious Association of Chaos and Mischief (ACM) in order to take down their command structure. Unfortunately, they appear to be prepared for such an eventuality, and have given their command structure an annoyingly complex design which makes our infiltration quite difficult. The ACM command structure is divided into several cells. For each pair of cells \textbf{A} and \textbf{B}, either \textbf{A} controls \textbf{B} or \textbf{B} controls \textbf{A}. But this "control" relation can be cyclic, so it could happen that \textbf{A} controls \textbf{B} and \textbf{B} controls \textbf{C} and \textbf{C} controls \textbf{A}. We can send in agents to infiltrate any particular cell, which gives us control over that cell and the cells that it controls, but not any other cells. So in the example above, infiltrating \textbf{A} would give us control over \textbf{A} and \textbf{B}, but not \textbf{C}. For a successful infiltration of the ACM, we must obtain control over all of its cells, otherwise the cells that are out of our control will discover us and start causing some of their trademark chaos and mischief. As you know, we’re on a tight spending leash from higher authority these days, so we need to execute this mission as efficiently as possible. Your mission is to figure out the minimum number of cells we need to infiltrate in order to succeed. This mission briefing will self-destruct in five hours. Good luck! \InputFile The first line of a test case contains the number \textbf{n} of cells the ACM has (\textbf{1} ≤ \textbf{n} ≤ \textbf{75}). Each of the next \textbf{n} lines contains a binary string of length \textbf{n} where the \textbf{i}^th character of the \textbf{j}^th line is \textbf{1} if cell \textbf{j} controls cell \textbf{i}, and \textbf{0} otherwise (\textbf{1} ≤ \textbf{i}, \textbf{j} ≤ \textbf{n}). The \textbf{i}^th character of the \textbf{i}^th line is \textbf{0} and for \textbf{i} \textbf{≠ j}, either the \textbf{i}^th character of the \textbf{j}^th line is \textbf{1} or the \textbf{j}^th character of the \textbf{i}^th line is \textbf{1}, but not both. \OutputFile For each test case, display its case number followed by the minimum number \textbf{m} of cells that must be infiltrated to obtain complete control of the ACM. Then display \textbf{m} numbers \textbf{c_1}, ..., \textbf{c_m} in any order, indicating the list of cells to infiltrate (cells are numbered from \textbf{1} to \textbf{n}). If more than one set of \textbf{m} cells gives complete control, any one will be accepted.
Лимит времени 3 секунды
Лимит использования памяти 256 MiB
Входные данные #1
2
00
10
3
010
001
100
5
01000
00011
11001
10100
10010
Выходные данные #1
Case 1: 1 2
Case 2: 2 1 2
Case 3: 2 2 3
Источник ACM-ICPC World Finals 2012