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

27407번 - CPR (Cut-Paste-Reverse) 점수다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.1 초 1024 MB138770.000%

문제

Consider the list of integers 1, 2, ..., N. On this list you can perform a series of cut-paste operations. A cut-paste operation <x, y, z> consists of cutting the sequence between the values x and y and inserting the sequence immediately after the value z (z can also be 0 to designate an insertion at the beginning of the list). A triplet <x, y, z> constitutes a correct cut-paste operation if

  • x appears before y in the list, or x = y;
  • z appears outside the sequence from x to y, or z = 0.

Find a series of correct operations that reverses the list, so that after performing the operations the list becomes N, N - 1, ..., 2, 1. The fewer operations you require, the higher your score will be.

입력

The input contains a single integer number N, representing the length of the list.

출력

The outpu must contain a number M on the first line, representing the number of cut-paste operations. Each of the following M lines must contain three numbers x y z representing an operation.

제한

  • 1 ≤ N ≤ 5,000

점수

Test cases will be scored individually. For every test, if your solution requires M operations, you will earn points as follows (slashes denote integer divisions):

  • 100 points if M ≤ N / 2 + 1;
  • 80 points if N / 2 + 1 < M ≤ 2 * N / 3;
  • 60 points if 2 * N / 3 < M ≤ 3 * N / 4;
  • 40 points if 3 * N / 4 < M ≤ 4 * N / 5;
  • 20 points if 4 * N / 5 < M ≤ 5 * N / 6;
  • 0 points if M > 5 * N / 6.

The score for the task will be the minimum of the scores for each test.

예제 입력 1

6

예제 출력 1

4
2 6 0
4 5 0
3 6 4
6 5 0

힌트

The initial list is 1 2 3 4 5 6

After the first operation, the list becomes 2 3 4 5 6 1 (The operation 1 1 6 would have had the same result.)

After the second operation, the list becomes 4 5 2 3 6 1

After the third operation, the list becomes 4 3 6 5 2 1

After the fourth operation, the list becomes 6 5 4 3 2 1

This solution earns full points as 4 = 6 / 2 + 1.

출처

Olympiad > Romanian Master of Informatics > Romanian Master of Informatics 2016 4번

채점 및 기타 정보

  • 100점 이상을 획득해야 를 받는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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