QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607993#8939. PermutationzzlWA 0ms3736kbC++17719b2024-10-03 17:35:232024-10-03 17:35:23

Judging History

This is the latest submission verdict.

  • [2024-10-03 17:35:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3736kb
  • [2024-10-03 17:35:23]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,l,r;
int qu(int l,int r) {
    cout<<'?'<<' '<<l<<' '<<r<<endl;
    cout.flush();
    int tem;
    cin>>tem;
    return tem;
}
int work(int l,int r,int s) {
    if(l==r)return l;
    if(s==0)s=qu(l,r);
    if(l==r-1)return s==l?r:l;
    int up=ceil(0.6*(r-l));
    if(r-s>=s-l) {
        if(qu(l,r-up)==s)return work(l,r-up,s);
        else return work(r-up+1,r,0);
    }
    else {
        if(qu(l+up,r)==s)return work(l+up,r,s);
        else return work(l,l+up-1,0);
    }
}
signed main() {
    int t;
    cin>>t;
    while(t--) {
        cin>>n;
        n=work(1,n,0);
        cout<<'!'<<' '<<n<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3736kb

input:

3
5
3
1
3

output:

? 1 5
? 1 2
? 3 5
? 3 3

result:

wrong answer Integer 3 violates the range [4, 5] (test case 1)