QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#541030#8939. Permutationucup-team4508#TL 0ms0kbC++23575b2024-08-31 18:25:532024-08-31 18:25:53

Judging History

This is the latest submission verdict.

  • [2024-08-31 18:25:53]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-08-31 18:25:53]
  • Submitted

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(x+1,r);
    else return solve(l,x-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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
5
3
3
5

output:

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

result: