QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364329#8239. Mysterious TreezhouyuhengTL 0ms0kbC++141.6kb2024-03-24 13:46:232024-03-24 13:46:24

Judging History

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

  • [2024-03-24 13:46:24]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-24 13:46:23]
  • 提交

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

output:


result: