QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#541044 | #8939. Permutation | ucup-team4508# | TL | 0ms | 0kb | C++23 | 575b | 2024-08-31 18:29:41 | 2024-08-31 18:29:42 |
Judging History
answer
#include<iostream>
#include<algorithm>
int query(int l,int r){
std::cout<<"? "<<l<<" "<<r<<std::endl;
int res;
std::cin>>res;
return res;
}
int solve(int l,int r){
if(l==r)return l;
int t=query(l,r),x=query(t,r);
if(x==t)return solve(t+1,r);
else return solve(l,t-1);
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin>>t;
while(t--){
int n;
std::cin>>n;
int res=solve(1,n);
std::cout<<"! "<<res<<std::endl;
}
return 0;
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
3 5 3 3 5
output:
? 1 5 ? 3 5 ? 4 5 ? 5 5