QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106192#6394. Turn on the Light4_ss#WA 3ms3444kbC++17798b2023-05-16 20:30:282023-05-16 20:30:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-16 20:30:31]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3444kb
  • [2023-05-16 20:30:28]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long

using namespace std;
const int m=41;
const int N=1e6+10;
bool light[N];

signed main()
{	
	int n;
	cin>>n;
	int num[m];
	int sb[n+1];
	for(int i=0;i<n+1;i++) sb[i]=0;
	sb[1]=(1+n)/2;
	for(int i=1;i<m;i++)
	{
		cout<<"? "<<sb[i]<<endl;
		scanf("%d",&num[i]);
		
		if(num[1]==0)
		{
			cout<<"! "<<sb[i]<<endl;
			break;
		}
		else if(num[1]==1)//右 
			sb[i+1]=(sb[i]+n)/2+1;
		else if(num[1]==-1)//左 
			sb[i+1]=(sb[i]+1)/2-1;
		
		if(i>=2)
		{
			if(num[i]==num[i-1])
			{
				cout<<"! "<<sb[i]<<endl;
				break;
			}
			else if(num[i]==num[i-1]+1)
			{
				sb[i+1]=(sb[i]+n)/2+1;
			}
			else if(num[i]==num[i-1]-1)
			{
				sb[i+1]=(sb[i]+sb[i-1])/2-1;
			}
		}
		cout.flush();
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3444kb

input:

3
1

output:

? 2
? 0

result:

wrong answer Integer parameter [name=x] equals to 0, violates the range [1, 3]