QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310200#6394. Turn on the LightPlentyOfPenalty#WA 1ms3644kbC++20421b2024-01-21 08:27:292024-01-21 08:27:29

Judging History

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

  • [2024-01-21 08:27:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-01-21 08:27:29]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

int query(int x)
{
	cout<<"? "<<x<<endl;
	int f;
	cin>>f;
	return f;
}
int main()
{
	int n;
	cin>>n;
	int l=1,r=n,pre=0;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		int g=query(l);
		if(g==pre)
		{
			r=l;break;
		}
		int f=query(mid);
		if(f==pre+2)l=mid+1;
		else if(f==pre)++l,r=mid-1;
		else{l=r=mid;break;}
	}
	cout<<"! "<<l<<endl;
	return 0;
}

详细

Test #1:

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

input:

3
1
2

output:

? 1
? 2
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

10
1
0
1
0

output:

? 1
? 6
? 2
? 4
! 3

result:

ok Correct position at 3

Test #3:

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

input:

9
1
2
3
2

output:

? 1
? 5
? 6
? 8
! 9

result:

wrong answer Wrong favorite light!