QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#109379 | #6303. Inversion | wfycsw | WA | 851ms | 19240kb | C++14 | 1.4kb | 2023-05-28 19:56:11 | 2023-05-28 19:56:13 |
Judging History
answer
#include<bits/stdc++.h>
#define RI register int
#define err puts("asd")
#define ll long long
#define ull unsigned long long
#define LL __int128
#define mk make_pair
#define fl fflush(stdout)
//#define int long long
using namespace std;
inline ll read(){
ll s=0;register char c=getchar();bool f=0;
while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}
while(c>='0'&&c<='9') s=(s<<3)+(s<<1)+c-48,c=getchar();
return f?-s:s;
}
const int N=2e3+5;
int n,a[N],f[N],cnt;
int A[N][N];
inline int Q(int x,int y){
if(A[x][y]!=-1) return A[x][y];
if(++cnt>40000) exit(1);
cout<<"? "<<x<<' '<<y<<endl;fl;
RI z=read();
return A[x][y]=z;
}
inline void add(int x){while(x<=n) f[x]^=1,x+=x&-x;}
inline int ask(int x){RI ans=0;while(x) ans^=f[x],x^=x&-x;return ans;}
inline int get(int l,int r){
RI tmp=0;
for(RI i=r;i>=l;--i){
tmp^=ask(a[i]);
add(a[i]);
}
for(RI i=l;i<=r;++i) add(a[i]);
return tmp;
}
signed main(){
//freopen("1.in","r",stdin);
//freopen("1.out","w",stdout);
n=read();
memset(A,-1,sizeof A);
RI x,y,z,l,r,mid,ans;
for(RI i=1;i<=n;++i){
l=1;r=i-1;ans=0;
while(l<=r){
mid=l+r>>1;
if(Q(mid,i)^Q(mid+1,i)^get(mid+1,i-1)^get(mid,i-1)) r=mid-1;
else l=mid+1,ans=mid;
}
//cout<<"debug "<<ans<<endl;
for(RI j=1;j<i;++j)
if(a[j]>ans) ++a[j];
a[i]=ans+1;
}
cout<<"! ";
for(RI i=1;i<=n;++i) cout<<a[i]<<' ';fl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 19240kb
input:
3 0 0 0 1
output:
? 1 2 ? 2 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 851ms
memory: 19204kb
input:
1993 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 1 0 1 0 1 0 0 0 0 0 0 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0...
output:
? 1 2 ? 2 2 ? 1 3 ? 2 3 ? 3 3 ? 2 4 ? 3 4 ? 4 4 ? 2 5 ? 3 5 ? 1 5 ? 3 6 ? 4 6 ? 1 6 ? 2 6 ? 3 7 ? 4 7 ? 1 7 ? 2 7 ? 4 8 ? 5 8 ? 2 8 ? 3 8 ? 4 9 ? 5 9 ? 2 9 ? 3 9 ? 5 10 ? 6 10 ? 7 10 ? 8 10 ? 9 10 ? 5 11 ? 6 11 ? 8 11 ? 9 11 ? 10 11 ? 11 11 ? 6 12 ? 7 12 ? 3 12 ? 4 12 ? 5 12 ? 6 13 ? 7 13 ? 3 13 ? 4...
result:
wrong answer Wa.