33OJ
登录 注册

#P17578. [JAG 2026 Summer Camp #3] Guess Palindrome

    ID: 20286 远端评测题 2000ms 2048MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>字符串交互题Special JudgeICPC2026

[JAG 2026 Summer Camp #3] Guess Palindrome

Problem Description

Alice has a hidden string SS of length NN consisting only of the two characters a and b. Since she likes symmetric strings, it is known that SS is a palindrome. Your task is to determine SS by asking Alice the following type of query:

  • You provide an arbitrary non-empty string TT of length at most NN consisting only of a and b.
  • Alice responds with an integer representing the number of occurrences of TT as a contiguous substring of SS. Occurrences are counted even if they overlap.

However, to avoid upsetting Alice, you may ask at most ⌊N/2⌋\lfloor N/2\rfloor queries.

Write a program that determines the hidden string SS within the given query limit.

Interaction

First, the length NN of SS (2≤N≤1002\le N\le100) is given from standard input.

After reading the input, you may start asking queries. To ask a query with a string TT, print the following format to standard output, where TT must be a non-empty string of length at most NN consisting only of a and b.

? T

In response to this query, an integer representing the number of occurrences of TT as a contiguous substring of SS is given from standard input.

Once you have determined SS, print your answer to standard output in the following format.

! S

You may ask at most ⌊N/2⌋\lfloor N/2\rfloor queries and print the answer exactly once. After printing the answer, your program must terminate immediately.

If your program violates the specified format, exceeds the query or answer limit, or produces any extraneous output, your submission will be judged as a wrong answer. Note that you may need to flush the output buffer after each output. Note also that the judge for this problem is not adaptive. The judge determines SS before the interaction begins.

9

1

1

4

? aabb

? baa

? aa

! bbaaaaabb