QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97693#6319. Parallel Processing (Easy)whatever#WA 3ms3808kbC++146.0kb2023-04-17 22:41:372023-04-17 22:41:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-17 22:41:39]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3808kb
  • [2023-04-17 22:41:37]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
vector<vector<vector<int> > > ans;
void op(vector<vector<int> > v)
{
/*	bitset<2005> A,B,C,D;
	A=(s[v[0][1]]^s[v[0][2]]);
	B=(s[v[1][1]]^s[v[1][2]]);
	C=(s[v[2][1]]^s[v[2][2]]);
	D=(s[v[3][1]]^s[v[3][2]]);
	s[v[0][0]]=A;
	s[v[1][0]]=B;
	s[v[2][0]]=C;
	s[v[3][0]]=D;*/
	ans.push_back(v);
}
int N;

vector<vector<vector<int> > > solve2(int n)
{
	if(n>=33&&n!=38||n==23)
	{
		auto qaq=solve2(n-15);
		vector<vector<vector<int> > > qwq=qaq;
		for(int i=0;i<qwq.size();i++)
		{
			for(int j=0;j<qwq[i].size();j++)
			{
				for(int k=0;k<qwq[i][j].size();k++)
					qwq[i][j][k]+=15;
			}
		}
		qwq.insert(qwq.begin(),{{2,1,2},{4,3,4},{6,5,6},{8,7,8}});
		qwq.insert(qwq.begin(),{{4,2,4},{8,6,8},{12,11,12},{10,9,10}});
		qwq.insert(qwq.begin(),{{6,4,6},{8,4,8},{14,13,14},{16,15,16}});
		qwq.insert(qwq.begin(),{{3,2,3},{5,4,5},{10,8,10},{14,12,14}});
		qwq.insert(qwq.begin(),{{7,6,7},{9,8,9},{12,10,12},{14,10,14}});
		qwq.insert(qwq.begin(),{{11,10,11},{13,12,13},{15,14,15},{16,14,16}});
		return qwq;
	}
	ans.clear();
//	bitset<2005> s[2005];
	int fa[2005]={},cnt[2005]={};
	for(int i=1;i<=n;i++) fa[i]=i-1,cnt[i-1]=1;
	for(int i=1;i<=n;i++)
	{
		if(n%10==6&&i<=6)
		{
			
			vector<vector<int> > v;
			bitset<2005> qwq;
			qwq.reset();
			int C=4;
			for(int j=1;j<=n;j++)
			{
				if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]]&&fa[fa[j]]==0)
				{
					v.push_back({j,fa[j],j});
					--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
					--C;
				}
				if(!C) break;
			}
			for(int j=1;j<=n;j++)
			{
				if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
				{
					v.push_back({j,fa[j],j});
					--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
					--C;
				}
				if(!C) break;
			}
			for(int j=1;j<=n;j++)
			{
				if(fa[j]!=0&&!qwq[fa[j]]&&fa[fa[j]]==0)
				{
					v.push_back({j,fa[j],j});
					--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
					--C;
				}
				if(!C) break;
			}
			for(int j=1;j<=n;j++)
			{
				if(fa[j]!=0&&!qwq[fa[j]])
				{
					v.push_back({j,fa[j],j});
					--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
					--C;
				}
				if(!C) break;
			}
			if(v.size()==0) break;
			while(v.size()<4) v.insert(v.begin(),{v.back()[0],2000,2000});
			op(v);
			continue;
		}
		vector<vector<int> > v;
		bitset<2005> qwq;
		qwq.reset();
		int C=4;
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]]&&fa[fa[j]]==0)
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&!qwq[fa[j]]&&fa[fa[j]]==0)
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		if(v.size()==0) break;
		while(v.size()<4) v.insert(v.begin(),{v.back()[0],2000,2000});
		op(v);
	}
	return ans;
}
vector<vector<vector<int> > > solve1(int n)
{
	ans.clear();
//	bitset<2005> s[2005];
	int fa[2005]={},cnt[2005]={};
	for(int i=1;i<=n;i++) fa[i]=i-1,cnt[i-1]=1;
	for(int i=1;i<=n;i++)
	{
		vector<vector<int> > v;
		bitset<2005> qwq;
		qwq.reset();
		int C=4;
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]]&&fa[fa[j]]==0)
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&!qwq[fa[j]]&&fa[fa[j]]==0)
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		if(v.size()==0) break;
		while(v.size()<4) v.insert(v.begin(),{v.back()[0],2000,2000});
		op(v);
	}
	return ans;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
//	for(int i=1;i<=n;i++) s[i][i]=1;
//	for(int i=1;i<=n;i++) fa[i]=i-1,cnt[i-1]=1;
/*	for(int i=1;i<=n;i++)
	{
		vector<vector<int> > v;
		bitset<2005> qwq;
		qwq.reset();
		int C=4;
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&cnt[j]&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&fa[fa[j]]==0&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]];
				--C;
			}
			if(!C) break;
		}
		for(int j=1;j<=n;j++)
		{
			if(fa[j]!=0&&!qwq[fa[j]])
			{
				v.push_back({j,fa[j],j});
				--cnt[fa[j]],++cnt[fa[fa[j]]],fa[j]=fa[fa[j]],qwq[j]=1;
				--C;
			}
			if(!C) break;
		}
		if(v.size()==0) break;
		while(v.size()<4) v.push_back({2,1,2});
		op(v);
	}*/
	vector<vector<vector<int> > > qwq;
	for(int i=0;i<=10000;i++) qwq.push_back({{}});
	for(int i=n;i<=n+4;i++)
	{
		vector<vector<vector<int> > > xx=solve2(i);
		if(xx.size()<qwq.size()) qwq=xx;
		xx=solve2(i);
		if(xx.size()<qwq.size()) qwq=xx;
	}
	ans=qwq;
//	assert(((n-1)*2+4)/5==ans.size());
	cout << ans.size() << "\n";
	for(auto t:ans)
	{
		for(auto y:t)
		{
			for(auto x:y) cout << min(n,x) << " ";
			cout << "\n";
		}
	}
/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cout << s[i][j];
		}
		cout << "\n";
	}*/
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2

output:

1
2 2 2 
2 2 2 
2 2 2 
2 1 2 

result:

ok AC

Test #2:

score: 0
Accepted
time: 2ms
memory: 3808kb

input:

4

output:

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

result:

ok AC

Test #3:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

3

output:

2
2 3 3 
2 3 3 
2 3 3 
2 1 2 
3 3 3 
3 3 3 
3 3 3 
3 2 3 

result:

ok AC

Test #4:

score: 0
Accepted
time: 2ms
memory: 3792kb

input:

5

output:

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

result:

ok AC

Test #5:

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

input:

6

output:

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

result:

ok AC

Test #6:

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

input:

7

output:

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

result:

ok AC

Test #7:

score: 0
Accepted
time: 2ms
memory: 3784kb

input:

8

output:

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

result:

ok AC

Test #8:

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

input:

9

output:

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

result:

ok AC

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3728kb

input:

10

output:

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

result:

wrong answer A[10] is not (1, …, 10)