QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#606612#8939. Permutationliguo#WA 1ms3972kbC++20706b2024-10-03 11:00:112024-10-03 11:00:12

Judging History

This is the latest submission verdict.

  • [2024-10-03 11:00:12]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3972kb
  • [2024-10-03 11:00:11]
  • Submitted

answer

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3972kb

input:

3
5
3
2
3
3

output:

? 1 5
? 1 3
? 3 5
? 3 4
? 3 4

result:

wrong answer Too many queries , n = 5 , now_q 5 (test case 1)