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

17652번 - Domino 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB2000.000%

문제

The set for playing Domino is composed of rectangular pieces of size 2 x 1, each of them divided in two equal halves by a straight line parallel to the shorter side of the rectangular. On each of the two halves dots are drown. The number of dots in one half varies from 0 to M, inclusive. The pieces of a domino set have all possible different unordered pairs of numbers. For example, if M = 3, then the corresponding domino full set contains 10 pieces: {0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 1}, {1, 2}, {1, 3}, {2, 2}, {2, 3}, {3, 3}. The pieces of the domino set can be arranged in chains. Two pieces can be joined by their shorter sides when the corresponding halves have the same number of dots drawn on them.

Suppose that N pieces are removed from the full set (but not all of them). It is interesting to know the minimal number of chains that it is possible to build so that each piece is included in exactly one chain. Write a program to solve the task: by given M and the list of the removed pieces you have to find the minimum number of chains with the described property

입력

The first line of the standard input will contain the maximum number M of dots that are drawn on one half of a piece and the number N of removed pieces. It follows N lines and the i-th of these lines contains the numbers Ai and Bi – the number of dots on both halves of the i-th removed piece.

출력

The program has to print on the first line of the standard output the found minimum number of chains V. Each of the next V lines has to contain one of the found chains, presented as a sequence of numbers from the interval from 0 to M in which each two consecutive numbers are the dots of the two parts of the current piece. The numbers in each line are separated by one space. Each sequence has to end with -1.

제한

  • 0 ≤ M ≤ 1024

예제 입력 1

3 5
0 2
1 1
1 2
1 3
3 3

예제 출력 1

1
2 2 3 0 0 1 -1

힌트

The chain of the pieces is: {2,2}, {2,3}, {3,0}, {0,0}, {0,1}.

출처

Olympiad > International Autumn Tournament in Informatics > 2018 > Group B (Juniors) 6번

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

출처

대학교 대회

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

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