QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#19821#1807. Distribute the Barsconqueror_of_zky#AC ✓14ms8460kbC++201.4kb2022-02-11 16:33:592022-05-06 07:14:10

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:10]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:8460kb
  • [2022-02-11 16:33:59]
  • 提交

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=1;i<=x;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]*2-2);
	for(int i=1;i<=x;i++)
		v[i].push_back(l+x*2+p2[i]*2-2);
	for(int i=1;i<=x;i++)
		v[i].push_back(l+x*4+p3[i]*2-2);
	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: 0ms
memory: 6480kb

input:

4

output:

2
2 1 7
2 3 5

result:

ok OK (2 groups)

Test #2:

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

input:

2

output:

-1

result:

ok OK (impossible)

Test #3:

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

input:

3

output:

-1

result:

ok OK (impossible)

Test #4:

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

input:

1659

output:

553
3 1 2209 2767
3 3 2205 2769
3 5 2201 2771
3 7 2197 2773
3 9 2193 2775
3 11 2189 2777
3 13 2185 2779
3 15 2181 2781
3 17 2177 2783
3 19 2173 2785
3 21 2169 2787
3 23 2165 2789
3 25 2161 2791
3 27 2157 2793
3 29 2153 2795
3 31 2149 2797
3 33 2145 2799
3 35 2141 2801
3 37 2137 2803
3 39 2133 2805
3...

result:

ok OK (553 groups)

Test #5:

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

input:

8941

output:

-1

result:

ok OK (impossible)

Test #6:

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

input:

458

output:

229
2 1 915
2 3 913
2 5 911
2 7 909
2 9 907
2 11 905
2 13 903
2 15 901
2 17 899
2 19 897
2 21 895
2 23 893
2 25 891
2 27 889
2 29 887
2 31 885
2 33 883
2 35 881
2 37 879
2 39 877
2 41 875
2 43 873
2 45 871
2 47 869
2 49 867
2 51 865
2 53 863
2 55 861
2 57 859
2 59 857
2 61 855
2 63 853
2 65 851
2 67...

result:

ok OK (229 groups)

Test #7:

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

input:

5

output:

-1

result:

ok OK (impossible)

Test #8:

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

input:

9

output:

3
3 1 9 17
3 3 11 13
3 5 7 15

result:

ok OK (3 groups)

Test #9:

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

input:

25

output:

5
5 1 49 11 27 37
5 3 47 13 23 39
5 5 45 15 29 31
5 7 43 17 25 33
5 9 41 19 21 35

result:

ok OK (5 groups)

Test #10:

score: 0
Accepted
time: 5ms
memory: 5972kb

input:

143

output:

13
11 1 285 27 259 53 233 79 207 105 153 171
11 3 283 29 257 55 231 81 205 107 149 173
11 5 281 31 255 57 229 83 203 109 145 175
11 7 279 33 253 59 227 85 201 111 141 177
11 9 277 35 251 61 225 87 199 113 137 179
11 11 275 37 249 63 223 89 197 115 133 181
11 13 273 39 247 65 221 91 195 117 155 157
1...

result:

ok OK (13 groups)

Test #11:

score: 0
Accepted
time: 11ms
memory: 6364kb

input:

85849

output:

293
293 1 171697 587 171111 1173 170525 1759 169939 2345 169353 2931 168767 3517 168181 4103 167595 4689 167009 5275 166423 5861 165837 6447 165251 7033 164665 7619 164079 8205 163493 8791 162907 9377 162321 9963 161735 10549 161149 11135 160563 11721 159977 12307 159391 12893 158805 13479 158219 14...

result:

ok OK (293 groups)

Test #12:

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

input:

99991

output:

-1

result:

ok OK (impossible)

Test #13:

score: 0
Accepted
time: 13ms
memory: 6612kb

input:

99997

output:

5263
19 1 199993 10527 189467 21053 178941 31579 168415 42105 157889 52631 147363 63157 136837 73683 126311 84209 105257 110525
19 3 199991 10529 189465 21055 178939 31581 168413 42107 157887 52633 147361 63159 136835 73685 126309 84211 105253 110527
19 5 199989 10531 189463 21057 178937 31583 16841...

result:

ok OK (5263 groups)

Test #14:

score: 0
Accepted
time: 14ms
memory: 8460kb

input:

100000

output:

50000
2 1 199999
2 3 199997
2 5 199995
2 7 199993
2 9 199991
2 11 199989
2 13 199987
2 15 199985
2 17 199983
2 19 199981
2 21 199979
2 23 199977
2 25 199975
2 27 199973
2 29 199971
2 31 199969
2 33 199967
2 35 199965
2 37 199963
2 39 199961
2 41 199959
2 43 199957
2 45 199955
2 47 199953
2 49 199951...

result:

ok OK (50000 groups)

Test #15:

score: 0
Accepted
time: 8ms
memory: 6936kb

input:

28454

output:

14227
2 1 56907
2 3 56905
2 5 56903
2 7 56901
2 9 56899
2 11 56897
2 13 56895
2 15 56893
2 17 56891
2 19 56889
2 21 56887
2 23 56885
2 25 56883
2 27 56881
2 29 56879
2 31 56877
2 33 56875
2 35 56873
2 37 56871
2 39 56869
2 41 56867
2 43 56865
2 45 56863
2 47 56861
2 49 56859
2 51 56857
2 53 56855
2 ...

result:

ok OK (14227 groups)

Test #16:

score: 0
Accepted
time: 9ms
memory: 7684kb

input:

64338

output:

32169
2 1 128675
2 3 128673
2 5 128671
2 7 128669
2 9 128667
2 11 128665
2 13 128663
2 15 128661
2 17 128659
2 19 128657
2 21 128655
2 23 128653
2 25 128651
2 27 128649
2 29 128647
2 31 128645
2 33 128643
2 35 128641
2 37 128639
2 39 128637
2 41 128635
2 43 128633
2 45 128631
2 47 128629
2 49 128627...

result:

ok OK (32169 groups)

Test #17:

score: 0
Accepted
time: 9ms
memory: 7288kb

input:

88078

output:

44039
2 1 176155
2 3 176153
2 5 176151
2 7 176149
2 9 176147
2 11 176145
2 13 176143
2 15 176141
2 17 176139
2 19 176137
2 21 176135
2 23 176133
2 25 176131
2 27 176129
2 29 176127
2 31 176125
2 33 176123
2 35 176121
2 37 176119
2 39 176117
2 41 176115
2 43 176113
2 45 176111
2 47 176109
2 49 176107...

result:

ok OK (44039 groups)

Test #18:

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

input:

16831

output:

-1

result:

ok OK (impossible)

Test #19:

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

input:

10880

output:

5440
2 1 21759
2 3 21757
2 5 21755
2 7 21753
2 9 21751
2 11 21749
2 13 21747
2 15 21745
2 17 21743
2 19 21741
2 21 21739
2 23 21737
2 25 21735
2 27 21733
2 29 21731
2 31 21729
2 33 21727
2 35 21725
2 37 21723
2 39 21721
2 41 21719
2 43 21717
2 45 21715
2 47 21713
2 49 21711
2 51 21709
2 53 21707
2 5...

result:

ok OK (5440 groups)

Test #20:

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

input:

28979

output:

-1

result:

ok OK (impossible)

Test #21:

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

input:

20173

output:

-1

result:

ok OK (impossible)

Test #22:

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

input:

78401

output:

-1

result:

ok OK (impossible)

Test #23:

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

input:

52067

output:

-1

result:

ok OK (impossible)

Test #24:

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

input:

94727

output:

-1

result:

ok OK (impossible)

Test #25:

score: 0
Accepted
time: 7ms
memory: 6236kb

input:

35657

output:

197
181 1 71313 395 70919 789 70525 1183 70131 1577 69737 1971 69343 2365 68949 2759 68555 3153 68161 3547 67767 3941 67373 4335 66979 4729 66585 5123 66191 5517 65797 5911 65403 6305 65009 6699 64615 7093 64221 7487 63827 7881 63433 8275 63039 8669 62645 9063 62251 9457 61857 9851 61463 10245 61069...

result:

ok OK (197 groups)

Test #26:

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

input:

41449

output:

229
181 1 82897 459 82439 917 81981 1375 81523 1833 81065 2291 80607 2749 80149 3207 79691 3665 79233 4123 78775 4581 78317 5039 77859 5497 77401 5955 76943 6413 76485 6871 76027 7329 75569 7787 75111 8245 74653 8703 74195 9161 73737 9619 73279 10077 72821 10535 72363 10993 71905 11451 71447 11909 7...

result:

ok OK (229 groups)

Test #27:

score: 0
Accepted
time: 6ms
memory: 5960kb

input:

7367

output:

139
53 1 14733 279 14455 557 14177 835 13899 1113 13621 1391 13343 1669 13065 1947 12787 2225 12509 2503 12231 2781 11953 3059 11675 3337 11397 3615 11119 3893 10841 4171 10563 4449 10285 4727 10007 5005 9729 5283 9451 5561 9173 5839 8895 6117 8617 6395 8339 6673 8061 6951 7503 7647
53 3 14731 281 1...

result:

ok OK (139 groups)

Test #28:

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

input:

12191

output:

167
73 1 24381 335 24047 669 23713 1003 23379 1337 23045 1671 22711 2005 22377 2339 22043 2673 21709 3007 21375 3341 21041 3675 20707 4009 20373 4343 20039 4677 19705 5011 19371 5345 19037 5679 18703 6013 18369 6347 18035 6681 17701 7015 17367 7349 17033 7683 16699 8017 16365 8351 16031 8685 15697 9...

result:

ok OK (167 groups)

Test #29:

score: 0
Accepted
time: 8ms
memory: 6636kb

input:

43847

output:

269
163 1 87693 539 87155 1077 86617 1615 86079 2153 85541 2691 85003 3229 84465 3767 83927 4305 83389 4843 82851 5381 82313 5919 81775 6457 81237 6995 80699 7533 80161 8071 79623 8609 79085 9147 78547 9685 78009 10223 77471 10761 76933 11299 76395 11837 75857 12375 75319 12913 74781 13451 74243 139...

result:

ok OK (269 groups)

Test #30:

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

input:

20819

output:

191
109 1 41637 383 41255 765 40873 1147 40491 1529 40109 1911 39727 2293 39345 2675 38963 3057 38581 3439 38199 3821 37817 4203 37435 4585 37053 4967 36671 5349 36289 5731 35907 6113 35525 6495 35143 6877 34761 7259 34379 7641 33997 8023 33615 8405 33233 8787 32851 9169 32469 9551 32087 9933 31705 ...

result:

ok OK (191 groups)

Test #31:

score: 0
Accepted
time: 5ms
memory: 5904kb

input:

9943

output:

163
61 1 19885 327 19559 653 19233 979 18907 1305 18581 1631 18255 1957 17929 2283 17603 2609 17277 2935 16951 3261 16625 3587 16299 3913 15973 4239 15647 4565 15321 4891 14995 5217 14669 5543 14343 5869 14017 6195 13691 6521 13365 6847 13039 7173 12713 7499 12387 7825 12061 8151 11735 8477 11409 88...

result:

ok OK (163 groups)

Test #32:

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

input:

1369

output:

37
37 1 2737 75 2663 149 2589 223 2515 297 2441 371 2367 445 2293 519 2219 593 2145 667 2071 741 1997 815 1923 889 1849 963 1775 1037 1701 1111 1627 1185 1553 1259 1403 1445
37 3 2735 77 2661 151 2587 225 2513 299 2439 373 2365 447 2291 521 2217 595 2143 669 2069 743 1995 817 1921 891 1847 965 1773 ...

result:

ok OK (37 groups)

Test #33:

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

input:

6241

output:

79
79 1 12481 159 12323 317 12165 475 12007 633 11849 791 11691 949 11533 1107 11375 1265 11217 1423 11059 1581 10901 1739 10743 1897 10585 2055 10427 2213 10269 2371 10111 2529 9953 2687 9795 2845 9637 3003 9479 3161 9321 3319 9163 3477 9005 3635 8847 3793 8689 3951 8531 4109 8373 4267 8215 4425 80...

result:

ok OK (79 groups)

Test #34:

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

input:

841

output:

29
29 1 1681 59 1623 117 1565 175 1507 233 1449 291 1391 349 1333 407 1275 465 1217 523 1159 581 1101 639 1043 697 985 755 867 901
29 3 1679 61 1621 119 1563 177 1505 235 1447 293 1389 351 1331 409 1273 467 1215 525 1157 583 1099 641 1041 699 983 757 863 903
29 5 1677 63 1619 121 1561 179 1503 237 1...

result:

ok OK (29 groups)

Test #35:

score: 0
Accepted
time: 12ms
memory: 6816kb

input:

69169

output:

263
263 1 138337 527 137811 1053 137285 1579 136759 2105 136233 2631 135707 3157 135181 3683 134655 4209 134129 4735 133603 5261 133077 5787 132551 6313 132025 6839 131499 7365 130973 7891 130447 8417 129921 8943 129395 9469 128869 9995 128343 10521 127817 11047 127291 11573 126765 12099 126239 1262...

result:

ok OK (263 groups)

Test #36:

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

input:

121

output:

11
11 1 241 23 219 45 197 67 175 89 129 145
11 3 239 25 217 47 195 69 173 91 125 147
11 5 237 27 215 49 193 71 171 93 121 149
11 7 235 29 213 51 191 73 169 95 117 151
11 9 233 31 211 53 189 75 167 97 113 153
11 11 231 33 209 55 187 77 165 99 131 133
11 13 229 35 207 57 185 79 163 101 127 135
11 15 2...

result:

ok OK (11 groups)