#P7827. 「RdOI R3 附加」ACP-I
「RdOI R3 附加」ACP-I
Background
Note: This is not a simulation problem. Please read the entire statement carefully before you start.
Leaderboard
| task | Shortest Lines | Achiever |
|---|---|---|
| 1 | 5 | std |
| 2 | 191 | __Ultimium__ |
| 3 | 845 | dead_X |
| 4 | 24 | 囧仙 (jiong xian) |
| 5 | 77 | dqstz |
| 6 | 15078 | 寻逍遥2006 (xun xiao yao 2006) |
| 7 | 211 | liqingyang |
| 8 | 6796 |
If your solution uses strictly fewer lines than the number on the list, please contact
The problem name ACP has two meanings: Ancient Computer Program and Another Construct Problem.
In 1951, on the eve of the -th National Olympiad in Informatics winter camp for teenagers, Little A used a Time Transport Interface (Time Transport Interface) to connect to a computer from 2015, and obtained the problems of the 32nd winter camp to practice.
He opened the third problem, "Future Program":
This is an output-only problem with 10 test points.
For each test point, you are given the source code of a program and the input of that program. You need to run the program and save its output.
Unfortunately, these programs are extremely inefficient, and cannot produce output within the 5-hour contest time.
Little A thought about it and decided to try running this problem on a 1951 computer. However, because the 1951 computer has too little storage space, he cannot transfer the attachments and data. Please help Little A write the standard solution to generate testdata.
Problem Description
This is an output-only problem.
Little A's antique computer uses two stacks of -bit unsigned integers, and , to store data. Each stack initially contains zeros.
For convenience, let "" denote the top element of stack . Let the symbols "", "", and "" represent bitwise AND, bitwise OR, and bitwise XOR operations, respectively.
This computer supports 8 assembly instructions. Unless otherwise stated, all parameters of the following instructions are integers.
| Name | Parameters | Description | Pseudocode |
|---|---|---|---|
| Set to the bitwise AND of and the other stack’s top. | |||
| Set to the bitwise OR of and the other stack’s top. | |||
| Set to the bitwise XOR of and the other stack’s top. | |||
| Set to left-shifted by bits, with natural overflow. | |||
| Set to right-shifted by bits, with natural overflow. | |||
| Set to the bitwise NOT of . | |||
| Pop the top element of stack . | |||
| Move from to the other stack, i.e., to . | $\text{Push}\ T_i\text{ to }S_{i\oplus 1};\ \textbf{pop}\ i$ |
You need to use these assembly instructions to implement several computation tasks, where each test point corresponds to a separate task.
Below, "input " means pushing the integers into stack in order, while the zeros at the bottoms of both stacks remain unchanged. Unless otherwise stated, all input numbers are integers in the range .
"Output " means that after the instructions finish running, several integers will be taken out from in order as to check whether the result is correct. Besides these, after execution, all numbers in and all numbers in that are not taken out may be arbitrary.
- Input , output . That is, swap the two numbers.
- Input , output . That is, compute the difference with natural overflow.
- Input , i.e. . Treat as a length- string under ASCII encoding. You need to reverse the string and then convert it into the corresponding decimal integer and output it. That is, implement a fast input routine. In particular, the string may have leading zeros.
- Input , output . Here is the number of bits in the binary representation of .
- Input , output .
- Input , where is a non-negative power of or zero. Output . In particular, when , output .
- Input , where both and the answer are non-negative powers of or zero, output .
- Input , output , i.e., the greatest common divisor of .
Input Format
Since the setter does not want to make this a big simulation problem, the assembly simulation part is provided in the attachment.
In the distributed files, there are checker.cpp and 1.ans ~ 8.ans. Among them, checker.cpp provides simple implementations of several assembly instructions. You can use checker.cpp to test your program. Compile checker.cpp with g++ checker.cpp -o checker -std=c++11 into an executable, then run checker *.in *.out *.ans. The checker will output your results and the score for that test point. Here *.in contains the input data given to the instructions, one per line, ending at EOF; *.out stores your instructions; *.ans refers to the .ans files in the distributed package.
Note: This checker is only a sample and does not have the ability to verify correctness.
Output Format
Please write the instructions for each task into 1.out ~ 8.out, then pack them into a zip and submit.
123456789
2147483648
2147483648
123456789
2147483647998244353
9982443532147483647
10611784189560312322
51
53
51
52
52
50
56
57
57
998244353
233456
1
2147483647998244353
9223372036854775808
2147483647998244353
2147483647998244353
9982443532147483647
9223372036854775808
7806477557104029183
4611686018427387904
2147483648
24 32
8
输入 a,b。输出 a 按位异或 b 的结果。
mov 0
xor 1
没有输入,输出数字 6。
not 1
lsh 1 62
rsh 1 61
Hint
Sample Explanation
The above "sample groups " represent the sample input/output for subtasks . "Sample groups " are one shortest program implementation for an example problem.
Scoring
Let * denote the test point index. If your instructions (*.out) do not correctly complete the computation, you get points. Otherwise, let the number of instructions you used be . If there are numbers in *.ans that satisfy , then you get points for that test point.
Notes
Although you are allowed to submit up to lines of instructions, due to Luogu’s time limit for running the checker, your instruction length is forced to have a strange upper bound: approximately . If you exceed this length, the checker may time out and cause UKE.
Due to the nature of Luogu output-only problems, if you cannot solve some tasks, please put an empty *.out file as a placeholder in the zip, where * is the task number. Otherwise, the whole problem may have mismatched answers (for example, 2.out being submitted to test point ), causing the following test points to become points.
Translated by ChatGPT 5