#P4639. [SHOI2011] 编译优化

[SHOI2011] 编译优化

Description

Just like the PASCAL language and the C/C++ language, the SH language is also a programming language. The SH language has 2626 registers, represented by uppercase Latin letters A, B, … , Z. In an SH program, the first line contains the initial values of these 2626 registers in order, separated by spaces. Starting from the second line, each line is one instruction. The SH language has three kinds of instructions, as shown in the table below (in the “Format” column, underscores are used to represent a single space in the actual language).

  • The ADD instruction. Format: ADD_R1_R2. Function: add the value of register R2 to register R1. Restriction: none.

  • The GOTO instruction. Format: IF _R_ < _I1_ GOTO _LINE_ I2. Function: if the value of register R is less than the immediate value I1, then jump to line I2 ( 2\ge 2 ); otherwise, continue to execute the next line. Restriction: it appears at most once, and it can only appear after line I2.

  • The PRINT instruction. Format: PRINT_R. Function: print the value of register R. Restriction: it appears and only appears on the last line.

Given an SH program, output the value printed by the PRINT instruction.

Input Format

Each input file is an SH program. The input guarantees that all initial register values and the immediate values appearing in the GOTO instruction are non-negative integers not exceeding 26312^{63}-1, but during program execution, register values are not limited to this range.

Output Format

Each output file contains only one line with one integer, which is the value printed by the PRINT instruction.

0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADD A B
IF A < 220 GOTO LINE 2
PRINT A
300

Hint

For each test point, if your output is exactly the same as the standard answer, you will get full score for that test point; otherwise, you will get 00 points for that test point.

This is an output-only problem. All 1010 input files compiler1.in ~ compiler10.in have been provided in the download link in the “Background” section. For each input file, you need to provide the corresponding output file compiler1.out ~ compiler10.out.

Note: You only need to submit the output files, and you do not need to submit any program.

Translated by ChatGPT 5