QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507826#8239. Mysterious TreeHe2717970784WA 1ms3732kbC++171.7kb2024-08-06 21:25:542024-08-06 21:25:54

Judging History

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

  • [2024-08-06 21:25:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2024-08-06 21:25:54]
  • 提交

answer

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

void solve(){
    int n = 0;
    cin >> n;
    for(int i = 1;i <= n;i += 2){
        int x = min(i,n - 1),y = min(i + 1,n);
        cout << "? " << x << ' ' << y << endl;
        cout.flush();
        int op = 0;
        cin >> op;
        if(!op){
            continue;
        }
        vector<int>v;
        for(int k = 1;k <= 4;k++){
            if((k != x) && (k != y)){
                v.push_back(k);
            }
        }
        cout << "? " << x << ' ' << v[0] << endl;
        cout.flush();
        cin >> op;
        if(op){
            cout << "? " << x << ' ' << v[1] << endl;
            cout.flush();
            cin >> op;
            if(op){
                cout << "! 2" << endl;
                cout.flush();
                return;
            }
            else{
                cout << "! 1" << endl;
                cout.flush();
                return;
            }
        }
        else{
            cout << "? " << y << ' ' << v[0] << endl;
            cout.flush();
            cin >> op;
            if(op){
                cout << "? " << y << ' ' << v[1] << endl;
                cout.flush();
                cin >> op;
                if(op){
                    cout << "! 2" << endl;
                    cout.flush();
                    return;
                }
                else{
                    cout << "! 1" << endl;
                    cout.flush();
                    return;
                }
            }
        }
    }
    cout << "! 1" << endl;
    cout.flush();
    return;
}

int main(){
    int t = 0;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
1
0
1
0
4
0
1
1
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
0
1
1
15
0
0
0
0
0
0
1
1
1
7
0
0
0
1
0
1
1
15
0
0
0
1
0
0
1
1
0
19
0
0
0
0
0
1
1
1
20
0
0
0
0
0
0
0
0
0
0
7
0
0
1
0
1
1
20
0
0
0
0
0
0
0
1
1
1
17
0
0
0
0
0
0
0
0
0
11
1
0
0
1
0
0
0
0
0

output:

? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 12 1
? 12 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 13 1
? 13 2
! 2
? 1 2
? 3 4
? 5 6
? 6 7
? 6 1
? 7 1
? 7 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 7 1
? 8 1
? 9 10
? 9 1
? 9 2
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 11 2
! 2
? 1 2
? 3...

result:

wrong answer Too many queries , n = 11 , now_q 10 (test case 10)