QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#649680#8939. Permutation11d10xyWA 1ms3824kbC++14536b2024-10-18 08:51:442024-10-18 08:51:47

Judging History

This is the latest submission verdict.

  • [2024-10-18 08:51:47]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3824kb
  • [2024-10-18 08:51:44]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
int n;
inline int ask(int l,int r){
   printf("? %d %d\n",l,r);fflush(stdout);
   int x;scanf("%d",&x);return x;
}
int calc(int l,int r){
   if(l==r)return l;
   int mid=l+r>>1,x=calc(l,mid),y=calc(mid+1,r),res=ask(l,r);
   if(res==x)return y;
   if(res==y)return x;
   if(l<=res&&res<=mid)return x;
   else return y;
}
void solve(){
   scanf("%d",&n);
   printf("! %d\n",calc(1,n)),fflush(stdout);
}
int main(){
   int T;for(scanf("%d",&T);T--;)solve();
   return 0;
}

详细

Test #1:

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

input:

3
5
1
2
5
3
6
1
3
4
5

output:

? 1 2
? 1 3
? 4 5
? 1 5
! 4
? 1 2
? 1 3
? 4 5
? 4 6
? 1 6

result:

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