QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560211#8239. Mysterious Treeshabi666#WA 1ms3632kbC++143.1kb2024-09-12 14:20:382024-09-12 14:20:38

Judging History

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

  • [2024-09-12 14:20:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3632kb
  • [2024-09-12 14:20:38]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int N=1e6+10;

int a[N];
int n,m;

void solve(){
    cin>>n;
    if(n%2)
    {
       int flag=1;
       for(int i=1;i<n;i+=2)
       {
          cout<<"? "<<i<<' '<<i+1<<endl;
          int x; cin>>x;
          if(x==1)
          {
             int val=i-1;
             if(val==0) val=i+2;
             cout<<"? "<<i<<' '<<val<<endl;
             int temp; cin>>temp;
             if(temp==1)
             {
                if(val==i+2) val++;
                else val--;
                cout<<"? "<<i<<' '<<val<<endl;
                int t;cin>>t;
                if(t)
                {
                    cout<<"! 2\n";
                    return ;
                } else
                {
                    cout<<"! 1\n";
                    return ;
                }
             }

             cout<<"? "<<i+1<<' '<<val<<endl;
             cin>>temp;
             if(temp==1)
             {
                if(val==i+2) val++;
                else val--;
                cout<<"? "<<i+1<<' '<<val<<endl;
                int t;cin>>t;
                if(t)
                {
                    cout<<"! 2\n";
                    return ;
                } else
                {
                    cout<<"! 1\n";
                    return ;
                }
             }else cout<<"! 1\n";
             return ;
          }
       }
       for(int i=1;i<=3;i++)
       {
           cout<<"? "<<n<<i<<' ';
           int temp; cin>>temp;
           if(temp==0) flag=0;
       }
       if(flag) cout<<"! 2\n";
       else cout<<"! 1\n";
    } else
    {
       for(int i=1;i<n;i+=2)
       {
          cout<<"? "<<i<<' '<<i+1<<endl;
          int x; cin>>x;
          if(x==1)
          {
             int val=i-1;
             if(val==0) val=i+2;
             cout<<"? "<<i<<' '<<val<<endl;
             int temp; cin>>temp;
             if(temp==1)
             {
                if(val==i+2) val++;
                else val--;
                cout<<"? "<<i<<' '<<val<<endl;
                int t;cin>>t;
                if(t)
                {
                    cout<<"! 2\n";
                    return ;
                } else
                {
                    cout<<"! 1\n";
                    return ;
                }
             }

             cout<<"? "<<i+1<<' '<<val<<endl;
             cin>>temp;
             if(temp==1)
             {
                if(val==i+2) val++;
                else val--;
                cout<<"? "<<i+1<<' '<<val<<endl;
                int t;cin>>t;
                if(t)
                {
                    cout<<"! 2\n";
                    return ;
                } else
                {
                    cout<<"! 1\n";
                    return ;
                }
             }else cout<<"! 1\n";
             return ;
          }
       }
       cout<<"! 1\n";
    }
return ;
}

signed main(){
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T=1; cin>>T;
    while(T--)
    {
      solve();
    }
return 0;
}

详细

Test #1:

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

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 2
? 3 1
! 2

result:

ok Correct (2 test cases)

Test #2:

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

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

output:

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

result:

wrong answer Integer 71 violates the range [1, 7] (test case 3)