QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621432#6394. Turn on the Light666ldc#WA 1ms3716kbC++171.2kb2024-10-08 14:29:192024-10-08 14:29:36

Judging History

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

  • [2024-10-08 14:29:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3716kb
  • [2024-10-08 14:29:19]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define int long long
// #define endl '\n'
using i128 = __int128;
using i64 = long long;
using f128 = long double;
using u64 = unsigned long long;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;
const i64 inf = 2e18;
//-------------------------------------------
void solve()
{
    int n;
    cin >> n;
    int l = 1, r = n;
    int ct = 0;
    auto check = [&](int x)
    {
        int t;
        cout << "? " << x << endl;
        cin >> t;
        if (ct < t)
        {
            ct = t;
            return true;
        }
        else if (ct >= t)
        {
            ct = t;
            return false;
        }
    };

    while (r > l)
    {
        int mid = l + r >> 1;
        if (check(mid))
            l = mid + 1;
        else
            r = mid;
    }

    cout << "! " << r << endl;
}
signed main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; i++)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1

output:

? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3

output:

? 5
? 8
? 9
! 10

result:

wrong answer Wrong answer, more than 1 possible light!