QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687486#9432. PermutationWilliamHuAC ✓265ms4040kbC++175.1kb2024-10-29 19:17:432024-10-29 19:17:43

Judging History

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

  • [2024-10-29 19:17:43]
  • 评测
  • 测评结果:AC
  • 用时:265ms
  • 内存:4040kb
  • [2024-10-29 19:17:43]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
using namespace std;
int read()
{
	int x = 0, f = 1;
	char c = getchar();
	while(c != EOF and !isdigit(c))
	{
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c))
	{
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
struct node{
	int l, r, p;
	vector<int>id;
};
vector<pair<int, int> >l;
vector<node>tmp;
vector<node>s;
int ans[10010], n;
int query(int l1, int r1, int v1, int l2, int r2, int v2)
{
	//cout<<l1<<' '<<r1<<' '<<v1<<endl;
	//cout<<l2<<' '<<r2<<' '<<v2<<endl;
	fflush(stdout);
	cout<<"0 ";
	for(int i = 1;i <= r1;i ++)cout<<v1<<' ';
	for(int i = l2;i <= n;i ++)cout<<v2<<' ';
	cout<<'\n';
	fflush(stdout);
	return read();
}
void print()
{
	for(int i = 0;i< s.size();i ++)
	{
		cout<<s[i].l<<' '<<s[i].r<<' '<<s[i].p<<endl;
		for(int j = 0;j < s[i].id.size();j ++)
		{
			cout<<s[i].id[j]<<' ';
		}
		cout<<endl;
	}
}
signed main()
{
	n = read();
	int las = 1;
	node lyw;
	lyw.l = 1;
	lyw.r = n;
	lyw.p = 1;
	for(int i = 1;i<= n;i ++)lyw.id.push_back(i);
	s.push_back(lyw);
	while(s.size() != n)
	{
		tmp.clear();
		for(int i = 0;i < s.size();i ++)
		{
			int len = s[i].id.size(), qwq = 0;
			if(i != 0)las = s[0].id[0];
			else if(s.size() > 1)las = qwq = s[1].id[0];
			l.clear();
			int left = s[i].l, right = s[i].r, mid;
			//cout<<left<<' '<<right<<endl;
			if(left == right)
			{
				tmp.push_back(s[i]);
				continue;
			}
			mid = left + right >> 1;
			node le, ri;
			le.l = s[i].l;
			le.r = mid;
			le.p = 2 * s[i].p;
			ri.l = mid+1;
			ri.r = s[i].r;
			ri.p = 2 * s[i].p + 1;
			
			
			for(int j = 0;j+1 < len;j += 2)
			{
				int x = query(left, mid, s[i].id[j], mid+1, right, s[i].id[j+1]);
				if(x == 0)
				{
					le.id.push_back(s[i].id[j+1]);
					ri.id.push_back(s[i].id[j]);
					qwq = s[i].id[j];
				}
				else if(x == 2)
				{
					le.id.push_back(s[i].id[j]);
					ri.id.push_back(s[i].id[j+1]);
					qwq = s[i].id[j + 1];
				}
				else{
					l.push_back(make_pair(s[i].id[j], s[i].id[j + 1]));
				}
			}
			if((right - left + 1) & 1)
			{
				int x;
				if(qwq)
				{
					x = query(left, mid, s[i].id[len - 1], mid+1, right, qwq);
					if(x == 1)
					{
						ri.id.push_back(s[i].id[len - 1]);
					}
					else if(x == 2)
					{
						le.id.push_back(s[i].id[len - 1]);
					}
				}
				else{
					x = query(left, mid, s[i].id[len - 1], mid+1, right, las);
					if(x == 0)
					{
						ri.id.push_back(s[i].id[len - 1]);
					}
					else if(x == 2)
					{
						le.id.push_back(s[i].id[len - 1]);
					}
				}
			}	
			len = l.size();
			for(int j = 0;j+1 < len;j += 2)
			{
				int x = query(left, mid, l[j].first, mid+1, right, l[j+1].first);
				if(x == 0)
				{
					le.id.push_back(l[j+1].first);
					le.id.push_back(l[j+1].second);
					ri.id.push_back(l[j].first);
					ri.id.push_back(l[j].second);
				}
				else if(x == 2)
				{
					le.id.push_back(l[j].first);
					le.id.push_back(l[j].second);
					ri.id.push_back(l[j+1].first);
					ri.id.push_back(l[j+1].second);
				}
				else{
					int x;
					if(qwq)
					{
						x = query(left, mid, l[j].first, mid+1, right, qwq);
						if(x == 1)
						{
							ri.id.push_back(l[j].first);
							ri.id.push_back(l[j].second);
							ri.id.push_back(l[j+1].first);
							ri.id.push_back(l[j+1].second);
						}
						else if(x == 2)
						{
							le.id.push_back(l[j].first);
							le.id.push_back(l[j].second);
							le.id.push_back(l[j+1].first);
							le.id.push_back(l[j+1].second);
						}
					}
					else{
						x = query(left, mid, l[j].first, mid+1, right, las);
						if(x == 0)
						{
							ri.id.push_back(l[j].first);
							ri.id.push_back(l[j].second);
							ri.id.push_back(l[j+1].first);
							ri.id.push_back(l[j+1].second);
						}
						else
						{
							le.id.push_back(l[j].first);
							le.id.push_back(l[j].second);
							le.id.push_back(l[j+1].first);
							le.id.push_back(l[j+1].second);
						}
					}
				}
			}
			if(len&1)
			{
				int x;
				if(qwq)
				{
					x = query(left, mid, l[len - 1].first, mid+1, right, qwq);
					if(x == 1)
					{
						ri.id.push_back(l[len - 1].first);
						ri.id.push_back(l[len - 1].second);
					}
					else if(x == 2)
					{
						le.id.push_back(l[len - 1].first);
						le.id.push_back(l[len - 1].second);
					}
				}
				else{
					x = query(left, mid, l[len - 1].first, mid+1, right, las);
					if(x == 0)
					{
						ri.id.push_back(l[len - 1].first);
						ri.id.push_back(l[len - 1].second);
					}
					else
					{
						le.id.push_back(l[len - 1].first);
						le.id.push_back(l[len - 1].second);
					}
				}
			}
			
			//for(int i = 0;i < le.id.size();i ++)cout<<le.id[i]<<' ';
			//for(int i = 0;i < ri.id.size();i ++)cout<<ri.id[i]<<' ';
			//cout<<endl;
			tmp.push_back(le);
			tmp.push_back(ri);
		}
		s.clear();
		for(int i = 0;i < tmp.size();i ++)s.push_back(tmp[i]);
		//print();
	}
	cout<<1<<' ';
	for(int i = 0;i < s.size();i ++)ans[s[i].l] = s[i].id[0];
	for(int i = 1;i <= n;i ++)cout<<ans[i]<<' ';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3588kb

input:

5
0
1
1
2
0
2
2
2

output:

0 1 1 1 2 2 
0 3 3 3 4 4 
0 5 5 5 1 1 
0 3 3 3 1 1 
0 2 2 3 3 3 
0 4 4 2 2 2 
0 1 1 1 1 5 
0 3 4 4 4 4 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 265ms
memory: 3816kb

input:

1000
2
0
0
1
2
2
0
2
1
1
1
1
1
0
1
0
0
1
2
1
1
1
2
0
2
2
0
1
2
1
1
0
1
1
1
0
1
1
0
1
2
0
1
1
0
2
2
1
1
2
1
1
2
1
2
1
0
0
0
1
1
0
1
2
1
0
1
1
0
0
1
1
2
2
1
1
1
0
0
0
2
0
2
2
2
1
1
1
1
1
0
1
1
1
2
1
2
2
1
1
1
0
1
0
0
0
2
1
0
2
1
1
2
2
0
1
1
1
0
2
1
2
1
2
0
1
1
2
2
0
2
0
1
0
1
1
1
1
1
1
0
1
0
2
2
2
1
1...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Accepted

Test #3:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3
2
2
0

output:

0 1 1 2 
0 3 3 2 
0 1 3 3 
1 3 1 2 

result:

ok Accepted

Test #6:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

4
1
1
0
2
0

output:

0 1 1 2 2 
0 3 3 4 4 
0 1 1 3 3 
0 3 4 4 4 
0 1 1 1 2 
1 3 4 2 1 

result:

ok Accepted

Test #7:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

6
0
1
1
2
0
2
2
2
2
2

output:

0 1 1 1 2 2 2 
0 3 3 3 4 4 4 
0 5 5 5 6 6 6 
0 3 3 3 5 5 5 
0 2 2 3 3 3 3 
0 4 4 2 2 2 2 
0 1 1 1 1 1 5 
0 6 6 6 6 6 5 
0 3 4 4 4 4 4 
0 1 1 1 1 6 6 
1 3 4 2 1 6 5 

result:

ok Accepted

Test #8:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

7
1
2
1
2
2
1
1
2
0
2
2
0
0

output:

0 1 1 1 1 2 2 2 
0 3 3 3 3 4 4 4 
0 5 5 5 5 6 6 6 
0 7 7 7 7 4 4 4 
0 1 1 1 1 5 5 5 
0 3 3 7 7 7 7 7 
0 1 1 2 2 2 2 2 
0 3 3 1 1 1 1 1 
0 4 4 4 4 4 4 5 
0 6 6 6 6 6 6 4 
0 3 7 7 7 7 7 7 
0 1 1 1 2 2 2 2 
0 5 5 5 5 5 6 6 
1 3 7 2 1 6 5 4 

result:

ok Accepted

Test #9:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

8
1
2
1
2
2
1
1
2
1
1
0
2
0
0
2

output:

0 1 1 1 1 2 2 2 2 
0 3 3 3 3 4 4 4 4 
0 5 5 5 5 6 6 6 6 
0 7 7 7 7 8 8 8 8 
0 1 1 1 1 5 5 5 5 
0 3 3 7 7 7 7 7 7 
0 1 1 2 2 2 2 2 2 
0 3 3 1 1 1 1 1 1 
0 4 4 4 4 4 4 8 8 
0 5 5 5 5 5 5 6 6 
0 4 4 4 4 4 4 5 5 
0 3 7 7 7 7 7 7 7 
0 1 1 1 2 2 2 2 2 
0 5 5 5 5 5 6 6 6 
0 4 4 4 4 4 4 4 8 
1 3 7 2 1 6 5 4 8 

result:

ok Accepted

Test #10:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

9
1
2
1
2
2
2
1
1
2
2
2
2
0
2
0
0
2
2

output:

0 1 1 1 1 1 2 2 2 2 
0 3 3 3 3 3 4 4 4 4 
0 5 5 5 5 5 6 6 6 6 
0 7 7 7 7 7 8 8 8 8 
0 9 9 9 9 9 8 8 8 8 
0 1 1 1 1 1 5 5 5 5 
0 3 3 3 7 7 7 7 7 7 
0 9 9 9 1 1 1 1 1 1 
0 2 2 2 4 4 4 4 4 4 
0 3 3 3 9 9 9 9 9 9 
0 4 4 4 4 4 4 4 8 8 
0 5 5 5 5 5 5 5 6 6 
0 2 2 3 3 3 3 3 3 3 
0 7 7 2 2 2 2 2 2 2 
0 9 9 ...

result:

ok Accepted

Test #11:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

10
2
2
1
2
1
0
0
2
2
0
1
1
2
1
1
2
2
2
2
0
2
0

output:

0 1 1 1 1 1 2 2 2 2 2 
0 3 3 3 3 3 4 4 4 4 4 
0 5 5 5 5 5 6 6 6 6 6 
0 7 7 7 7 7 8 8 8 8 8 
0 9 9 9 9 9 10 10 10 10 10 
0 5 5 5 5 5 9 9 9 9 9 
0 1 1 1 3 3 3 3 3 3 3 
0 7 7 7 9 9 9 9 9 9 9 
0 10 10 10 9 9 9 9 9 9 9 
0 2 2 2 2 2 2 2 2 4 4 
0 8 8 8 8 8 8 8 8 5 5 
0 6 6 6 6 6 6 6 6 2 2 
0 8 8 8 8 8 8 8 ...

result:

ok Accepted

Test #12:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

11
2
2
2
2
1
1
2
0
0
0
0
2
2
1
1
2
2
2
2
2
2
2
2
2

output:

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

result:

ok Accepted

Test #13:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

12
2
2
2
2
1
1
2
0
0
0
0
1
1
0
1
1
2
2
2
1
0
1
2
2
2
2
2
2

output:

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

result:

ok Accepted

Test #14:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

13
2
0
2
2
1
1
2
2
2
0
2
2
2
1
1
0
0
2
0
2
0
2
0
2
0
0
0
2
0

output:

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

result:

ok Accepted

Test #15:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

14
2
0
1
2
1
1
1
0
0
2
2
1
1
2
2
2
0
2
0
0
0
2
1
1
0
2
2
0
0
2
2
2
0

output:

0 1 1 1 1 1 1 1 2 2 2 2 2 2 2 
0 3 3 3 3 3 3 3 4 4 4 4 4 4 4 
0 5 5 5 5 5 5 5 6 6 6 6 6 6 6 
0 7 7 7 7 7 7 7 8 8 8 8 8 8 8 
0 9 9 9 9 9 9 9 10 10 10 10 10 10 10 
0 11 11 11 11 11 11 11 12 12 12 12 12 12 12 
0 13 13 13 13 13 13 13 14 14 14 14 14 14 14 
0 5 5 5 5 5 5 5 9 9 9 9 9 9 9 
0 11 11 11 11 11 ...

result:

ok Accepted

Test #16:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

15
2
0
1
2
1
2
2
2
0
2
2
2
0
2
1
1
2
2
0
2
1
1
0
2
0
2
2
0
0
0
2
0
0
2

output:

0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 
0 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 
0 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 
0 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 
0 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 
0 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 
0 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 
0 15 15 15 15 15 15 15 15 14 14 ...

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 235ms
memory: 3796kb

input:

975
2
0
0
1
2
2
0
2
1
1
1
1
1
0
1
0
0
1
2
1
1
1
2
0
2
2
0
1
2
1
1
0
1
1
1
0
1
1
0
1
2
0
1
1
0
2
2
1
1
2
1
1
2
1
2
1
0
0
0
1
1
0
1
2
1
0
1
1
0
0
1
1
2
2
2
1
0
0
0
0
2
0
2
2
2
1
1
1
1
1
0
1
1
1
2
1
2
2
1
1
1
0
1
0
0
0
2
1
0
2
1
1
2
2
0
1
1
1
0
2
1
2
1
2
0
0
1
2
2
0
2
0
1
0
1
1
1
0
1
1
0
1
0
2
2
2
1
1
...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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
1
1
1
0
1
0
2
2
2
1
1
...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 231ms
memory: 4004kb

input:

992
2
0
0
1
2
2
0
2
1
1
1
1
1
0
1
0
0
1
2
1
1
1
2
0
2
2
0
1
2
1
1
0
1
1
1
0
1
1
0
1
2
0
1
1
0
2
2
1
1
2
1
1
2
1
2
1
0
0
0
1
1
0
1
2
1
0
1
1
0
0
1
1
2
2
1
1
0
0
0
0
2
0
2
2
2
1
1
1
1
1
0
1
1
1
2
1
2
2
1
1
1
0
1
0
0
0
2
1
0
2
1
1
2
2
0
1
1
1
0
2
1
2
1
2
0
1
1
2
2
0
2
0
1
0
1
1
1
1
1
1
0
1
0
2
2
2
1
1
...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 237ms
memory: 3804kb

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