QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#751680 | #6303. Inversion | chenyitaoooo | WA | 1ms | 3788kb | C++23 | 831b | 2024-11-15 20:07:06 | 2024-11-15 20:07:07 |
Judging History
answer
#include<bits/stdc++.h>
#define Ri register int
using namespace std;
const int N=2005;
int a[N],F[N][N],b[N],n;
void ff(){
fflush(stdout);
}
int qy(int l,int r){
int x,y;
printf("?%d %d\n",l,r);
ff();
scanf("%d",&x);
if(l==r-1) return x;
printf("?%d %d\n",l+1,r);
ff();
scanf("%d",&y);
return x^y;
}
int main(){
scanf("%d",&n);
a[1]=1;
for(Ri i=2; i<=n; ++i){
for(Ri j=1; j<i; ++j){
b[a[j]]=j;
}
int l=1,r=i-1,an=i;
while(l<=r){
int mid=(l+r)>>1;
if(qy(b[mid],i)==1) r=mid-1,an=mid;
else l=mid+1;
}
// printf(":%d %d:\n",i,an);
for(Ri j=1; j<i; ++j){
if(a[j]>=an) a[j]++;
}
a[i]=an;
for(Ri j=i-1; j>=1; --j){
F[j][i]=F[j+1][i]^F[j][i-1]^F[j+1][i-1]^(a[j]>a[i]);
}
}
printf("!");
for(Ri i=1; i<=n; ++i) printf("%d ",a[i]);
ff();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3788kb
input:
3
output:
?1 2
result:
wrong output format Unexpected end of file - int32 expected