QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606623#8939. Permutationliguo#WA 0ms3864kbC++20709b2024-10-03 11:03:212024-10-03 11:03:23

Judging History

This is the latest submission verdict.

  • [2024-10-03 11:03:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3864kb
  • [2024-10-03 11:03:21]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
void solve(){
	int n;scanf("%d",&n);
	int l=1,r=n,sl;
	printf("? %d %d\n",l,r);
	fflush(stdout);
	scanf("%d",&sl);
	while(l<r){
//		printf("**");
		if(l+1==r){
			printf("! %d\n",l+r-sl);
			fflush(stdout);
			return;
		}
		int fl=0;
		int mid=l+(r-l)/2;
		if(l<=sl&&sl<=mid){
			printf("? %d %d\n",l,mid);
			fflush(stdout);
			int res;scanf("%d",&res);
			if(res==sl)
				r=mid;
			else
				l=mid,sl=res;
		}
		else{
			printf("? %d %d\n",mid,r);
			fflush(stdout);
			int res;scanf("%d",&res);
			if(res==sl)
				l=mid;
			else
				r=mid,sl=res;
		}
	}
}
int main(){
	int t;scanf("%d",&t);
	while(t--){
		solve();
	}
}

詳細信息

Test #1:

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

input:

3
5
3
2
5

output:

? 1 5
? 1 3
? 4 5
! 2

result:

wrong answer Wrong prediction (test case 1)