Logo
(追記) (追記ここまで)

23526번 - Lis on Circle 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB522100.000%

문제

There are $n$ people at the round gaming table. Each of them has a set of cards. Every card contains some number $x$. Players make turns consecutively, one after another, starting from the player number 1. A player in his turn can either skip his turn (to pass), or put (and leave on the table) a card with a number that is strictly greater than the previously played last number. No more than $k$ players in a row can pass the turn. All players know the numbers written on the other players cards and always play optimally. Help gamblers to assemble an increasing sequence of maximum length.

입력

The first line contains two numbers $n$ and $k$ --- the number of players and the maximum possible amount of turn skipping in a row.

The next $n$ lines contain the description of the cards players have in their hands. The first number in the $m_i$ is the number of cards the current player has in his hand. The following space separated $m_i$ numbers represent the written on the cards numbers $x$.

출력

In the first line print the single number --- the length of the maximum sequence. In the next lines print two space separated numbers: the player index number and the number written on the card he played. If several solutions exist, output any of them.

제한

  • 0ドル \le \sum m_i \le 10^5$
  • 1ドル \le n \le 10^5$
  • 0ドル \le k < n$
  • 0ドル \le x \le 10^9$

예제 입력 1

3 1
4 1 10 12 20
2 11 21
4 3 5 15 22

예제 출력 1

9
1 1
3 3
1 10
2 11
1 12
3 15
1 20
2 21
3 22

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 18: Grand Prix of Minsk D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /