CF1697D.Guess The String

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307.

The jury has chosen a string ss consisting of nn characters; each character of ss is a lowercase Latin letter. Your task is to guess this string; initially, you know only its length.

You may ask queries of two types:

  • 11 ii — the query of the first type, where ii is an integer from 11 to nn . In response to this query, the jury will tell you the character sis_i ;
  • 22 ll rr — the query of the second type, where ll and rr are integers such that 1lrn1 \le l \le r \le n . In response to this query, the jury will tell you the number of different characters among sl,sl+1,,srs_l, s_{l+1}, \dots, s_r .

You are allowed to ask no more than 2626 queries of the first type, and no more than 60006000 queries of the second type. Your task is to restore the string ss .

For each test in this problem, the string ss is fixed beforehand, and will be the same for every submission.

输入格式

Initially, the jury program sends one integer nn on a separate line — the size of ss ( 1n10001 \le n \le 1000 ).

输出格式

To give the answer, print one line ! s with a line break in the end, where ss should be the string picked by the jury. After that, your program should flush the output and terminate gracefully.

Interaction

To ask a query, you should send one line containing the query, in one of the following formats:

  • ? 1 i — for a query of the first type ( 1in1 \le i \le n );
  • ? 2 l r — for a query of the second type ( 1lrn1 \le l \le r \le n ).

Don't forget to flush the output after sending the query line.

The answer to your query will be given on a separate line. For a query of the first type, the answer will be the character sis_i . For a query of the second type, the answer will be an integer equal to the number of different characters among sl,sl+1,,srs_l, s_{l+1}, \dots, s_r .

You are allowed to ask no more than 2626 queries of the first type, and no more than 60006000 queries of the second type.

In case you ask too many queries, or the jury program fails to recognize your query format, the answer to your query will be one integer 00 . After receiving 00 as the answer, your program should terminate immediately — otherwise you may receive verdict "Runtime error", "Time limit exceeded" or some other verdict instead of "Wrong answer".

输入输出样例

  • 输入#1

    5
    4
    u
    2
    g
    e
    s
    1

    输出#1

    ? 2 1 5
    ? 1 2
    ? 2 1 2
    ? 1 1
    ? 1 3
    ? 1 4
    ? 2 4 5
    ! guess

说明/提示

Let's analyze the example of interaction.

The string chosen by the jury is guess, so initially the jury sends one integer 55 .

  1. the first query is ? 2 1 5, which means "count the number of different characters among s1,s2,,s5s_1, s_2, \dots, s_5 ". The answer to it is 44 .
  2. the second query is ? 1 2, which means "tell which character is s2s_2 ". The answer to it is u.
  3. the third query is ? 2 1 2, which means "count the number of different characters among s1s_1 and s2s_2 ". The answer to it is 22 .
  4. the fourth query is ? 1 1, which means "tell which character is s1s_1 ". The answer to it is g.
  5. the fifth query is ? 1 3, which means "tell which character is s3s_3 ". The answer to it is e.
  6. the sixth query is ? 1 4, which means "tell which character is s4s_4 ". The answer to it is s.
  7. the seventh query is ? 2 4 5, which means "count the number of different characters among s4s_4 and s5s_5 ". The answer to it is 11 , so it's possible to deduce that s4s_4 is the same as s5s_5 .

In the end, the answer is submitted as ! guess, and it is deduced correctly.

首页