QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694320#8239. Mysterious TreeYuu#WA 1ms3596kbC++231.2kb2024-10-31 17:42:252024-10-31 17:42:26

Judging History

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

  • [2024-10-31 17:42:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2024-10-31 17:42:25]
  • 提交

answer

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

//  The 2023 ICPC Asia Hangzhou Regional Contest

int ask(int u, int v){
    std::cout<<"? "<<u<<" "<<v<<endl;
    int x; std::cin>>x;
    return x;
}

void sol(){
    int n; std::cin>>n;
    int u = -1, v = -1;

    for(int i = 1;i<n;i+=2){
        if(ask(i, i + 1)){
            u = i, v = i + 1;
            break;
        }
    }

    if(u == -1 && v == -1){
        std::cout<<"! 2"<<endl;
        return ;
    }

    if(u == 1){
        if(ask(u, n - 1)){
            std::cout<<(ask(u, n)?"! 2":"! 1")<<endl;
        }else{
            if(ask(v, n - 1) && ask(v, n)){
                std::cout<<"! 2"<<endl;
            }else{
                std::cout<<"! 1"<<endl;
            }
        }
    }else{
        if(ask(u, 1)){
            std::cout<<(ask(u, 2)?"! 2":"! 1")<<endl;
        }else{
            if(ask(v, 1) && ask(v, 2)){
                std::cout<<"! 2"<<endl;
            }else{
                std::cout<<"! 1"<<endl;
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
    int t = 1; std::cin>>t;
    while(t--) sol();
    return 0;
}

詳細信息

Test #1:

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

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: 0ms
memory: 3580kb

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
15
0
0
0
1
0
0
19
0
0
0
0
0
1
1
1
20
0
0
0
0
0
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
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 7 1
? 8 1
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 11 1
? 11 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 15 ...

result:

wrong answer Wrong prediction (test case 6)