logo AlgoBeat OnlineJudge
登录 注册

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

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

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

However, to avoid upsetting Alice, you may ask at most queries.

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

Interaction

First, the length of () is given from standard input.

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

? T

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

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

! S

You may ask at most 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 before the interaction begins.

样例

样例输入 1

9

1

1

4

样例输出 1


? aabb

? baa

? aa

! bbaaaaabb