QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649692 | #8939. Permutation | 11d10xy | WA | 1ms | 3828kb | C++14 | 753b | 2024-10-18 08:59:10 | 2024-10-18 08:59:25 |
Judging History
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,int res){
if(l==r)return l;
int mid=l+r>>1;
if(!res)res=ask(l,r);
if(res<=mid){
if(l==mid)return calc(mid+1,r,0);
int x=ask(l,mid);
if(x==res)return calc(l,mid,res);
else return calc(mid+1,r,0);
}else{
if(mid+1==r)return calc(l,mid,0);
int x=ask(mid+1,r);
if(x==res)return calc(mid+1,r,res);
else return calc(mid+1,r,0);
}
}
void solve(){
scanf("%d",&n);
printf("! %d\n",calc(1,n,0)),fflush(stdout);
}
int main(){
int T;for(scanf("%d",&T);T--;)solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3828kb
input:
3 5 3 2 5 6 6 5 5 4
output:
? 1 5 ? 1 3 ? 4 5 ! 4 ? 1 6 ? 4 6 ? 4 6 ? 4 5 ! 6
result:
wrong answer Wrong prediction (test case 2)