QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109376#6303. InversionwfycswWA 942ms3356kbC++141.3kb2023-05-28 19:41:082023-05-28 19:41:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-28 19:41:09]
  • 评测
  • 测评结果:WA
  • 用时:942ms
  • 内存:3356kb
  • [2023-05-28 19:41:08]
  • 提交

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];

inline int Q(int x,int y){
	cout<<"? "<<x<<' '<<y<<endl;fl;
	RI z=read();
	return 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();
	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;
		}
		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: 2ms
memory: 3352kb

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: 942ms
memory: 3356kb

input:

1993
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
1
0
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
0
0
0
0
1
1
0
0
1...

output:

? 1 2
? 2 2
? 1 3
? 2 3
? 2 3
? 3 3
? 2 4
? 3 4
? 3 4
? 4 4
? 2 5
? 3 5
? 1 5
? 2 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
? 3 8
? 4 8
? 4 9
? 5 9
? 2 9
? 3 9
? 3 9
? 4 9
? 5 10
? 6 10
? 7 10
? 8 10
? 8 10
? 9 10
? 5 11
? 6 11
? 8 11
? 9 11
? 9 11
? 10 11
? 10 11
? 1...

result:

wrong answer Wa.