QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881943#8939. PermutationsugarWA 0ms3456kbC++14815b2025-02-04 19:58:182025-02-04 19:58:19

Judging History

This is the latest submission verdict.

  • [2025-02-04 19:58:19]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3456kb
  • [2025-02-04 19:58:18]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
mt19937 myrand(time(0));
int n;
void solve()
{
	cin>>n;
	int l=1,r=n,la=0;
	cout<<'?'<<' '<<1<<' '<<n<<endl;
	cin>>la;
	while(l!=r)
	{
//		printf("sure %d-%d\n",l,r);
		if(r==l+1)
		{
			if(l==la)l++;
			else r--;
			break;
		}
		int mid=(l+r)>>1,mi=0;
		if(mi<la)mi=l+(r-l)*3/8;
		else mi=l+(r-l)*5/8;
		int num=(mi<la);
		if(num)cout<<'?'<<' '<<mi+1<<' '<<r<<endl;
		else cout<<'?'<<' '<<l<<' '<<mi<<endl;
		int pos=0;
		cin>>pos;
		if(la==pos)
		{
			if(num) l=mi+1;
			else r=mi;
		}
		else
		{
			if(num)cout<<'?'<<' '<<l<<' '<<mi<<endl;
			else cout<<'?'<<' '<<mi+1<<' '<<r<<endl;
			cin>>la;
			if(num)r=mi;
			else l=mi+1;
		}
	}
	cout<<'!'<<' '<<l<<endl;
}
int main()
{
	int tt=0;
	cin>>tt;
	while(tt--)solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3456kb

input:

3
5
3
3

output:

? 1 5
? 3 5
? 3 3

result:

wrong answer Integer 3 violates the range [4, 5] (test case 1)