QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#230864#6394. Turn on the LightLLCS#WA 1ms3824kbC++141.5kb2023-10-28 21:23:042023-10-28 21:23:04

Judging History

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

  • [2023-10-28 21:23:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2023-10-28 21:23:04]
  • 提交

answer

/*
@Date    : 2023-10-28 21:18:55
@Author  : Adscn ([email protected])
@Link    : http://www.cnblogs.com/LLCSBlog
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define IL inline
#define RG register
#define gi geti<int>()
#define gl geti<ll>()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
template<typename T>IL bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>IL bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>
IL T geti()
{
	RG T xi=0;
	RG char ch=gc;
	bool f=0;
	while(!isdigit(ch))ch=='-'?f=1:f,ch=gc;
	while(isdigit(ch))xi=xi*10+ch-48,ch=gc;
	return f?-xi:xi;
}
template<typename T>
IL void pi(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)pi(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
/*
IL unsigned int LOG2(unsigned int x)
{
	unsigned int ret;
	__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));
	return ret;
}
*/
int query(int x){
	printf("? %d\n",x);
	fflush(stdout);
	return gi;
}
void answer(int x){
	printf("! %d\n",x);
	fflush(stdout);
	exit(0);
}
int main(void)
{
	#ifndef ONLINE_JUDGE
//	File("");
	#endif
	int n=gi;
	int res=query(1);
	if(!res)answer(1);
	int l=2,r=n;
	while(l<=r){
		int mid=(l+r)/2;
		int res1=query(mid);
		if(res1==res)answer(mid);
		if(res1<res)r=mid-1;
		else l=mid+1;
		res=res1;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3808kb

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5

result:

wrong answer format  Unexpected end of file - token expected