QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607962 | #8939. Permutation | zzl | WA | 53ms | 3628kb | C++17 | 728b | 2024-10-03 17:22:11 | 2024-10-03 17:22:12 |
Judging History
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=round((double)(r-l)*0.6);
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: 3628kb
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: 0
Accepted
time: 53ms
memory: 3568kb
input:
10000 10 2 2 3 5 10 10 10 8 7 10 5 1 10 9 6 10 4 4 4 4 10 10 6 3 3 2 10 3 3 3 2 10 1 5 9 9 9 10 1 3 8 8 8 10 2 4 9 9 8 10 3 3 1 5 10 4 1 7 8 9 10 8 7 1 1 2 10 4 1 9 9 8 10 7 8 2 1 4 10 5 1 7 6 10 10 8 8 6 9 10 2 1 7 7 7 10 6 6 8 10 10 1 3 8 8 8 10 7 9 5 5 4 10 7 8 4 4 4 10 3 4 7 8 10 10 4 4 4 3 10 8...
output:
? 1 10 ? 1 5 ? 1 3 ? 4 5 ! 4 ? 1 10 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