ICPC BAPC 2021 G - Gyrating Glyphs

View as PDF

Submit solution


Points: 17 (partial)
Time limit: 6.0s
Memory limit: 1G

Problem types

You are rocking the latest breakthrough in Computer Science: animated fonts. Suddenly, all of your colleagues' code looks amazing, and you are finally motivated to review it. Unfortunately, due to the constant rotations, it is hard to distinguish between the + (plus) and the × (multiply) operators (all the other characters are still readable). The function you are reviewing takes as input n+1 integers a0,a1,,an and returns the value

((((a0 op1 a1) op2 a2) op3 a3) opn an)mod109+7,

where the n operators op1,op2,,opn are either + or ×. For example when given input (a0,a1,a2)=(1,1,2) with hidden operators (op1,op2)=(+,×), then the function returns ((1+1)×2)=4mod109+7.

You can still execute the function a few times on some input and read the returned value. Use this to recover the operators.

Interaction

This is an interactive problem. Your submission will be run against an interactor, which reads the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:

The interactor first sends one line containing one integer n (1n4000), the number of hidden operators.

Then, your program should make at most 275 queries to determine the operators. Each query is made by printing one line of the form ? a_0 a_1 ... a_n (0ai<109+7). The interactor will respond by printing one line with an integer, the value of

((((a0 op1 a1) op2 a2) op3 a3) opn an)mod109+7,

Make sure you flush the buffer after each write.

When you have determined the operators, print a single line of the form ! s, where s is a string consisting of exactly n characters, which are all + (plus) or x (multiply). The ith character of this string should be opi. This line does not count as one of your queries.

Using more than 275 queries will result in a wrong answer verdict.

Sample Interaction 1

>>> denotes your output. Do not print this out.

Copy
2
>>> ? 1 1 2
4
>>> ? 1 1 3
6
! +x

Sample Interaction 2

>>> denotes your output. Do not print this out.

Copy
10
>>> ? 1 1 1 1 1 1 1 1 1 1 1
5
>>> ? 0 4 2 4 2 4 2 4 2 4 2
6224
>>> ? 1 2 3 4 5 6 7 8 9 10 11
640750
>>> ! ++xxx+x+xx

Comments

There are no comments at the moment.