시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 0 0 0 0.000%

## 문제

Consider a Two-Operation Machine (TOM for short) with nine registers, numbered 1…9. Each register stores a non-negative integer in the range 0…1000. The machine has two operations:

 S i j  Store one plus the value of register i into register j. Note that i may equal j. P i  Print the value of register i.

A TOM program includes a set of initial values for the registers and a sequence of operations. Given an integer N (0 ≤ N ≤ 255), generate a TOM program that prints the decreasing sequence of integers N, N-1, N-2, …, 0. The maximum number of consecutive S-operations should be as small as possible.

Example of a TOM program and its execution for N=2:

Operation New Register Values Printed Value
1 2 3 4 5 6 7 8 9
Initial values 0 2 0 0 0 0 0 0 0
P 2 0 2 0 0 0 0 0 0 0 2
S 1 3 0 2 1 0 0 0 0 0 0
P 3 0 2 1 0 0 0 0 0 0 1
P 1 0 2 1 0 0 0 0 0 0 0

## 입력

The first line of the input file contains K, an integer specifying the subtask number.

The second line of input contains N.

## 출력

The first line of output should contain nine space-separated values representing the desired initial values of the registers, in order (register 1, then register 2, etc.).

The rest of the output file should contain the ordered list of operations to be performed, one per line. Thus, the third line contains the first operation to perform, and so on. The last line of the file should be the one that prints 0. Each line should be a valid operation. The instructions should be formatted as in the example output.

번호 배점 제한
1 10

N = 2

2 10

N = 8

3 10

N = 12

4 10

N = 14

5 10

N = 26

6 10

N = 33

7 10

N = 44

8 10

N = 50

9 10

N = 75

10 10

N = 97

11 10

N = 112

12 10

N = 140

13 10

N = 173

14 10

N = 200

15 10

N = 240

16 10

N = 255

## 예제 입력 1

1
2


## 예제 출력 1

0 2 0 0 0 0 0 0 0
P 2
S 1 3
P 3
P 1


Partial points

## 예제 입력 2

1
2


## 예제 출력 2

0 2 1 0 0 0 0 0 0
P 2
P 3
P 1


Full points

## 점수

Scoring of each test case will be based on correctness and optimality of the TOM program given.

Correctness: 20%

A TOM program is correct if it performs no more than 131 consecutive S-operations and the sequence of values printed by it is correct (contains exactly N+1 integers, starting at N and ending at 0). If any S-operation causes a register to overflow, the TOM program is considered incorrect.

Optimality: 80%

Optimality of a correct TOM program is measured by the maximum number of consecutive S-operations in the program, which should be as small as possible. Scoring will be based on the difference between your TOM program and the best known TOM program.

## 채점 및 기타 정보

• 160점 이상을 획득해야 를 받는다.
• 예제는 채점하지 않는다.