QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#858096#8939. PermutationhujinliangCompile Error//C++141.1kb2025-01-16 14:04:212025-01-16 14:05:00

Judging History

This is the latest submission verdict.

  • [2025-01-16 14:05:00]
  • Judged
  • [2025-01-16 14:04:21]
  • Submitted

answer

/*胡金梁*/
#include<bits/stdc++.h>
using namespace std;
#define __MY_TEST__ 0
inline int read()
{
	int f=1,re=0;
	char ch=getchar();
	while(!isdigit(ch)){ if(ch=='-') f=-1; ch=getchar();}
	while( isdigit(ch)) re=(re<<3)+(re<<1)+(ch^'0'),ch=getchar();
	return re*f;
}
int query(int l,int r)
{
	cout<<"? "<<l<<" "<<r<<endl;
	return read();
}
int dvd(int l,int r)
{
	if(r-l<10) return (r-l)*2/3;
	else return (r-l)*3/5;
}
void work(int ii)
{
	int n=read();
	int l=1,r=n,k=query(l,r);
	while(r-l>1)
	{
		if(k<(l+r)/2)
		{
			int pmid=l+dvd(l,r);
			if(k==query(l,pmid)) r=pmid;
			else
			{
				l=pmid+1;
				if(l!=r) k=query(l,r);
			}
		}
		else
		{
			int pmid=r-dvd(l,r);
			if(k==query(pmid,r)) l=pmid;
			else
			{
				r=pmid-1;
				if(l!=r) k=query(l,r);
			}
		}
	}
	if(l==r)
	{
		cout<<"! "<<l<<endl;
	}
	else
	{
		cout<<"! "<<(l==k?r:l)<<endl;
	}
}
signed main()
{
#if __MY_TEST__
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=read();
	while(t--) work(i);
}


详细

answer.code: In function ‘int main()’:
answer.code:68:25: error: ‘i’ was not declared in this scope
   68 |         while(t--) work(i);
      |                         ^