QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607973#8939. PermutationzzlWA 1ms3716kbC++17713b2024-10-03 17:27:052024-10-03 17:27:07

Judging History

This is the latest submission verdict.

  • [2024-10-03 17:27:07]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3716kb
  • [2024-10-03 17:27:05]
  • 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=(r-l)*0.7;
    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: 100
Accepted
time: 1ms
memory: 3716kb

input:

3
5
3
2
5
6
6
5
3
3
4
3
3

output:

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

result:

ok Correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3644kb

input:

10000
10
2
2
1
3
10
10
7
3
1
5

output:

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

result:

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