QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#298052 | #6303. Inversion | PlentyOfPenalty# | WA | 1ms | 3596kb | C++20 | 1004b | 2024-01-05 16:43:23 | 2024-01-05 16:43:23 |
Judging History
answer
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
using namespace std;
const int N=2e3+9;
int n,p[N+10],pos[N+10],q[N+10][N+10];
int cnt=0;
int Que(int l,int r){
if(l>=r)return 0;
assert((++cnt)<=40000);
cout<<"? "<<l<<" "<<r<<"\n";
cout<<flush;
int ret;
cin>>ret;
return ret;
}
bool Check(int x,int y){
int a=Que(x,y),b=Que(x+1,y);
return a^b^q[x][y-1]^q[x+1][y-1];
}
int l,r,mid,fl;
int main(){
#ifndef ONLINE_JUDGE
//freopen(".in","r",stdin);
#endif
cin.tie(0)->sync_with_stdio(0);
cin>>n;
p[1]=1,pos[1]=1,q[1][1]=0;
for(int i=2;i<=n;++i){
l=0,r=i-1;
while(l<r){
mid=(l+r+1>>1);
if(Check(pos[mid],i))r=mid-1;
else l=mid;
}
cout<<"l="<<l<<"\n";
for(int j=i-1;j>l;--j)++p[pos[j]],pos[j+1]=pos[j];
p[pos[l+1]=i]=l+1;
fl=0;
for(int j=i-1;j>=1;--j)fl^=(p[j]>p[i]),q[j][i]=q[j][i-1]^fl;
//for(int j=1;j<=i;++j)cout<<p[j]<<" \n"[j==i];cout<<flush;
}
cout<<"! ";
for(int i=1;i<=n;++i)cout<<p[i]<<" ";
cout<<flush;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3596kb
input:
3 0
output:
? 1 2 l=1 ? 1 3
result:
wrong output format Unexpected end of file - int32 expected