QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105593#6303. InversionLYC_music#WA 495ms3580kbC++141.8kb2023-05-14 14:44:342023-05-14 14:45:05

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-14 14:45:05]
  • 评测
  • 测评结果:WA
  • 用时:495ms
  • 内存:3580kb
  • [2023-05-14 14:44:34]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define int ll
#define N 2005
using namespace std;
int n,a[N],p[N];
poly g;
mt19937_64 rnd(time(0));
int ansp[N];
int bl[N][N],vis[N][N];
int lim;
int tot=0;
int np[N];
namespace BIT
{
	int tr[N];
	void upd(int x,int y)
	{
		while (x<N)
		{
			tr[x]^=y;
			x+=x&-x;
		}
	}
	int qry(int x)
	{
		int res=0;
		while (x)
		{
			res^=tr[x];
			x-=x&-x;
		}
		return res;
	}
}
using namespace BIT;
int query(int l,int r)
{
	if (l>r) return 0;
	int res=0;
	if (r<lim)
	{
		for (auto u:g)
			np[u]=0;
		res=(n%2);
		for (auto u:g)
		{
			if (np[u]) continue;
			int now=u;
			while (!np[now])
			{
				np[now]=1;
				now=p[now];
			}
			res^=1;
		}
		return res;
	}
	cout<<"? "<<l<<" "<<r<<endl;
	cin>>res;
	return res;
}
void BellaKira()
{
	cin>>n;
	g.push_back(1);
	for (int i=2;i<=n;i++)
	{
		lim=i;
		int l=0,r=g.size()-1;
		int x=0;
		while (l<=r)
		{
			int mid=l+(r-l)/2;
			if ((query(g[mid],i)-query(g[mid]+1,i)-query(g[mid],i-1)+query(g[mid]+1,i-1))%2==0)
			{
				x=mid+1;
				l=mid+1;
			} else r=mid-1;
		}		
		poly nxt;
		for (int j=0;j<x;j++)	nxt.push_back(g[j]);
		nxt.push_back(i);
		for (int j=x;j<g.size();j++)
			nxt.push_back(g[j]);
		nxt.swap(g);
		for (int j=0;j<g.size();j++)
			p[g[j]]=j+1;
	}
	for (int i=0;i<n;i++)
		p[g[i]]=i+1;
	cout<<"! ";
	for (int i=1;i<=n;i++) cout<<p[i]<<" ";
	cout<<endl;
	// cout<<tot<<endl;
	// for (int i=1;i<=n;i++) assert(ansp[i]==p[i]);
}
signed main()
{
	// IOS;
	// cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3512kb

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: 495ms
memory: 3580kb

input:

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

output:

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

result:

wrong answer Wa.