QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#364329 | #8239. Mysterious Tree | zhouyuheng | TL | 0ms | 0kb | C++14 | 1.6kb | 2024-03-24 13:46:23 | 2024-03-24 13:46:24 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;
template <typename T> inline T gcd(const T a,const T b){if(b==0)return a;return gcd(b,a%b);}
template <typename T> inline void read(T&x)
{
char cu=getchar();x=0;bool fla=0;
while(!isdigit(cu)){if(cu=='-')fla=1;cu=getchar();}
while(isdigit(cu))x=x*10+cu-'0',cu=getchar();
if(fla)x=-x;
}
template <typename T> void printe(const T x)
{
if(x>=10)printe(x/10);
putchar(x%10+'0');
}
template <typename T> inline void print(const T x)
{
if(x<0)putchar('-'),printe(-x);
else printe(x);
}
const ll mod=998244353;
inline ll Pow(ll x,ll y)
{
ll res=1;//x%=mod
for(;y;y>>=1,x=x*x%mod)if(y&1)res=(res*x)%mod;
return res;
}
ll T,n,ans;
int main(){
read(T);
while(T--){
read(n);
int ans=1,res;
for(int i=1;i<=n;i+=2){
if(i==n){
int res1,res2,res3;
printf("? %d %d\n",i,1);
scanf("%d",&res1);
printf("? %d %d\n",i,2);
scanf("%d",&res2);
printf("? %d %d\n",i,3);
scanf("%d",&res3);
if(res1&&res2&&res3)ans=2;
break;
}
printf("? %d %d\n",i,i+1);
scanf("%d",&res);
if(res){
int res1,res2,res3;
printf("? %d %d\n",i,i==1?3:1);
scanf("%d",&res1);
if(res1){
printf("? %d %d\n",i,i==1?4:2);
scanf("%d",&res2);
if(res2)ans=2;
}
else{
printf("? %d %d\n",i+1,i==1?3:1);
scanf("%d",&res2);
printf("? %d %d\n",i+1,i==1?4:2);
scanf("%d",&res3);
if(res2&&res3)ans=2;
}
break;
}
}
printf("! %d\n",ans);
}
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
2 4