QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61388 | #1807. Distribute the Bars | tichec | AC ✓ | 21ms | 6956kb | C++14 | 993b | 2022-11-12 19:12:46 | 2022-11-12 19:12:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
struct apple{
long long he;
vector<int>g;
bool operator<(const apple &other)const{
return he<other.he;
}
}e[100005];int n;
int cmp(int a,int b){return e[a].he<e[b].he;}
int main(){
scanf("%d",&n);int flag=0;
for(int i=n-1;i>=2;i--)
if(n%i==0)flag=i;
if(!flag)puts("-1");
else{
if(n%2==0){
printf("%d\n",n/2);
for(int i=1;i<=n/2;i++)printf("%d %d %d\n",2,2*i-1,2*(n-i+1)-1);
}else{
int x=flag,y=n/flag;
printf("%d\n",y);
for(int i=1;i<=y;i++){
e[i].g.pb(2*i-1);
int D=y+(i+y/2)%y+1;
e[i].g.pb(2*D-1);
e[i].he=2*i-1+2*D-1;
}
sort(e+1,e+y+1);
for(int i=1;i<=y;i++){
printf("%d",x);
for(int j=0;j<2;j++)printf(" %d",e[i].g[j]);
int D=3*y-i+1;
printf(" %d",2*D-1);
for(int j=4;j<=x;j+=2){
int D1=(j-1)*y+i,D2=j*y+(y-i)+1;
printf(" %d %d",2*D1-1,2*D2-1);
}
printf("\n");
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 6624kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 4ms
memory: 6472kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 3ms
memory: 6608kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 0ms
memory: 6808kb
input:
1659
output:
553 3 553 1107 3317 3 1 1661 3315 3 555 1109 3313 3 3 1663 3311 3 557 1111 3309 3 5 1665 3307 3 559 1113 3305 3 7 1667 3303 3 561 1115 3301 3 9 1669 3299 3 563 1117 3297 3 11 1671 3295 3 565 1119 3293 3 13 1673 3291 3 567 1121 3289 3 15 1675 3287 3 569 1123 3285 3 17 1677 3283 3 571 1125 3281 3 19 1...
result:
ok OK (553 groups)
Test #5:
score: 0
Accepted
time: 1ms
memory: 6468kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: 0
Accepted
time: 4ms
memory: 6624kb
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: 1ms
memory: 6460kb
input:
5
output:
-1
result:
ok OK (impossible)
Test #8:
score: 0
Accepted
time: 3ms
memory: 6628kb
input:
9
output:
3 3 3 7 17 3 1 11 15 3 5 9 13
result:
ok OK (3 groups)
Test #9:
score: 0
Accepted
time: 3ms
memory: 6696kb
input:
25
output:
5 5 5 11 29 31 49 5 1 17 27 33 47 5 7 13 25 35 45 5 3 19 23 37 43 5 9 15 21 39 41
result:
ok OK (5 groups)
Test #10:
score: 0
Accepted
time: 4ms
memory: 6636kb
input:
143
output:
13 11 13 27 77 79 129 131 181 183 233 235 285 11 1 41 75 81 127 133 179 185 231 237 283 11 15 29 73 83 125 135 177 187 229 239 281 11 3 43 71 85 123 137 175 189 227 241 279 11 17 31 69 87 121 139 173 191 225 243 277 11 5 45 67 89 119 141 171 193 223 245 275 11 19 33 65 91 117 143 169 195 221 247 273...
result:
ok OK (13 groups)
Test #11:
score: 0
Accepted
time: 4ms
memory: 6704kb
input:
85849
output:
293 293 293 587 1757 1759 2929 2931 4101 4103 5273 5275 6445 6447 7617 7619 8789 8791 9961 9963 11133 11135 12305 12307 13477 13479 14649 14651 15821 15823 16993 16995 18165 18167 19337 19339 20509 20511 21681 21683 22853 22855 24025 24027 25197 25199 26369 26371 27541 27543 28713 28715 29885 29887 ...
result:
ok OK (293 groups)
Test #12:
score: 0
Accepted
time: 4ms
memory: 6596kb
input:
99991
output:
-1
result:
ok OK (impossible)
Test #13:
score: 0
Accepted
time: 4ms
memory: 6956kb
input:
99997
output:
5263 19 5263 10527 31577 31579 52629 52631 73681 73683 94733 94735 115785 115787 136837 136839 157889 157891 178941 178943 199993 19 1 15791 31575 31581 52627 52633 73679 73685 94731 94737 115783 115789 136835 136841 157887 157893 178939 178945 199991 19 5265 10529 31573 31583 52625 52635 73677 7368...
result:
ok OK (5263 groups)
Test #14:
score: 0
Accepted
time: 14ms
memory: 6632kb
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: 1ms
memory: 6784kb
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: 10ms
memory: 6784kb
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: 21ms
memory: 6772kb
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: 6460kb
input:
16831
output:
-1
result:
ok OK (impossible)
Test #19:
score: 0
Accepted
time: 2ms
memory: 6636kb
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: 0ms
memory: 6772kb
input:
28979
output:
-1
result:
ok OK (impossible)
Test #21:
score: 0
Accepted
time: 3ms
memory: 6600kb
input:
20173
output:
-1
result:
ok OK (impossible)
Test #22:
score: 0
Accepted
time: 3ms
memory: 6604kb
input:
78401
output:
-1
result:
ok OK (impossible)
Test #23:
score: 0
Accepted
time: 2ms
memory: 6596kb
input:
52067
output:
-1
result:
ok OK (impossible)
Test #24:
score: 0
Accepted
time: 2ms
memory: 6460kb
input:
94727
output:
-1
result:
ok OK (impossible)
Test #25:
score: 0
Accepted
time: 3ms
memory: 6728kb
input:
35657
output:
197 181 197 395 1181 1183 1969 1971 2757 2759 3545 3547 4333 4335 5121 5123 5909 5911 6697 6699 7485 7487 8273 8275 9061 9063 9849 9851 10637 10639 11425 11427 12213 12215 13001 13003 13789 13791 14577 14579 15365 15367 16153 16155 16941 16943 17729 17731 18517 18519 19305 19307 20093 20095 20881 20...
result:
ok OK (197 groups)
Test #26:
score: 0
Accepted
time: 7ms
memory: 6704kb
input:
41449
output:
229 181 229 459 1373 1375 2289 2291 3205 3207 4121 4123 5037 5039 5953 5955 6869 6871 7785 7787 8701 8703 9617 9619 10533 10535 11449 11451 12365 12367 13281 13283 14197 14199 15113 15115 16029 16031 16945 16947 17861 17863 18777 18779 19693 19695 20609 20611 21525 21527 22441 22443 23357 23359 2427...
result:
ok OK (229 groups)
Test #27:
score: 0
Accepted
time: 4ms
memory: 6888kb
input:
7367
output:
139 53 139 279 833 835 1389 1391 1945 1947 2501 2503 3057 3059 3613 3615 4169 4171 4725 4727 5281 5283 5837 5839 6393 6395 6949 6951 7505 7507 8061 8063 8617 8619 9173 9175 9729 9731 10285 10287 10841 10843 11397 11399 11953 11955 12509 12511 13065 13067 13621 13623 14177 14179 14733 53 1 419 831 83...
result:
ok OK (139 groups)
Test #28:
score: 0
Accepted
time: 5ms
memory: 6636kb
input:
12191
output:
167 73 167 335 1001 1003 1669 1671 2337 2339 3005 3007 3673 3675 4341 4343 5009 5011 5677 5679 6345 6347 7013 7015 7681 7683 8349 8351 9017 9019 9685 9687 10353 10355 11021 11023 11689 11691 12357 12359 13025 13027 13693 13695 14361 14363 15029 15031 15697 15699 16365 16367 17033 17035 17701 17703 1...
result:
ok OK (167 groups)
Test #29:
score: 0
Accepted
time: 8ms
memory: 6644kb
input:
43847
output:
269 163 269 539 1613 1615 2689 2691 3765 3767 4841 4843 5917 5919 6993 6995 8069 8071 9145 9147 10221 10223 11297 11299 12373 12375 13449 13451 14525 14527 15601 15603 16677 16679 17753 17755 18829 18831 19905 19907 20981 20983 22057 22059 23133 23135 24209 24211 25285 25287 26361 26363 27437 27439 ...
result:
ok OK (269 groups)
Test #30:
score: 0
Accepted
time: 6ms
memory: 6652kb
input:
20819
output:
191 109 191 383 1145 1147 1909 1911 2673 2675 3437 3439 4201 4203 4965 4967 5729 5731 6493 6495 7257 7259 8021 8023 8785 8787 9549 9551 10313 10315 11077 11079 11841 11843 12605 12607 13369 13371 14133 14135 14897 14899 15661 15663 16425 16427 17189 17191 17953 17955 18717 18719 19481 19483 20245 20...
result:
ok OK (191 groups)
Test #31:
score: 0
Accepted
time: 4ms
memory: 6644kb
input:
9943
output:
163 61 163 327 977 979 1629 1631 2281 2283 2933 2935 3585 3587 4237 4239 4889 4891 5541 5543 6193 6195 6845 6847 7497 7499 8149 8151 8801 8803 9453 9455 10105 10107 10757 10759 11409 11411 12061 12063 12713 12715 13365 13367 14017 14019 14669 14671 15321 15323 15973 15975 16625 16627 17277 17279 179...
result:
ok OK (163 groups)
Test #32:
score: 0
Accepted
time: 2ms
memory: 6796kb
input:
1369
output:
37 37 37 75 221 223 369 371 517 519 665 667 813 815 961 963 1109 1111 1257 1259 1405 1407 1553 1555 1701 1703 1849 1851 1997 1999 2145 2147 2293 2295 2441 2443 2589 2591 2737 37 1 113 219 225 367 373 515 521 663 669 811 817 959 965 1107 1113 1255 1261 1403 1409 1551 1557 1699 1705 1847 1853 1995 200...
result:
ok OK (37 groups)
Test #33:
score: 0
Accepted
time: 0ms
memory: 6672kb
input:
6241
output:
79 79 79 159 473 475 789 791 1105 1107 1421 1423 1737 1739 2053 2055 2369 2371 2685 2687 3001 3003 3317 3319 3633 3635 3949 3951 4265 4267 4581 4583 4897 4899 5213 5215 5529 5531 5845 5847 6161 6163 6477 6479 6793 6795 7109 7111 7425 7427 7741 7743 8057 8059 8373 8375 8689 8691 9005 9007 9321 9323 9...
result:
ok OK (79 groups)
Test #34:
score: 0
Accepted
time: 3ms
memory: 6700kb
input:
841
output:
29 29 29 59 173 175 289 291 405 407 521 523 637 639 753 755 869 871 985 987 1101 1103 1217 1219 1333 1335 1449 1451 1565 1567 1681 29 1 89 171 177 287 293 403 409 519 525 635 641 751 757 867 873 983 989 1099 1105 1215 1221 1331 1337 1447 1453 1563 1569 1679 29 31 61 169 179 285 295 401 411 517 527 6...
result:
ok OK (29 groups)
Test #35:
score: 0
Accepted
time: 10ms
memory: 6632kb
input:
69169
output:
263 263 263 527 1577 1579 2629 2631 3681 3683 4733 4735 5785 5787 6837 6839 7889 7891 8941 8943 9993 9995 11045 11047 12097 12099 13149 13151 14201 14203 15253 15255 16305 16307 17357 17359 18409 18411 19461 19463 20513 20515 21565 21567 22617 22619 23669 23671 24721 24723 25773 25775 26825 26827 27...
result:
ok OK (263 groups)
Test #36:
score: 0
Accepted
time: 2ms
memory: 6680kb
input:
121
output:
11 11 11 23 65 67 109 111 153 155 197 199 241 11 1 35 63 69 107 113 151 157 195 201 239 11 13 25 61 71 105 115 149 159 193 203 237 11 3 37 59 73 103 117 147 161 191 205 235 11 15 27 57 75 101 119 145 163 189 207 233 11 5 39 55 77 99 121 143 165 187 209 231 11 17 29 53 79 97 123 141 167 185 211 229 1...
result:
ok OK (11 groups)