QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302883#6303. InversionZYF_B#WA 71ms19396kbC++141.2kb2024-01-11 14:42:512024-01-11 14:42:51

Judging History

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

  • [2024-01-11 14:42:51]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:19396kb
  • [2024-01-11 14:42:51]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

inline int read()
{
	int f=1,x=0;char s=getchar();
	while(s<'0'||s>'9')
	{
		if(s=='-') f=-1;
		s=getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=x*10+s-48;
		s=getchar();
	}
	return f*x;
}

const int N=2005;
int n;
int mp[N][N],v[N],p[N],suf[N];
int query(int l,int r)
{
	if(l>=r) return 0; 
	if(mp[l][r]!=-1) return mp[l][r];
	cout<<"? "<<l<<" "<<r<<endl;
	cout.flush();
	int x;
	cin>>x;
	return mp[l][r]=x;
}

int ask(int x,int y)
{
	return query(x,y)^query(x+1,y-1)^query(x,y-1)^query(x+1,y);
}

int main()
{
	memset(mp,-1,sizeof(mp));
	cin>>n;
	v[1]=1;
	for(int i=2;i<=n;i++)
	{
		int l=1,r=i-1,pos=i;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(ask(v[mid],i)) pos=mid,r=mid-1;
			else l=mid+1; 
		}
		for(int j=i-1;j>=pos;j--) v[j+1]=v[j];
		v[pos]=i;
		for(int j=1;j<=i;j++) p[v[j]]=j;
		mp[i][i]=suf[i]=0;
//		for(int j=i-1;j>=1;j--) suf[j]=suf[j+1]^(p[i]<p[j]),mp[j][i]=mp[j][i-1]^suf[j];
	}
	cout<<"! ";
	for(int i=1;i<=n;i++) p[v[i]]=i;
	for(int i=1;i<=n;i++) cout<<p[i]<<" ";
	cout.flush();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 19316kb

input:

3
0
0
1

output:

? 1 2
? 1 3
? 2 3
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 71ms
memory: 19396kb

input:

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

output:

? 1 2
? 1 3
? 2 3
? 2 4
? 3 4
? 2 5
? 3 5
? 1 5
? 1 4
? 2 6
? 3 6
? 5 6
? 1 6
? 1 7
? 2 7
? 5 7
? 6 7
? 1 8
? 2 8
? 3 8
? 4 7
? 3 7
? 4 8
? 1 9
? 2 9
? 8 9
? 3 9
? 9 10
? 5 10
? 6 9
? 5 9
? 6 10
? 7 10
? 7 9
? 8 10
? 1 11
? 2 10
? 1 10
? 2 11
? 8 11
? 9 11
? 10 11
? 11 12
? 8 12
? 9 12
? 10 12
? 2 1...

result:

wrong output format Unexpected end of file - int32 expected