QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#350144 | #8239. Mysterious Tree | mc020207# | WA | 1ms | 3668kb | C++17 | 1.6kb | 2024-03-10 14:40:21 | 2024-03-10 14:40:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = (a);i <= (b);i++)
#define Rof(i, a, b) for(int i = (a);i >= (b);i--)
int ask(int x,int y){
cout<<"? "<<x<<" "<<y<<endl;
int t;cin>>t;
return t;
}
int n;
int st[10],top;
int getn(){
For(i,1,n){
bool f=0;
For(j,1,top){
if (i==st[j]){
f=1;
break;
}
}
if (!f) return i;
}
}
void Main(){
top=0;
cin>>n;
bool f=0;
int x,y;
for (int i=1;i<=n;i+=2){
if (ask(i,i%n+1)){
x=i,y=i%n+1;
f=1;
break;
}
}
// if (n%2){
// if(ask(1,n)){
// x=1,y=n;
// f=1;
// }
// }
if (!f){
cout<<"! "<<1<<endl;
return ;
}
st[++top]=x,st[++top]=y;
int z=getn();
cout<<z<<endl;
if (ask(x,z)){
st[++top]=z;
int w=getn();
if (ask(x,w)){
cout<<"! "<<2<<endl;
return ;
}else{
cout<<"! "<<1<<endl;
return ;
}
}else swap(x,y);
if (ask(x,z)){
st[++top]=z;
int w=getn();
if (ask(x,w)){
cout<<"! "<<2<<endl;
return ;
}else{
cout<<"! "<<1<<endl;
return ;
}
}else{
cout<<"! "<<1<<endl;
return ;
}
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T;cin>>T;
while (T--) Main();
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3668kb
input:
2 4 1
output:
? 1 2 3 ? 1 3
result:
wrong answer Token parameter [name=type] equals to "3", doesn't correspond to pattern "?|!" (test case 1)