QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528337#6394. Turn on the Lighthnust_100team#WA 1ms3704kbC++17535b2024-08-23 12:59:172024-08-23 12:59:17

Judging History

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

  • [2024-08-23 12:59:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-08-23 12:59:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#define int long long
int query(int x){
	cout<<"? "<<x<<endl;
	cout.flush();
	int num;
	cin>>num;
	return num;
}
void solve(){
	int n;cin>>n;
	int cnt = query(1);
	if(cnt==0){
		cout<<"! "<<1<<"\n";
		return ;
	}
	int l = 1,r=n;
	while(l<r){
		int mid=(l+r+1)/2;
		if(query(mid)>=cnt) l =mid;
		else r=mid-1;
		
	}
	cout<<"! "<<l<<"\n";
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3684kb

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5
! 5

result:

wrong answer Wrong favorite light!