#P7336. [JRKSJ R1] 1+1

    ID: 6252 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>搜索2021洛谷原创交互题Special JudgeO2优化

[JRKSJ R1] 1+1

Description

Gameplay Overview

"1+1" is a two-player competitive game. Each player has two numbers. On each turn, a player may add one of their own numbers to one of the opponent’s numbers; if the result is greater than 99, then only the ones digit is kept. The two players take turns doing this. For example, the following records several rounds of the game, where the two players are a and b:

In the explanations below, the first position marked with * is the first player.

a:1 1*(initial position)
b:1 2

a:1 3(1+2)
b:1 2

a:1 3
b:1 5(2+3)

a:6 3(1+5)
b:1 5

Special Positions

We call the following cases "attack":

3 3
5 3
6 1
9 1

The "attack level" of these attacks is 11, except for 9 1. The attack level of 9 1 is 22.

We call the following cases "defense":

5 1
5 5

The "defense level" of these defenses is 11, except for 5 5. The defense level of 5 5 is 22.

Of course, for all attacks or defenses, the order of the two numbers does not matter. For example, 5 1 and 1 5 are both considered defenses, and 9 1 and 1 9 are both considered attacks, with the same attack/defense levels.

If player a has a defense, and player b makes an attack on the next move, as in the following:

a:1 5
b:1 1*

a:1 5
b:6 1

Then at this moment, a holds 1 5 with defense level 11, and b holds 6 1 with attack level 11. In this case, a’s numbers should be changed to 1 1, and b’s attack this turn is invalid.

That is, if a’s attack level is equal to b’s defense level, then change b’s two numbers to 1 1, and treat a’s attack this turn as invalid.

We consider the attack/defense level of any position not belonging to the above attacks/defenses to be 00 (such as 3 4, etc.).

In particular, if the following situation occurs:

a:5 5
b:1 1*

a:5 5
b:1 6

a’s defense level is 22 while b’s attack level is 11. In this case, a should be changed to 5 1, and b’s attack this turn is invalid.


Winning Condition

If after one side finishes a move, their attack level is strictly greater than the other side’s defense level, then that side wins. In this case, no changes should be made, even if the rules would otherwise require changing the other side to 1 1 or 5 1.

An example is given below:

a:1 1
b:6 3*

a:1 1
b:6 4

a:1 5
b:6 4

a:1 5
b:6 9

a:1 1
b:6 9

a:1 1
b:6 0

a:1 7
b:6 0

a:1 7
b:6 1

( b wins)

To remove ambiguity, here are some more examples:

a:5 5
b:1 4*

a:1 1
b:1 9

a:1 0( 1+9=10 ,the ones digit is 0 )
b:1 9

a:1 0
b:1 9(note here: b used 1 (or 9) plus a’s 0, which also counts as a new attack)

( b wins)
a:1 1*
b:1 4

a:1 5
b:1 4

a:1 5(because this is the last move, there is no need to change to “1 1”)
b:1 9(here b’s “1 9” directly crushes a’s “1 5”)

( b wins)

Now, you are asked to write a program to play this game as the first player, via interaction, against mcyl35’s program.

Input Format

The first line contains five integers p0,p1,c0,c1,Pp_0,p_1,c_0,c_1,P, which represent your two numbers, mcyl35’s two numbers, and the test point ID.

Each following line contains two integers x,yx,y, indicating that mcyl35’s xx-th number was added to your yy-th number.

This problem uses interactive IO. For details, see P1733 Guess the Number (Interactive IO Version).

Output Format

Each line outputs two integers x,yx,y, indicating that your xx-th number is added to mcyl35’s yy-th number.

1 1 1 2 0
1 1
1 0
0 0
0 1
0 0

Hint

Constraints and Conventions

For test point 11, it is guaranteed that the player can win in one move.

For test point 22, it is guaranteed that mcyl35’s program makes random moves.

For other test points, there are no special guarantees.

For 100%100\% of the data, 0p0,p1,c0,c190\le p_0,p_1,c_0,c_1\le 9.

Scoring Rules

  • If there is illegal output (for example, the output contains numbers other than 0,10,1), you get 00 points.

  • If you win, or if mcyl35 makes 100100 moves or more in this test point, you get full score.

  • Otherwise, you get st20\lfloor \dfrac {st} {20} \rfloor points, where stst is the number of moves taken, and one move means mcyl35 makes one move.

Notes

When the interactive library does not return a number, it means the result has already been judged.

Sample Explanation

pl:1 1*
cp:1 2

pl:2 1
cp:1 2

pl:2 1
cp:1 3

pl:5 1
cp:1 3

pl:5 1
cp:1 8

pl:6 1(Win)
cp:1 8

Translated by ChatGPT 5