QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613136#8239. Mysterious Treefosov#WA 0ms3576kbC++141.4kb2024-10-05 13:36:592024-10-05 13:37:16

Judging History

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

  • [2024-10-05 13:37:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2024-10-05 13:36:59]
  • 提交

answer

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

#define ll long long 
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353

#define M 100010

bool qry(int u, int v) {
    cout << "? " << u << " " << v << '\n';
    cout.flush();
    bool res; cin >> res;
    return res;
}

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t; cin >> t;
    while (t --) {
        int n; cin >> n;
        
        int r0 = n-1, r1 = n-1;

        int ecnt = 0;
        for (int i = 1; i < n-1; i += 2) {
            bool he = qry(i, i+1);
            if (he) ++ ecnt, r0 = i, r1 = i+1;
        }

        if (ecnt > 1) {
            cout << "! 1" << '\n';
            cout.flush();
            continue;
        }

        if (r0 == r1) {
            bool star = qry(r0, 1) && qry(r0, 2) && qry(r0, 3);
            cout << (star ? "! 2" : "! 1" ) << '\n';
            cout.flush();
        } else {
            int op1 = r0 == 1 ? 3 : 1;
            int op2 = r0 == 1 ? 4 : 2;
            bool star = 0;
            
            if (qry(r0, op1)) {
                star = qry(r0, op2);
            } else {
                star = qry(r1, op1) && qry(r1, op2);
            }
            cout << (star ? "! 2" : "! 1" ) << '\n';
            cout.flush();
        }
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

2
4
1
0
1
0
4
0
1
1

output:

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

result:

wrong answer u != v (test case 2)