#P2838. 瓶子国的故事

瓶子国的故事

Description

We use the amount of water to represent a number.

  • The capacity of a bottle is the maximum amount of water it can hold.

The king of Bottle Country believes bottles can do the following:

  • I\verb!I!: Create a new bottle whose capacity and current amount of water are both equal to the input number. Its index is 当前最大编号+1\textbf{当前最大编号} +1.
  • s\verb!F !s: Fill the bottle with index ss to its full capacity.
  • s\verb!E !s: Empty the bottle with index ss.
  • s\verb!C !s: Create a new bottle with capacity ss and no water in it. Its index is 当前最大编号+1\textbf{当前最大编号} +1. Note that due to limited capacity, 0s1090\le s\le 10^9.
  • s\verb!M !s: Create a new bottle whose capacity equals s 号瓶子里装的水的数量\textbf{s 号瓶子里装的水的数量} and which initially contains no water. Its index is 当前最大编号+1\textbf{当前最大编号}+1.
  • a b\verb!T !a\ b: Pour water from bottle aa into bottle bb until bottle aa becomes empty or bottle bb becomes full (note aba\neq b).
  • s\verb!O !s: Output the amount of water in bottle ss.

There is also an expensive operation:

  • a b\verb!K !a\ b: Create a new bottle whose capacity equals a 号瓶子的容量×b 号瓶子的容量\textbf{a 号瓶子的容量} \times \textbf{b 号瓶子的容量}. Its index is 当前最大编号+1\textbf{当前最大编号}+1. Note that due to capacity limits, a 号瓶子的容量×b 号瓶子的容量\textbf{a 号瓶子的容量}\times\textbf{b 号瓶子的容量} must not exceed 10910^9. (Using this operation deducts points; see the scoring rules below.)

The king gives you these operations; you only need to output them, and the bottles will execute them for you!

The king of Bottle Country gives you several computational tasks. Just implement these tasks.

On the left are the data point IDs; on the right are the tasks:

  1. Given aa and bb, compute a+ba+b. (0a,b1050\le a,b\le 10^5)
  2. Given aa and bb, compute ab|a-b|. (0a,b1050\le a,b\le 10^5)
  3. Given aa and bb, compute max(a,b)\max(a,b). (0a,b1050\le a,b\le 10^5)
  4. Given aa and bb, output gcd(a,b)\gcd(a,b). (1a,b10001\le a,b\le 1000)
  5. Given aa, output the 32-bit binary representation of aa. (0a1050\le a\le 10^5, for example, 55 outputs $\verb!0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1!$)
  6. Given aa and bb, output a×ba\times b. (0a,b10000\le a,b\le 1000)
  7. Given aa and bb, output aba\oplus b. (0a,b1050\le a,b\le 10^5, where \oplus denotes bitwise XOR)
  8. Given aa, output a÷10\lfloor a\div 10 \rfloor. (1a100001\le a\le 10000)
  9. Given aa and bb, output a×bmod262144a\times b \bmod 262144. (0a,b1050\le a,b\le 10^5)
  10. Given aa and bb, output aba^b. (1a,b10001\le a,b\le 1000, and aba^b does not exceed 10610^6)

The king will generate about 3030 groups of testdata to test your program and will score it based on the number of operations you use. See the scoring rules below.

(UPD: If you did not understand the problem, here is an additional explanation.)

Your program submitted to Luogu (C/C++/Pascal) must output a sequence of operations in the format similar to the sample output.

For example, for the first data point, after submission the checker on Luogu will randomly generate aa and bb as the inputs to the I\verb!I! operation to test your operations.

For the local checker (see the Hint section for download), you can save your output operations to a file named a.txt. Then input a.txt on the first line. On the second line, input 00 if playing manually, or input the specific data point ID if testing that point.

Input Format

A single line containing one integer representing the data point ID.

Output Format

Output a sequence of operations that satisfies the computational task.

233
// 仅作为参考,这里应该填数据编号
I
C 1
F 2
C 233333
T 1 3
T 2 3
O 3
(这个程序可以进行x+1!是不是很厉害啊!不过程序中并不能附加任何注释)

Hint

Please note you are submitting a program that outputs operations! (If you generate the answers and then delete the program and directly hardcode the outputs, your output might exceed limits.)

Inspired by NOI2016 “Wilderness Big Computation” (you probably knew that anyway).

For convenient local testing, here is a C++ local checker (note that its results may differ from Luogu’s; Luogu may be stricter):

If you need an executable, you can use Baidu Netdisk:

Scoring Rules:

If your algorithm produces a wrong result (extra outputs also count), or a runtime error occurs (operations violate the rules, etc.), or the number of lines exceeds 5×1065\times 10^6, or the lines are so many that the checker cannot finish testing 3030 groups within 11 s, you receive 00 points.

Otherwise, suppose the standard solution uses ss steps and your solution uses xx steps.

  • If xsx\le s, your base score is 1010 points.
  • If s<xs+5s<x\le s+5, your base score is 99 points.
  • If s+5<x3ss+5<x\le 3s, your base score is 88 points.
  • If 3s<x10s3s<x\le 10s, your base score is 77 points.
  • If 10s<x50s10s<x\le 50s, your base score is 66 points.
  • If x>50sx>50s, your base score is 55 points.

If you use the expensive K\verb!K! operation, you will get (base score 4-4) points.

Otherwise, you will receive the base score.

(In plain words: fewer steps → higher score; using the K operation deducts 4 points.)

(UPD2: Common checker error messages on Luogu)

too many lines:超过500w行(这个似乎还没有触发过)
WTF:就是操作的第一个字符串(I/T/K/F/E/C/M/O)长度大于1
(可能是由于上一个操作多跟了一个操作数?)
wrong operation:操作的第一个字符串长度为1但不是I/T/K/F/E/C/M/O。
expected *****:希望输入一个数/字符串却没有(可能是操作数多打/少打)
nothing to input:I操作数量大于输入的数数量
F/E/C/M/T/O/K wrong bottle:操作的瓶子编号不在[1,当前最大编号]范围内
C exceed [0,10^9]:字面意思
K exceed 10^9:字面意思
wa on test xxx:你在第xxx组随机数据狗带了
wa on extratest xxx:你在第xxx组人工数据(手打的)狗带了

Translated by ChatGPT 5