409472: GYM103575 C Primle

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Primletime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

This is an interactive problem.

The jury has chosen a secret five-digit prime number (without leading zeros). Your task is to guess this number. Whenever you make a guess, the jury's program will tell you which digits are correct and which ones are present but are currently in the wrong place.

Consider an example where the jury has chosen 19937 and your guess is 31357. The response for your guess will be ??-{}-+: the last 7 is in the correct place; the first two digits appear in the number but in other places. Note that the second occurrence of $$$3$$$ is marked as a - because there is only one $$$3$$$ in the secret prime number.

A more formal description of the response: let the secret prime be $$$S = s_1 s_2 s_3 s_4 s_5$$$ and your guess it $$$T = t_1 t_2 t_3 t_4 t_5$$$. For every $$$i$$$ such that $$$s_i = t_i$$$, the response will contain +. Let's call all such places used. For every remaining index, going from left to right, we'll make the following check: if $$$t_i$$$ is present among the yet unused digits in $$$S$$$, then the $$$i$$$-th character of the response will contain ?, and the corresponding digit in $$$S$$$ is marked as used. All remaining characters in the response will be -.

This game has two different modes: an easy mode and a hard mode. In easy mode, you are allowed to guess any five-digit with (possibly, with leading zeros). In hard mode, all your guesses have to be five-digit primes (without leading zeros). In addition, there is a limit on the number of guesses you can make for each subtask.

Each test will contain $$$T$$$ rounds. In every round, you have to guess a secret prime number. The prime numbers in each test are chosen beforehand and will be the same throughout the contest.

Interaction

You should start the interaction by reading a string describing the current mode and $$$L$$$ — the maximum number of guesses you can make during each round. The easy mode is described by the string «easy», and the hard mode is described by the string «hard».

Then, you should read the integer $$$T$$$ ($$$1 \le T \le 10$$$) — the number of rounds in the current test.

Every round starts with your program sending a five-digit string. In hard more, this string should denote a five-digit prime number without leading zeros. In easy mode, there are no restrictions on this five-digit string. Then, the jury program sends the response — a string with five characters -, ?, or +. If you either violated the interaction protocol or didn't guess the secret prime number on your $$$L$$$-th attempt, you will receive !!!!! as a response. After receiving such a response, you should terminate your program.

After receiving the +++++ response, the next round will start immediately. If it was the last round, finish the execution. Don't forget to print the line break character or flush the output after each guess.

Scoring
SubtaskPointsHard mode?ConstraintsRequired subtasks
17$$$-$$$$$$L = 100$$$
211$$$+$$$$$$L = 100$$$1
38$$$-$$$$$$L = 10$$$1
415$$$+$$$$$$L = 10$$$1,2,3
512$$$-$$$$$$L = 7$$$1,3
616$$$+$$$$$$L = 7$$$1,2,3,4,5
714$$$-$$$$$$L = 5$$$1,3,5
817$$$+$$$$$$L = 5$$$1,2,3,4,5,6,7
ExamplesInput
easy 10
1

-??+-

-+--?

+++++
Output


12345

78778

28843
Input
hard 5
1

??--+

?+--?

+++++
Output


31357

99083

19937

加入题单

算法标签: