QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#19820#1807. Distribute the Barsconqueror_of_zky#WA 4ms6932kbC++201.4kb2022-02-11 16:30:412022-05-06 07:14:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 07:14:06]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:6932kb
  • [2022-02-11 16:30:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
inline bool check(int n)
{
	for(int i=2;i*i<=n;i++)
		if(n%i==0) return 0;
	return 1;
}
vector <int> v[100005];
int p1[100005],p2[100005],p3[100005];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if(check(n))
	{
		cout << "-1";
		return 0;
	}
	if(n%2==0)
	{
		int x=n/2,qwq=-1;
		for(int i=1;i<=x;i++)
			v[i].push_back(qwq+=2);
		for(int i=x;i>=1;i--)
			v[i].push_back(qwq+=2);
		cout << x << "\n";
		for(int i=1;i<=x;i++)
		{
			cout << v[i].size();
			for(auto t:v[i]) cout << " " << t;
			cout << "\n";
		}
		return 0;
	}
	int x=0;
	for(int i=3;i<=n;i++)
	{
		if(n%i==0)
		{
			x=i;
			break;
		}
	}
	int y=x;
	x=n/x;
	int l=1,r=n+n-1;
	while(y>3)
	{
		y-=2;
		for(int i=1;i<=x;i++) v[i].push_back(l),l+=2;
		for(int i=x;i>=1;i--) v[i].push_back(r),r-=2;
	}
	for(int i=1;i<=x;i++) p1[i]=i;
	int qwq=1;
	for(int i=1;i<=x;i++)
	{
		p2[i]=qwq;
		qwq+=2;
		if(qwq>x) qwq-=x;
	}
	reverse(p2+1,p2+x+1);
	int s=(x+1)/2*3;
	for(int i=1;i<=x;i++)
		p3[i]=s-p1[i]-p2[i];
	for(int i=1;i<=x;i++)
		v[i].push_back(l+p1[i]-1);
	for(int i=1;i<=x;i++)
		v[i].push_back(l+x+p2[i]-1);
	for(int i=1;i<=x;i++)
		v[i].push_back(l+x+x+p3[i]-1);
	cout << x << "\n";
	for(int i=1;i<=x;i++)
	{
		int s=0;
		for(auto t:v[i]) s+=t;
		cout << v[i].size();
		for(auto t:v[i]) cout << " " << t;
		cout << "\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4

output:

2
2 1 7
2 3 5

result:

ok OK (2 groups)

Test #2:

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

input:

2

output:

-1

result:

ok OK (impossible)

Test #3:

score: 0
Accepted
time: 4ms
memory: 6304kb

input:

3

output:

-1

result:

ok OK (impossible)

Test #4:

score: -100
Wrong Answer
time: 4ms
memory: 6932kb

input:

1659

output:

553
3 1 1105 1384
3 2 1103 1385
3 3 1101 1386
3 4 1099 1387
3 5 1097 1388
3 6 1095 1389
3 7 1093 1390
3 8 1091 1391
3 9 1089 1392
3 10 1087 1393
3 11 1085 1394
3 12 1083 1395
3 13 1081 1396
3 14 1079 1397
3 15 1077 1398
3 16 1075 1399
3 17 1073 1400
3 18 1071 1401
3 19 1069 1402
3 20 1067 1403
3 21 ...

result:

wrong answer Even numbers not allowed