QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666311 | #8939. Permutation | xuzhihaodedie | WA | 1ms | 3708kb | C++20 | 972b | 2024-10-22 17:45:26 | 2024-10-22 17:45:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define lson 2*p
#define rson 2*p+1
#define x first
#define y second
// #define endl "\n"
const int N=2e5+10;
const int mod=1e9+7;
vector<int> v;
int last=-1;
int ans=0;
int ask(int l,int r) {
cout<<"? "<<l<<" "<<r<<endl;
int k;
cin>>k;
return k;
}
void solve(int l,int r) {
if(ans) return ;
// if(l>=r) return ;
if(l==r) {
ans=l;
return ;
}
if(l==r-1) {
ans=(l^r^ask(l,r));
return ;
}
int res=(r-l+1)/3;
if(last!=-1) {
int p=ask(l,l+res-1);
if(last==p) solve(l,l+res);
else solve(l+res,r),last=-1;
} else {
int k=ask(l,r);
int p=ask(l,l+res);
if(k==p) solve(l,l+res),last=p;
else solve(l+res+1,r);
}
}
void solve() {
int n;
cin>>n;
solve(1,n);
cout<<"! "<<ans<<endl;
}
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int T=1;
cin>>T;
while(T--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3708kb
input:
3 5 3 1 3 3
output:
? 1 5 ? 1 2 ? 3 5 ? 3 4 ? 3 4
result:
wrong answer Too many queries , n = 5 , now_q 5 (test case 1)