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

21986번 - Button Lock 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB23151361.905%

문제

You are standing in front of the room with great treasures. The only thing stopping you is the door with a push-button combination lock. This lock has $d$ buttons with digits from 0ドル$ to $d - 1$. Whenever you press a button, it stays pushed down. You can not pop back up just one button, but there is a "RESET" button --- pressing it pops up all other buttons. Initially, no buttons are pushed down.

The door instantly opens when some specific set of digits is pushed down. Sadly, you don't know the password for it. Having read the documentation for this specific lock, you found out that there are $n$ possible passwords for this particular lock.

Find the shortest sequence of button presses, such that all possible passwords appear at least once during its execution. Any shortest correct sequence of button presses will be accepted.

입력

The first line contains two integers $d$ and $n$ (1ドル \le d \le 10$; 1ドル \le n \le 2^d - 1$). Next $n$ lines describe possible passwords. Each line contains a string $s_i$ of $d$ zeros and ones: for all $j$ from 1ドル$ to $d$ the $j$-th character is 1 iff the button with the digit $j - 1$ must be pushed down.

All strings $s_i$ are different, and each string contains at least one 1.

출력

On the first line, print the number $k$ --- the minimum number of button presses. On the second line, print $k$ tokens, describing the sequence. Whenever you press a button with a digit, print that digit. Whenever you press "RESET", print "R".

제한

예제 입력 1

2 2
10
11

예제 출력 1

2
0 1

예제 입력 2

3 4
001
111
101
011

예제 출력 2

6
2 0 R 1 2 0

노트

In the second example, the sequence 1 2 R 2 0 1 is also possible.

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2020 (Offline) B번

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

출처

대학교 대회

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

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