PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000111. Tìm vị trí đổi giá trị (Find by Query)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm vị trí đổi giá trị (Find by Query)

Find by Query

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

The judge holds a hidden binary string S=S1S2…SnS=S_1S_2\ldots S_n with S1=0S_1=0 and Sn=1S_n=1. You only know its length nn. Find any pp satisfying 1≤p<n1\le p<n and Sp≠Sp+1S_p\ne S_{p+1}. Multiple correct indices may exist; any one is accepted. The hidden string is fixed throughout the interaction.

Input

Initially the judge sends a single integer nn. The string SS is not provided. After each valid query, it responds with one character, 0 or 1, on its own line.

Output

Ask for SiS_i by printing ? i with 1≤i≤n1\le i\le n and reading the judge reply. You may ask at most 20 questions. Once a valid position is found, print ! p, flush, and immediately exit. Each message must end with a newline and be flushed.

Interactive Protocol

Lines beginning with ? are queries to the judge; lines beginning with ! are final answers. Do not print any other text to standard output.

Subtasks

  • Subtask 1 (20 points): 2≤n≤402\le n\le 40; Si∈{0,1}S_i\in\{0,1\}; S1=0S_1=0, Sn=1S_n=1.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le 2000; Si∈{0,1}S_i\in\{0,1\}; S1=0S_1=0, Sn=1S_n=1.
  • Subtask 3 (50 points): 2≤n≤2000002\le n\le 200000; Si∈{0,1}S_i\in\{0,1\}; S1=0S_1=0, Sn=1S_n=1.

Examples

Input

7

Output

? 4
? 5
? 6
! 5

This is an illustrative transcript, not a fixed output file. Hidden values are revealed only in the explanation to make the example understandable.

Explanation

Suppose n=7n=7 and the hidden string is 0010011. Querying indices 4,5,64,5,6 returns 0,0,1. Since S5=0S_5=0 and S6=1S_6=1, output ! 5. Other change positions may also be valid.