QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#154466 | #6303. Inversion | qzez# | WA | 57ms | 19700kb | C++14 | 1.4kb | 2023-08-31 18:14:59 | 2023-08-31 18:15:00 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e3+5,M=N*40+5,K=(1<<25)+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,A[N],f[N][N],B[N];
int calc(int x,int y){
if(x>y) return 0;
if(~f[x][y]) return f[x][y];
cout<<"? "<<x<<' '<<y<<endl;
cin>>f[x][y];return f[x][y];
}
int qry(int x,int y){return (calc(x,y)-calc(x+1,y)-calc(x,y-1)+calc(x+1,y-1)+2)&1;}
void insert(int x){
int l=0,r=x,mid;
while(l+1<r){
mid=l+r>>1;
if(qry(B[mid],x)) r=mid;else l=mid;
}
A[x]=l+1;
for(int i=1;i<x;i++) if(A[i]>l) A[i]++;
for(int i=1;i<=x;i++) B[A[i]]=i;
for(int i=1;i<x;i++) f[i][x]=(f[i-1][x]+f[i][x-1]-f[i-1][x-1]+(A[i]>A[x])+2)&1;
}
void Solve(){
int i,j;scanf("%d",&n);
Me(f,-1);
for(i=1;i<=n;i++) insert(i);
cout<<"! ";
for(i=1;i<=n;i++) cout<<A[i]<<' ';cout<<endl;
}
int main(){
int t;
// scanf("%d",&t);
t=1;
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 19700kb
input:
3 0 0 0 0 1
output:
? 1 2 ? 2 2 ? 1 1 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=5
Test #2:
score: -100
Wrong Answer
time: 57ms
memory: 19688kb
input:
1993 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 1 1...
output:
? 1 2 ? 2 2 ? 1 1 ? 1 3 ? 2 3 ? 3 3 ? 2 4 ? 3 4 ? 4 4 ? 2 5 ? 3 5 ? 1 5 ? 2 6 ? 3 6 ? 5 6 ? 6 6 ? 5 5 ? 1 6 ? 1 7 ? 2 7 ? 5 7 ? 6 7 ? 1 8 ? 2 8 ? 3 8 ? 4 8 ? 1 9 ? 2 9 ? 8 9 ? 9 9 ? 8 8 ? 3 9 ? 2 10 ? 3 10 ? 8 10 ? 9 10 ? 10 10 ? 2 11 ? 3 11 ? 8 11 ? 9 11 ? 10 11 ? 11 11 ? 10 12 ? 11 12 ? 6 12 ? 7 1...
result:
wrong answer Wa.