QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#876572#9734. Identify ChordyuanruiqiWA 1ms3584kbC++261.8kb2025-01-31 00:22:152025-01-31 00:22:16

Judging History

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

  • [2025-01-31 00:22:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3584kb
  • [2025-01-31 00:22:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
void out(int x, int y)
{
    cout << "! " << x << ' ' << y << endl;
}
int ask(int x, int y)
{
    cout << "? " << x << ' ' << y << endl;
    int z;
    cin >> z;
    return z;
}
void solve()
{
    int n;
    cin >> n;
    int x = rng() % n + 1, y = (x + n / 2 - 1) % n + 1;
    for (;;)
    {
        int z = ask(x, y);
        if (z == n / 2)
        {
            if (n % 2 == 0) x = x % n + 1, y = y % n + 1;
            else if ((y - x + n) % n == n / 2) y = y % n + 1;
            else x = x % n + 1;
            continue;
        }
        int p = (x + n - 2) % n + 1, q = x % n + 1;
        int a = 0;
        if (ask(p, y) == z - 1)
        {
            int l = 1, r = (x - y + n) % n - 2;
            while (l < r)
            {
                int m = (l + r + 1) >> 1;
                if (ask((x - 1 + n - m) % n + 1, y) == z - m) l = m;
                else r = m - 1;
            }
            a = (x - 1 + n - r) % n + 1;
        }
        else if (ask(q, y) == z - 1)
        {
            int l = 1, r = (y - x + n) % n - 2;
            while (l < r)
            {
                int m = (l + r + 1) >> 1;
                if (ask((x - 1 + m) % n + 1, y) == z - m) l = m;
                else r = m - 1;
            }
            a = (x - 1 + r) % n + 1;
        }
        else a = x;
        z = ask(a, y) - 1;
        if (ask(a, (y - 1 + z) % n + 1) == 1) out(a, (y - 1 + z) % n + 1);
        else out(a, (y - 1 + n - z) % n + 1);
        break;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
6
3
2
2
1
1
1
1
4
0
0
0
0
0
-1

output:

? 6 3
? 1 4
? 6 4
? 2 4
? 2 4
? 2 4
! 2 4
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
! 1 1

result:

wrong answer Wrong answer n=4, actual=1-3, guessed=1-1 (test case 2)