QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613174#6394. Turn on the LightliaoyingyuTL 0ms0kbC++20820b2024-10-05 13:41:082024-10-05 13:41:13

Judging History

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

  • [2024-10-05 13:41:13]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-05 13:41:08]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
const int mod=1e9+7;
const int N=200000+10;
using namespace std;//初始化
typedef pair <int, int> pi;
int n;
int digui(int l,int r,int zhi){
	int mid=(l+r)/2;
	cout<<"? "<<mid<<endl;
	int now,noww;
	cin>>now;
	if(now==zhi){
		return mid;
	}
	cout<<"? "<<l<<endl;
	cin>>noww;
	if(now==noww){
		return l;
		
	}
	else{
		if(noww>now){
			digui(mid+1,r,noww);
		}
		else if(noww<now){
			digui(l+1,mid,noww);
		}
	}
}
void solve(){
	cin>>n;
	int nnn=digui(1,n,0);
	cout<<"! "<<nnn<<endl;
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(12);//小数保留位数
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3
1
2
2
2
2

output:

? 2
? 1
? 3
? 2
? 2

result: