You are on page 1of 1

PROBLEMS SUBMISSIONS USERS CONTESTS ENVIRONMENT SYLLABUS CPP REFERENCE Hello, ANAST3CH.

 A boring party
Your friend Lina invited you and a bunch of other friends to a costume party to celebrate her success on writing her first code called ''Hello world!''. Since the party was boring, you Submit solution
decided to try and guess Lina's position before the celebration comes to an end.

Weirdly enough, your friends were standing on a line numbered from 1 to N from left to right consecutively. At the beginning, no one knows where Lina is other than her. You can My submissions
perform the following action at most 100000 times (or the party will be over): All submissions
Best submissions
Select one person, ask them where Lina is, if they don't know the answer (or the person is Lina) they will answer with 0 , otherwise they will return either −1 (meaning that Lina's
position is greater then theirs) or 1 (meaning that Lina's position is smaller to theirs). After that, everyone that knows Lina's position will spread it to the people that are next to them (at  Points: 100 (partial)
most 2 new people will know Lina's position after each query).  Time limit: 3.0s

Try to find Lina using the least amount of queries possible.  Memory limit: 256M

Input Specification

The first line contains an integer N (1 ≤ N ≤ 100000) -- the number of people at the party.

Scoring

Your score will be calculated based on the maximal value of Q, the number of queries made.

If Q > 100000 : Score = 0 .


−−−−− −
Q
If 470 < Q ≤ 100000 : Score = 5 + 95 (1 − √ )
100000

If Q ≤ 470 : Score = 100 .

Sample Input
MOI 2023 Qualification - 17:02:48
Copy
5
0
1
-1
0

Sample Output

Copy
? 1
? 4
? 1
? 3
! 3

Notes

In the sample test there are 5 students. Lina was at position 3. At the beginning, no one except for her knew where she was: 0 0 0 0 0. After the first query, she revealed herself to the
people around her (positions 2 and 4): 0 -1 0 1 0. After the second query, the people who knew Lina's position (positions 2, 3, and 4) revealed it to the people around them (positions 1
and 5): -1 -1 0 1 1. After that, everyone knew where Lina was.

Interaction

To ask the friend number i(1 ≤ i ≤ N) ,use the format: ? i.

To guess where Lina is, use the format: ! i (1 ≤ i ≤ N) . (You can only guess once)

After asking a friend or guessing Lina's number, do not forget to output an end of line and to flush the output. Otherwise, you will get an idleness limit exceeded verdict. To do this in
C++, use:

fflush(stdout) or cout.flush()

 Clarifications Request clarification

No clarifications have been made at this time.

proudly powered by DMOJ | English (en)

You might also like