문제
The Institute for Creative Product Combinations (ICPC) tries to find unusual and innovative ways to unite seemingly unrelated products or technologies, opening up new markets and creating new jobs. (For instance, their most recent success was the “hairbachi,” a hair-dryer with a hibachi grill top attachment for preparing on-the-go hot meals.) The company employs n teams of size 2 to research individual products, then members of the different teams get together to explore ways of combining products.
During the pandemic, the ICPC management organized everyone’s schedule in such a way that there were never more than n people in the office at the same time, and things ran so smoothly that they continued the process once things began to return to normal. Here is the scheme they used. Label the teams with integers 1 through n and the two people on the ith team as (i,1) and (i,2) for each i from 1 to n. Each week, exactly one person from each team is allowed in the office, while the other has to stay away. The employees (i,1) and (i,2) know each other well and collaborate productively regardless of being isolated from each other, so members of the same team do not need to meet in person in the office. However, isolation between members from different teams is still a concern.
Each pair of teams i and j for
{
or infinity if those two people never meet. The isolation of the whole company is the maximum isolation across all choices of
You have been tasked to find a weekly schedule that minimizes the isolation of the whole company over a given number w of weeks.
입력
The input consists of a single line containing two integers n (
where n is the number of teams and w is the number of weeks that need to be scheduled.
출력
Output a line containing either an integer representing the minimum isolation achievable for n teams or the word infinity if no schedule guarantees that every pair of individuals on different teams can meet. If the isolation is finite, it is followed by w lines representing a schedule that achieves this isolation. The jth line of the schedule is a string of length n containing only the symbols 1 and 2, where the ith symbol indicates which of the two members from team i comes into the office on week j.
예제 #1
2 6
4
11
12
21
22
11
12
예제 #2
2 1
infinity