QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371546#6394. Turn on the LightHosamaJJFWA 1ms3660kbC++17768b2024-03-30 13:54:232024-03-30 13:54:24

Judging History

你现在查看的是最新测评结果

  • [2024-03-30 13:54:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2024-03-30 13:54:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int n, x, xx;

int main()
{
    cin >> n;
    cout << "? 1\n";
    cout.flush();
    cin >> x;
    if (x == 0)
    {
        cout << "! 1\n";
        cout.flush();
        return 0;
    }
    int t = 40, l = 2, r = n;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        cout << "? " << mid << "\n";
        cout.flush();
        cin >> xx;
        // cout<<"- "<<xx<<"\n";
        if (xx < x)
        {
            r = mid - 1;
        }
        else if (xx > x)
        {
            l = mid + 1;
        }
        else
        {
            cout << "! " << mid << "\n";
            cout.flush();
            break;
        }
        x = xx;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3644kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3660kb

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5

result:

wrong answer format  Unexpected end of file - token expected