QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417544#6394. Turn on the LightLCJWA 1ms3588kbC++14633b2024-05-22 19:39:222024-05-22 19:39:23

Judging History

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

  • [2024-05-22 19:39:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-05-22 19:39:22]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,m,k,q,ans;
int ask(int x){
	cout<<"? "<<x<<endl;
	//cout.flush();
	int res;
	cin>>res;
	return res;
}
void solve(){
	cin>>n;
	k=0;
	for(int i=1;i<=1;i++){
		int kk=ask(i);
		if(k==kk){
			cout<<"! "<<i<<endl;
			return;
		}
		k=kk;
	}
	k=1;
	int l=2,r=n;
	while(l<=r){
		int mid=(l+r)/2;
		ans=ask(mid);
		if(ans==k){
			cout<<"! "<<mid<<endl;
			return;
		}
		if(k<ans){
			l=mid+1;
		}
		else{
			r=mid-1;
		}
		k=ans;
	}
	
}
signed main(){
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5

result:

wrong answer format  Unexpected end of file - token expected