QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613287#6394. Turn on the LightliaoyingyuWA 1ms3636kbC++17849b2024-10-05 13:52:222024-10-05 13:52:24

Judging History

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

  • [2024-10-05 13:52:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2024-10-05 13:52:22]
  • 提交

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,anss;
void digui(int l,int r,int zhi){
	int mid=(l+r)/2;
	cout<<"? "<<mid<<endl;
	int now,noww;
	cin>>now;
	if(now==zhi){
		anss=mid;
		return ;
	}
	cout<<"? "<<l<<endl;
	cin>>noww;
	if(now==noww){
		anss=l;
		return ;
		
	}
	else{
		if(noww>now){
			digui(mid+1,r,noww);
		}
		else if(noww<now){
			digui(l+1,mid,noww);
		}
	}
	return;
}
void solve(){
	cin>>n;
	digui(1,n,0);
	cout<<"! "<<anss<<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: 100
Accepted
time: 1ms
memory: 3632kb

input:

3
1
2
2

output:

? 2
? 1
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
5

output:

? 5
? 1
? 8
? 6
? 9
? 9
! 9

result:

wrong answer Wrong favorite light!