QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#588741#6394. Turn on the Lightyumingsk#WA 1ms3652kbC++141.1kb2024-09-25 14:17:402024-09-25 14:17:40

Judging History

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

  • [2024-09-25 14:17:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-09-25 14:17:40]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
int fh = 0;
int print(int x)
{
    cout << "? " << x << endl;
    int c;
    cin >> c;
    return c - fh;
}

int f(int l, int r)
{
    if (l == r)
        return l;
    int num = 0;
    int ttt = 1;
    for (int i = l; i <= r; i += ttt)
    {
        if (i != l)
            ttt *= 2;
        int nxt = print(i);
        num++;
        if (nxt == num)
            continue;
        else if (nxt == num - 1)
        {
            return i;
        }
        else
        {
            fh += nxt;
            return f(i / 2 + 1, i - 1);
        }
    }
}
void solve()
{
    int n;
    cin >> n;
    int res = f(1, n);
    cout << "! " << res << endl;
}
int main()
{
    // IOS;
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3652kb

input:

3
1
2

output:

? 1
? 2
? 4

result:

wrong answer Integer parameter [name=x] equals to 4, violates the range [1, 3]