QOJ.ac

QOJ

満点: 100 出力のみ

#6972. Hacker Techniques

統計

You have recently been very busy, so the King of Jump has given you a problem for ZJOI2015, and you are on your own. You have secretly infiltrated the Kingdom of Jump, intending to steal the problems.

One day, while the King of Jump was out practicing jumping, you snuck into his computer and discovered that the problems were locked by 10 electronic combination locks!

Nothing can stop your determination! Each electronic combination lock contains 10 detection procedures. After entering a combination, if the detection procedure outputs a line of "ok", then that combination lock is unlocked. If you output 10 lines of "ok", then the combination lock is unlocked.

According to common knowledge, the King of Jump must have written the code in the high-level language flea++, and then compiled it into assembly code using the flea++ compiler, and then translated it into machine code using an assembler.

Apparently, you do not have the flea++ source code for these 10 electronic combination locks. Through reverse engineering, you have obtained the assembly code for these 10 electronic combination locks.

When the Jump program starts, it opens an array $a$ of $2^{23}$ 32-bit signed integers, with elements $a_0, a_1, \dots, a_{2^{23}-1}$, all initialized to 0.

In the Jump assembly language, there are three types of operands: "@ $c$", "$ $c$", and "# $c$" (excluding quotes). Here $c$ is an integer and $c \in [-2^{31}, 2^{31})$.

  • "@ $c$" represents the integer constant $c$.
  • "$ $c$" represents $a_c$.
  • "# $c$" represents $a_{a_c}$.

If the program attempts to access an array index that is out of bounds during execution, a Runtime Error will occur and the program will terminate abnormally.

The assembly code consists of several statements, each line is a statement (numbered starting from 1), and the program executes from the first statement downwards.

The statements are as follows:

  • Assignment statement: a b

    • $a, b$ are operands.
    • This means assigning the value of $b$ to $a$.
    • If $a$ is an integer constant, a Runtime Error will occur and the program will terminate abnormally.
  • Input statement: getc c or geti c

    • $c$ is an operand.
    • getc c means reading a character and storing the ASCII code of that character into $c$.
    • geti c means reading the next non-whitespace character position, reading a 32-bit signed integer represented in decimal, and storing it into $c$. (Whitespace characters are ASCII codes 9, 10, 13, 32).
    • If $c$ is an integer constant, a Runtime Error will occur and the program will terminate abnormally. If reading the integer fails, the program will terminate abnormally.
  • Output statement: putc c or puti c

    • $c$ is an operand.
    • putc c means outputting a character, where $c$ is the ASCII code of that character.
    • puti c means outputting the decimal representation of the integer $c$.
  • Conditional jump statement: if c t

    • $c, t$ are operands.
    • This means if $c$ is not 0, then jump to statement $t$ to continue execution (the next statement to be executed becomes the $t$-th statement).
    • If it is 0, then no operation is performed, and the next statement is executed.
  • Arithmetic statement: o a b c

    • $a, b, c$ are operands, $o$ is an operator.
    • This statement performs the operation $o$ on $a$ and $b$, and assigns the result to $c$.
    • If $o$ is +, it means addition, i.e., $a + b$.
    • If $o$ is -, it means subtraction, i.e., $a - b$.
    • If $o$ is *, it means multiplication, i.e., $a \times b$.
    • If $o$ is /, it means division followed by rounding down, i.e., $\lfloor a / b \rfloor$.
    • If $o$ is <, it means $a < b$, the result is 1, otherwise 0.
    • If $o$ is ==, it means $a = b$, the result is 1, otherwise 0.
    • If $c$ is an integer constant or the divisor in division is 0, a Runtime Error will occur and the program will terminate abnormally.

If the program attempts to execute the -1-th statement, the program terminates normally. If it attempts to execute any other non-existent statement, a Runtime Error will occur and the program will terminate abnormally.

If the number of executed statements exceeds $10^7$, a Time Limit Exceeded error will occur and the program will terminate abnormally.

Now, it is time to show your excellent hacking skills!

Input

This problem is for submission of answers. All input files lock1.in ~ lock10.in have been placed in the contestant's directory. Each input file represents the assembly code of a combination lock. We have also provided a simulator for the Jump Kingdom, which can directly execute the assembly code.

First, switch to the directory of this problem in the terminal (Windows users please use cmd). Then run: ./run <code>. Where <code> is the filename of the assembly code you want to execute. For example: ./run lock1.in (Windows users please use run_win32 lock1.in).

The simulator will read data from the terminal. If you want to read from a file, use <. For example: ./run lock1.in <lock1.out

Output

For the given 10 input files lock1.in ~ lock10.in, you need to provide your output files lock1.out ~ lock10.out respectively. Each output file contains some characters, representing the combination you entered.

Examples

Input 1

(input data)

Output 1

(output data)

Note

The program reads an integer. If this integer is 666, it will output 10 lines of "ok".

Scoring

Each combination lock is a test case, and each test case is worth 10 points. For each combination lock, we will use your output file as input to run the combination lock.

If the program terminates abnormally, the test case gets 0 points. Otherwise, we will check the lines output by the combination lock, let $x$ be the number of lines that are "ok". If $x \ge 10$, then the test case gets full marks, otherwise the test case gets $x$ points.

Postscript

You spent a long time trying to crack the combination lock, but in the end, you didn't crack it. Finally, you gritted your teeth and went to ZJOI2015, only to find that your own deeds were written into the problem.

Note

The "32-bit signed integer" mentioned in the problem is equivalent to int in C/C++ and longint in Pascal, capable of representing integers within $[-2^{31}, 2^{31})$. The calculation process may overflow, for example: $2147483647 + 1 = -2147483648$, $100000 \times 100000 = 1410065408$.

ASCII character reference table


またはファイルを一つずつアップロード:

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.