QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61694 | #1807. Distribute the Bars | AlienCollapsar | AC ✓ | 15ms | 6604kb | C++14 | 1.2kb | 2022-11-14 16:19:27 | 2022-11-14 16:19:28 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
const int Maxn=1e5+5;
int pri[Maxn],tot;
bool vis[Maxn];
void getPrime(int n){
for(int i=2;i<=n;++i){
if(!vis[i])pri[++tot]=i;
for(int j=1;j<=tot&&i*pri[j]<=n;++j){
vis[i*pri[j]]=1;
if(i%pri[j]==0)break;
}
}
}
vector<int>ans[Maxn];
int main(){
int n;cin>>n;
getPrime(n);
if(!vis[n]){cout<<-1<<'\n';return 0;}
if(n&1){
int a,b;
for(int i=1;i<=tot;++i)
if(n%pri[i]==0){a=pri[i],b=n/pri[i];break;}
int m=a*(b-a);
for(int i=1,j=m,k=0;i<j;++i,--j,(++k)%=a){
ans[k].emplace_back((i<<1)-1);
ans[k].emplace_back((j<<1)-1);
}
int st=0;
for(int i=m+1;i<=n;i+=a,(++st)%=a)
for(int j=0;j<a;++j)
ans[(st+j)%a].emplace_back((i+j<<1)-1);
cout<<a<<'\n';
for(int i=0;i<a;++i){
cout<<ans[i].size()<<' ';
for(int x:ans[i])cout<<x<<' ';cout<<'\n';
}
}else{
cout<<(n>>1)<<'\n';
for(int i=1,j=n;i<j;++i,--j)
cout<<2<<' '<<(i<<1)-1<<' '<<(j<<1)-1<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 5656kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 4ms
memory: 5720kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 3ms
memory: 6200kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 3ms
memory: 5692kb
input:
1659
output:
3 553 1 3299 7 3293 13 3287 19 3281 25 3275 31 3269 37 3263 43 3257 49 3251 55 3245 61 3239 67 3233 73 3227 79 3221 85 3215 91 3209 97 3203 103 3197 109 3191 115 3185 121 3179 127 3173 133 3167 139 3161 145 3155 151 3149 157 3143 163 3137 169 3131 175 3125 181 3119 187 3113 193 3107 199 3101 205 309...
result:
ok OK (3 groups)
Test #5:
score: 0
Accepted
time: 2ms
memory: 5972kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: 0
Accepted
time: 0ms
memory: 5656kb
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: 5672kb
input:
5
output:
-1
result:
ok OK (impossible)
Test #8:
score: 0
Accepted
time: 2ms
memory: 5720kb
input:
9
output:
3 3 1 11 15 3 3 7 17 3 5 9 13
result:
ok OK (3 groups)
Test #9:
score: 0
Accepted
time: 2ms
memory: 5632kb
input:
25
output:
5 5 1 19 27 35 43 5 3 11 29 37 45 5 5 13 21 39 47 5 7 15 23 31 49 5 9 17 25 33 41
result:
ok OK (5 groups)
Test #10:
score: 0
Accepted
time: 4ms
memory: 5684kb
input:
143
output:
11 13 1 43 45 87 107 127 147 167 187 207 227 247 267 13 3 41 47 67 109 129 149 169 189 209 229 249 269 13 5 39 49 69 89 131 151 171 191 211 231 251 271 13 7 37 51 71 91 111 153 173 193 213 233 253 273 13 9 35 53 73 93 113 133 175 195 215 235 255 275 13 11 33 55 75 95 115 135 155 197 217 237 257...
result:
ok OK (11 groups)
Test #11:
score: 0
Accepted
time: 7ms
memory: 6604kb
input:
85849
output:
293 293 1 1171 1755 2339 2923 3507 4091 4675 5259 5843 6427 7011 7595 8179 8763 9347 9931 10515 11099 11683 12267 12851 13435 14019 14603 15187 15771 16355 16939 17523 18107 18691 19275 19859 20443 21027 21611 22195 22779 23363 23947 24531 25115 25699 26283 26867 27451 28035 28619 29203 29787 30371 ...
result:
ok OK (293 groups)
Test #12:
score: 0
Accepted
time: 2ms
memory: 5852kb
input:
99991
output:
-1
result:
ok OK (impossible)
Test #13:
score: 0
Accepted
time: 14ms
memory: 6228kb
input:
99997
output:
19 5263 1 199271 39 199233 77 199195 115 199157 153 199119 191 199081 229 199043 267 199005 305 198967 343 198929 381 198891 419 198853 457 198815 495 198777 533 198739 571 198701 609 198663 647 198625 685 198587 723 198549 761 198511 799 198473 837 198435 875 198397 913 198359 951 198321 989 198283...
result:
ok OK (19 groups)
Test #14:
score: 0
Accepted
time: 7ms
memory: 5852kb
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: 2ms
memory: 5764kb
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: 5ms
memory: 5868kb
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: 15ms
memory: 5800kb
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: 2ms
memory: 5608kb
input:
16831
output:
-1
result:
ok OK (impossible)
Test #19:
score: 0
Accepted
time: 5ms
memory: 5768kb
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: 4ms
memory: 5752kb
input:
28979
output:
-1
result:
ok OK (impossible)
Test #21:
score: 0
Accepted
time: 0ms
memory: 5752kb
input:
20173
output:
-1
result:
ok OK (impossible)
Test #22:
score: 0
Accepted
time: 2ms
memory: 5788kb
input:
78401
output:
-1
result:
ok OK (impossible)
Test #23:
score: 0
Accepted
time: 4ms
memory: 5784kb
input:
52067
output:
-1
result:
ok OK (impossible)
Test #24:
score: 0
Accepted
time: 4ms
memory: 5952kb
input:
94727
output:
-1
result:
ok OK (impossible)
Test #25:
score: 0
Accepted
time: 4ms
memory: 5880kb
input:
35657
output:
181 197 1 5791 363 5429 725 5067 1087 4705 1449 4343 1811 3981 2173 3619 2535 3257 5793 6515 6875 7235 7595 7955 8315 8675 9035 9395 9755 10115 10475 10835 11195 11555 11915 12275 12635 12995 13355 13715 14075 14435 14795 15155 15515 15875 16235 16595 16955 17315 17675 18035 18395 18755 19115 19475 ...
result:
ok OK (181 groups)
Test #26:
score: 0
Accepted
time: 2ms
memory: 6284kb
input:
41449
output:
181 229 1 17375 363 17013 725 16651 1087 16289 1449 15927 1811 15565 2173 15203 2535 14841 2897 14479 3259 14117 3621 13755 3983 13393 4345 13031 4707 12669 5069 12307 5431 11945 5793 11583 6155 11221 6517 10859 6879 10497 7241 10135 7603 9773 7965 9411 8327 9049 17377 18099 18459 18819 19179 19539 ...
result:
ok OK (181 groups)
Test #27:
score: 0
Accepted
time: 2ms
memory: 5752kb
input:
7367
output:
53 139 1 9115 107 9009 213 8903 319 8797 425 8691 531 8585 637 8479 743 8373 849 8267 955 8161 1061 8055 1167 7949 1273 7843 1379 7737 1485 7631 1591 7525 1697 7419 1803 7313 1909 7207 2015 7101 2121 6995 2227 6889 2333 6783 2439 6677 2545 6571 2651 6465 2757 6359 2863 6253 2969 6147 3075 6041 3181 ...
result:
ok OK (53 groups)
Test #28:
score: 0
Accepted
time: 5ms
memory: 5692kb
input:
12191
output:
73 167 1 13723 147 13577 293 13431 439 13285 585 13139 731 12993 877 12847 1023 12701 1169 12555 1315 12409 1461 12263 1607 12117 1753 11971 1899 11825 2045 11679 2191 11533 2337 11387 2483 11241 2629 11095 2775 10949 2921 10803 3067 10657 3213 10511 3359 10365 3505 10219 3651 10073 3797 9927 3943 9...
result:
ok OK (73 groups)
Test #29:
score: 0
Accepted
time: 4ms
memory: 6072kb
input:
43847
output:
163 269 1 34555 327 34229 653 33903 979 33577 1305 33251 1631 32925 1957 32599 2283 32273 2609 31947 2935 31621 3261 31295 3587 30969 3913 30643 4239 30317 4565 29991 4891 29665 5217 29339 5543 29013 5869 28687 6195 28361 6521 28035 6847 27709 7173 27383 7499 27057 7825 26731 8151 26405 8477 26079 8...
result:
ok OK (163 groups)
Test #30:
score: 0
Accepted
time: 4ms
memory: 5824kb
input:
20819
output:
109 191 1 17875 219 17657 437 17439 655 17221 873 17003 1091 16785 1309 16567 1527 16349 1745 16131 1963 15913 2181 15695 2399 15477 2617 15259 2835 15041 3053 14823 3271 14605 3489 14387 3707 14169 3925 13951 4143 13733 4361 13515 4579 13297 4797 13079 5015 12861 5233 12643 5451 12425 5669 12207 58...
result:
ok OK (109 groups)
Test #31:
score: 0
Accepted
time: 5ms
memory: 5812kb
input:
9943
output:
61 163 1 12443 123 12321 245 12199 367 12077 489 11955 611 11833 733 11711 855 11589 977 11467 1099 11345 1221 11223 1343 11101 1465 10979 1587 10857 1709 10735 1831 10613 1953 10491 2075 10369 2197 10247 2319 10125 2441 10003 2563 9881 2685 9759 2807 9637 2929 9515 3051 9393 3173 9271 3295 9149 341...
result:
ok OK (61 groups)
Test #32:
score: 0
Accepted
time: 4ms
memory: 5808kb
input:
1369
output:
37 37 1 147 219 291 363 435 507 579 651 723 795 867 939 1011 1083 1155 1227 1299 1371 1443 1515 1587 1659 1731 1803 1875 1947 2019 2091 2163 2235 2307 2379 2451 2523 2595 2667 37 3 75 221 293 365 437 509 581 653 725 797 869 941 1013 1085 1157 1229 1301 1373 1445 1517 1589 1661 1733 1805 1877 1949 2...
result:
ok OK (37 groups)
Test #33:
score: 0
Accepted
time: 4ms
memory: 5876kb
input:
6241
output:
79 79 1 315 471 627 783 939 1095 1251 1407 1563 1719 1875 2031 2187 2343 2499 2655 2811 2967 3123 3279 3435 3591 3747 3903 4059 4215 4371 4527 4683 4839 4995 5151 5307 5463 5619 5775 5931 6087 6243 6399 6555 6711 6867 7023 7179 7335 7491 7647 7803 7959 8115 8271 8427 8583 8739 8895 9051 9207 9363 95...
result:
ok OK (79 groups)
Test #34:
score: 0
Accepted
time: 5ms
memory: 5728kb
input:
841
output:
29 29 1 115 171 227 283 339 395 451 507 563 619 675 731 787 843 899 955 1011 1067 1123 1179 1235 1291 1347 1403 1459 1515 1571 1627 29 3 59 173 229 285 341 397 453 509 565 621 677 733 789 845 901 957 1013 1069 1125 1181 1237 1293 1349 1405 1461 1517 1573 1629 29 5 61 117 231 287 343 399 455 511 56...
result:
ok OK (29 groups)
Test #35:
score: 0
Accepted
time: 7ms
memory: 6304kb
input:
69169
output:
263 263 1 1051 1575 2099 2623 3147 3671 4195 4719 5243 5767 6291 6815 7339 7863 8387 8911 9435 9959 10483 11007 11531 12055 12579 13103 13627 14151 14675 15199 15723 16247 16771 17295 17819 18343 18867 19391 19915 20439 20963 21487 22011 22535 23059 23583 24107 24631 25155 25679 26203 26727 27251 27...
result:
ok OK (263 groups)
Test #36:
score: 0
Accepted
time: 3ms
memory: 5684kb
input:
121
output:
11 11 1 43 63 83 103 123 143 163 183 203 223 11 3 23 65 85 105 125 145 165 185 205 225 11 5 25 45 87 107 127 147 167 187 207 227 11 7 27 47 67 109 129 149 169 189 209 229 11 9 29 49 69 89 131 151 171 191 211 231 11 11 31 51 71 91 111 153 173 193 213 233 11 13 33 53 73 93 113 133 175 195 215 23...
result:
ok OK (11 groups)