QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310199#6394. Turn on the LightPlentyOfPenalty#WA 0ms3632kbC++20419b2024-01-21 08:25:132024-01-21 08:25:13

Judging History

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

  • [2024-01-21 08:25:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-01-21 08:25:13]
  • 提交

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;
		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: 0ms
memory: 3632kb

input:

3
1
2

output:

? 1
? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4

output:

? 1
? 5
? 6
? 8
! 8

result:

wrong answer Wrong answer, more than 1 possible light!