#P10649. [ROI 2017] 四轴飞行器编程 (Day 1)
[ROI 2017] 四轴飞行器编程 (Day 1)
Background
Statement
There is a hidden valid bracket string in the system, consisting only of ( and ).
Each time, you may ask the system about a subsegment of , and the system will return whether this subsegment is a valid bracket string.
Write a program to interact with the system and finally output the exact information of .
Definition of a valid bracket string:
-
The empty string is a valid bracket string.
-
Let be a valid bracket string, then is also a valid bracket string.
-
Let and be valid bracket strings, then is also a valid bracket string.
Interaction Process
You can write a function getProgram() and include grader.h at the beginning of the program to complete the interaction process. This function has no return value and no parameters.
Please write a complete program directly to complete the interaction.
You first need to read an integer from standard input, which is the length of the system string.
You can output queries and the final answer to standard output in the following form:
-
To query whether a substring is valid, you should first output a character
?, followed by two integers , meaning you choose . Separate the character and integers with a single space. If is a valid bracket string, the interactive library will output to standard output; otherwise it will output . -
To output the final answer, you should first output a character
!, followed by a valid bracket string of length . Separate!and the string with a single space.
After answering, you should terminate the program. It is guaranteed that the quadcopter program will not change during the interaction.
During the interaction, your number of queries must not exceed a value .
Hint
Constraints
| Subtask ID | Score | ||
|---|---|---|---|
Translated by ChatGPT 5