H - Network Topology in Hezardastan


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Hezardastan, a leading information technology group in Iran, has a huge data center containing nn servers and mm terminals (where mnm \leq n). A terminal is a pair of keyboard and monitor that can be connected to a server for administrative purposes. The servers are numbered 11 through nn and the terminals are numbered 11 through mm. This data center has a network topology in which not every terminal is necessarily able to connect to every server. For example, the figure below depicts 33 terminals and 66 servers where a terminal can connect to a server if a line is drawn between them.

توضیح تصویر

A subset SS of the servers with size mm is called manageable if its members are allowed by the network topology to be simultaneously managed by the terminals, i.e. each terminal can be connected to a distinct server in SS. For example, the subset {2,3,6}\{2, 3, 6\} in the example above is manageable as its members can be respectively managed by the terminals {1,2,3}\{1, 2, 3\}. A subset of the servers is called unmanageable if it has size mm and is not manageable. A network topology is called totally manageable when it causes no unmanageable subset of servers. For example, the network topology shown in the example above is totally manageable, but if the connection link between terminal 22 and server 55 is removed, then it will not be totally manageable anymore since the subsets {1,5,6}\{1, 5, 6\}, {2,5,6}\{2, 5, 6\}, {3,5,6}\{3, 5, 6\}, and {4,5,6}\{4, 5, 6\} will become unmanageable. Given a network topology for the data center, you have to find if it is totally manageable or it makes an unmanageable subset.

ورودی🔗

The first line of input contains two integers mm and nn separated with a single space (1m150,1n400,mn)(1 \leq m \leq 150, \, 1 \leq n \leq 400, \, m \leq n). The next mm lines describe the network topology by an m×nm \times n matrix. Each of these lines contains nn space-separated integers which are either 00 or 11. The jj-th number (for 1jn1 \leq j \leq n) in the (1+i)(1 + i)-th line of input (for 1im1 \leq i \leq m) is 11 if terminal ii can connect to server jj, and it is 00 otherwise.

خروجی🔗

If the given network topology is totally manageable, you only have to print 11 in the first line of output. Otherwise, you should print 00 in the first line of output and an unmanageable subset of servers in the second line in the form of mm space-separated integers (indicating the server numbers, in any arbitrary order). If there are multiple unmanageable subsets, you can print any one of them.

مثال‌ها🔗

ورودی نمونه ۱🔗

3 6
1 1 1 1 0 0
0 1 1 1 1 0
0 0 1 1 1 1
Plain text

خروجی نمونه ۱🔗

1
Plain text

ورودی نمونه ۲🔗

3 6
1 1 1 1 0 0
0 1 1 1 0 0
0 0 1 1 1 1
Plain text

خروجی نمونه ۲🔗

0
1 5 6
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.