Schedule

시간 제한2초메모리 제한1024 MB

요약
n개 팀의 각 주별 출근 인원을 정해, 서로 다른 팀의 두 사람이 만나는 간격의 최댓값을 최소화하는 일정을 구하거나 불가능하면 infinity를 출력한다.
난이도

어려움10점 중 8점

유형
조합론, 그리디, 수학, 구현
정답자
아직 제출이 없습니다

문제

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 nn teams of size 22 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 nn 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 11 through nn and the two people on the iith team as (i,1)(i,1) and (i,2)(i,2) for each ii from 11 to nn. Each week, exactly one person from each team is allowed in the office, while the other has to stay away. The employees (i,1)(i,1) and (i,2)(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 ii and jj for i≠ji \ne j has to collaborate occasionally. For a given number ww of weeks and for fixed team members (i,a)(i,a) and (j,b)(j,b), let w_1\<w_2<…\<w_kw\_1\<w\_2< \dots \<w\_k be the weeks in which these two team members meet in the office. The isolation of those two people is the maximum of w_1,w_2−w_1,w_3−w_2,…,w_k−w_k−1,w+1−w_k,\\{w\_1,w\_2 - w\_1, w\_3 - w\_2, \dots , w\_k - w\_{k-1}, w+1 - w\_k\\}, or infinity if those two people never meet. The isolation of the whole company is the maximum isolation across all choices of ii, jj, aa, and bb.

You have been tasked to find a weekly schedule that minimizes the isolation of the whole company over a given number ww of weeks.

입력

The input consists of a single line containing two integers nn (2≤n≤1042≤n ≤10^4) and ww (1≤w≤521≤w≤52), where nn is the number of teams and ww is the number of weeks that need to be scheduled.

출력

Output a line containing either an integer representing the minimum isolation achievable for nn 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 ww lines representing a schedule that achieves this isolation. The jjth line of the schedule is a string of length nn containing only the symbols 1 and 2, where the iith symbol indicates which of the two members from team i comes into the office on week jj.

예제2

  1. 예제 1

    입력
    2 6
    
    예상 출력
    4
    11
    12
    21
    22
    11
    12
    
  2. 예제 2

    입력
    2 1
    
    예상 출력
    infinity