#P10649. [ROI 2017] 四轴飞行器编程 (Day 1)

    ID: 12155 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2017交互题Special JudgeO2优化ROI(俄罗斯)

[ROI 2017] 四轴飞行器编程 (Day 1)

Background

Statement

There is a hidden valid bracket string SS in the system, consisting only of ( and ).

Each time, you may ask the system about a subsegment S[l,r]S[l,r] of SS, 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 SS.

Definition of a valid bracket string:

  • The empty string is a valid bracket string.

  • Let A\text{A} be a valid bracket string, then (A)\text{(A)} is also a valid bracket string.

  • Let A\text{A} and B\text{B} be valid bracket strings, then AB\text{AB} 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 nn 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 l,rl,r, meaning you choose S[l,r]S[l,r]. Separate the character and integers with a single space. If S[l,r]S[l,r] is a valid bracket string, the interactive library will output Yes\texttt{Yes} to standard output; otherwise it will output No\texttt{No}.

  • To output the final answer, you should first output a character !, followed by a valid bracket string of length nn. 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 kk.

Hint

Constraints

Subtask ID Score 2n2 \le n \le k=k=
11 2121 1616 150150
22 2828 100100 10410^4
33 2626 10310^3
44 2525 5×1045 \times 10^4 10510^5

Translated by ChatGPT 5