CF1019B.The hat

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is an interactive problem.

Imur Ishakov decided to organize a club for people who love to play the famous game «The hat». The club was visited by nn students, where nn is even. Imur arranged them all in a circle and held a draw to break the students in pairs, but something went wrong. The participants are numbered so that participant ii and participant i+1i+1 ( 1<=i<=n11<=i<=n-1 ) are adjacent, as well as participant nn and participant 11 . Each student was given a piece of paper with a number in such a way, that for every two adjacent students, these numbers differ exactly by one. The plan was to form students with the same numbers in a pair, but it turned out that not all numbers appeared exactly twice.

As you know, the most convenient is to explain the words to the partner when he is sitting exactly across you. Students with numbers ii and sit across each other. Imur is wondering if there are two people sitting across each other with the same numbers given. Help him to find such pair of people if it exists.

You can ask questions of form «which number was received by student ii ?», and the goal is to determine whether the desired pair exists in no more than 6060 questions.

输入格式

At the beginning the even integer nn ( 2<=n<=1000002<=n<=100000 ) is given — the total number of students.

You are allowed to ask no more than 6060 questions.

输出格式

To ask the question about the student ii ( 1<=i<=n1<=i<=n ), you should print «? ii ». Then from standard output you can read the number aia_{i} received by student ii ( 109<=ai<=109-10^{9}<=a_{i}<=10^{9} ).

When you find the desired pair, you should print «! ii », where ii is any student who belongs to the pair ( 1<=i<=n1<=i<=n ). If you determined that such pair doesn't exist, you should output «! -1». In both cases you should immediately terminate the program.

The query that contains your answer is not counted towards the limit of 6060 queries.

Please make sure to flush the standard output after each command. For example, in C++ use function fflush(stdout), in Java call System.out.flush(), in Pascal use flush(output) and stdout.flush() for Python language.

Hacking

Use the following format for hacking:

In the first line, print one even integer nn ( 2<=n<=1000002<=n<=100000 ) — the total number of students.

In the second line print nn integers aia_{i} ( 109<=ai<=109-10^{9}<=a_{i}<=10^{9} ) separated by spaces, where aia_{i} is the number to give to ii -th student. Any two adjacent elements, including nn and 11 , must differ by 11 or 1-1 .

The hacked solution will not have direct access to the sequence aia_{i} .

输入输出样例

  • 输入#1

    8
    
    2
    
    2
    

    输出#1

    
    ? 4
    
    ? 8
    
    ! 4
    
  • 输入#2

    6
    
    1
    
    2
    
    3 
    
    2
    
    1
    
    0

    输出#2

    
    ? 1
    
    ? 2
    
    ? 3
    
    ? 4
    
    ? 5
    
    ? 6
    
    ! -1

说明/提示

Input-output in statements illustrates example interaction.

In the first sample the selected sequence is 1,2,1,2,3,4,3,21,2,1,2,3,4,3,2

In the second sample the selection sequence is 1,2,3,2,1,01,2,3,2,1,0 .

首页