QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138364#6394. Turn on the LightSchi2oidWA 1ms3460kbC++14915b2023-08-11 16:37:292023-08-11 16:37:30

Judging History

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

  • [2023-08-11 16:37:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3460kb
  • [2023-08-11 16:37:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int ask(int x){
	int ret;
	cout<<"? x"<<endl;
	cin>>ret;
	return ret;
}
int id[2][2000005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) id[0][i]=i;
	bool op=0;
	int bef=0;
	while(n>4){
		int p1=n/4,p2=n-n/4;
		int x=ask(p1);
		if(x==bef){
			cout<<"! p1";
			return 0;
		}
		 int y=ask(p2);
		 if(y==x){
		 	cout<<"! p2";
		 	return 0;
		 }
		 int delta=y-bef;
		 op^=1;
		 if(delta==0){
		 	n=p2-p1;
		 	int cnt=0;
		 	for(int i=p1+1;i<=p2;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 }
		 else{
		 	n=n-p2+p1-1;
		 	int cnt=0;
		 	for(int i=1;i<p1;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 	for(int i=p2+1;i<=n;i++){
		 		id[op][++cnt]=id[op^1][i];
		 	}
		 }
		 bef=y;
	}
	for(int i=1;i<=n;i++){
		int x=ask(i);
		if(x==bef){
			cout<<"! "<<id[op][i];
			return 0;
		}
		bef=x;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3460kb

input:

3

output:

? x

result:

wrong answer format  Expected integer, but "x" found