QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397129#6394. Turn on the LightsWA 1ms3808kbC++141.2kb2024-04-23 17:12:022024-04-23 17:12:04

Judging History

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

  • [2024-04-23 17:12:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3808kb
  • [2024-04-23 17:12:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
const int N = 1e6 + 10;
const int M = 4e5 + 10;
const int mod = 998244353;
const int inf = 1e18;
typedef long long ll;
typedef pair<int, int> pii;
typedef array<int, 3> ary;
#define PI acos(-1)
// #define endl '\n'
#define pb push_back
mt19937 rnd(time(0));
#define xx first
#define yy second
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

int l, r, n, x;
int as = 0;
void query(int x)
{
    cout << "? " << x << endl;
}
void solve()
{
    cin >> n;
    cout << "? 1" << endl;
    cin >> x;
    if (x == 0)
    {
        cout << "! 1" << endl;
        return;
    }
    as = 1;
    l = 2, r = n;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        query(mid);
        cin >> x;
        if (x == as)
        {
            cout << "! " << mid << endl;
            return;
        }
        if (x > as)
        {
            l = mid + 1;
        }
        else
        {
            r = mid;
        }
        as = x;
    }
    cout << "! " << l << endl;
}

signed main()
{
    IOS int _ = 1;
    // cin>>_;
    while (_--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2

output:

? 1
? 2
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3728kb

input:

10
1
0
1
2

output:

? 1
? 6
? 4
? 5
! 6

result:

wrong answer Wrong answer, more than 1 possible light!