QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858130 | #8939. Permutation | Le0Chan | WA | 0ms | 3584kb | C++14 | 1.1kb | 2025-01-16 14:23:22 | 2025-01-16 14:23:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int inf=0x3f3f3f3f;
const ll lnf=1e18;
int n,as;
int qry(int l,int r){
if(l==r) return l;
cout<<"? "<<l<<' '<<r<<endl;
cin>>l;return l;
}
void sol(int l,int r,int p){
if(l+1==r){
if(p==l) as=r;
else as=l;
return;
}
if(l==r){as=l;return;}
int len=(r-l+1)/3,mid,op;
if(p<=l+len*2-1) mid=l+len*2-1,op=0;
else mid=r-len*2,op=1;
int p2=(op?qry(mid+1,r):qry(l,mid));
if(p2==p) (op?sol(mid+1,r,p):sol(l,mid,qry(l,mid)));
else (op?sol(l,mid,qry(l,mid)):sol(mid+1,r,p));
}
void sv(){
cin>>n;
sol(1,n,qry(1,n));
cout<<"! "<<as<<endl;
}
int main(){
int _T;cin>>_T;
while(_T--){
sv();
}
return 0;
}
}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
return Le0::main();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
3 5 3 5 2 1
output:
? 1 5 ? 4 5 ? 1 3 ? 1 2 ! 3
result:
wrong answer Wrong prediction (test case 1)