아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Chess Tournament

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

요약
n명이 서로 한 번씩 대결하는 리그전에서 한 라운드에 최대 k개의 경기만 동시에 진행할 수 있을 때, 모든 대진을 마치는 최소 라운드 수와 그 일정을 출력한다.
난이도

보통10점 중 7점

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

문제

Alex organizes a chess tournament in his company. The tournament is a round-robin tournament of nn people, and each pair of players will face each other exactly once.

The problem is, there are only kk chess boards in the office (k≤n2k \le \frac{n}{2}). So only kk games can be played at the same time. Let's call gg games, being simultaneously played by 2g2g distinct players, where 1≤g≤k1 \le g \le k, a round.

Your task is to help Alex to set a schedule with a minimal number of rounds.

입력

The input contains two integers nn and kk (2≤n≤200,1≤k≤n22 \le n \le 200, 1 \le k \le \frac{n}{2}) --- the number of players and the number of chess boards.

출력

In the first line output an integer rr --- the number of rounds.

Then output rr sections, describing rounds. In the first line of each section, output an integer gg (1≤g≤k1 \le g \le k) --- the number of games in this round. Then output gg lines with two integers each --- the pairs of players that will play in this round. All these 2g2g integers must be distinct integers from 11 to nn.

If there are several possible solutions, output any of them.

예제3

  1. 예제 1

    입력
    4 2
    
    예상 출력
    3
    2
    2 3
    1 4
    2
    2 4
    3 1
    2
    1 2
    3 4
    
  2. 예제 2

    입력
    5 2
    
    예상 출력
    5
    2
    4 1
    2 3
    2
    1 5
    4 2
    2
    2 5
    4 3
    2
    3 5
    2 1
    2
    5 4
    3 1
    
  3. 예제 3

    입력
    6 2
    
    예상 출력
    8
    2
    3 2
    6 4
    2
    5 1
    4 3
    2
    6 1
    2 5
    2
    1 3
    5 6
    2
    2 4
    5 3
    2
    4 1
    2 6
    2
    6 3
    5 4
    1
    2 1