QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546397 | #1807. Distribute the Bars | surgutti | AC ✓ | 6ms | 4132kb | C++17 | 956b | 2024-09-04 00:30:02 | 2024-09-04 00:30:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int p = 2;
while (p < n) {
if (n % p == 0)
break;
p++;
}
if (p >= n) {
cout << "-1\n";
return 0;
}
if (n % 2 == 0) {
cout << n / 2 << '\n';
for (int i = 1; i <= n / 2; i++) {
cout << 2 << ' ' << 2 * i - 1 << ' ' << 2 * (n - i + 1) - 1 << '\n';
}
return 0;
}
vector<vector<int>> groups(p);
for (int j = 0; j < p; j++) {
for (int k = 0; k < p; k++) {
groups[(j + k) % p].push_back(2 * (1 + j * p + k) - 1);
}
}
int cur = 0;
for (int l = 1 + p * p, r = n; l < r; l++, r--) {
groups[cur].push_back(2 * l - 1);
groups[cur].push_back(2 * r - 1);
cur = (cur + 1) % p;
}
cout << groups.size() << '\n';
for (auto g : groups) {
cout << g.size() << ' ';
for (int x : g)
cout << x << ' ';
cout << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1659
output:
3 553 1 11 15 19 3317 25 3311 31 3305 37 3299 43 3293 49 3287 55 3281 61 3275 67 3269 73 3263 79 3257 85 3251 91 3245 97 3239 103 3233 109 3227 115 3221 121 3215 127 3209 133 3203 139 3197 145 3191 151 3185 157 3179 163 3173 169 3167 175 3161 181 3155 187 3149 193 3143 199 3137 205 3131 211 3125 217...
result:
ok OK (3 groups)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: 0
Accepted
time: 0ms
memory: 3612kb
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: 0ms
memory: 3596kb
input:
5
output:
-1
result:
ok OK (impossible)
Test #8:
score: 0
Accepted
time: 0ms
memory: 3780kb
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: 0ms
memory: 3824kb
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: 0ms
memory: 3740kb
input:
143
output:
11 13 1 43 63 83 103 123 143 163 183 203 223 243 285 13 3 23 65 85 105 125 145 165 185 205 225 245 283 13 5 25 45 87 107 127 147 167 187 207 227 247 281 13 7 27 47 67 109 129 149 169 189 209 229 249 279 13 9 29 49 69 89 131 151 171 191 211 231 251 277 13 11 31 51 71 91 111 153 173 193 213 233 2...
result:
ok OK (11 groups)
Test #11:
score: 0
Accepted
time: 4ms
memory: 3904kb
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: 1ms
memory: 3592kb
input:
99991
output:
-1
result:
ok OK (impossible)
Test #13:
score: 0
Accepted
time: 4ms
memory: 3864kb
input:
99997
output:
19 5263 1 75 111 147 183 219 255 291 327 363 399 435 471 507 543 579 615 651 687 723 199993 761 199955 799 199917 837 199879 875 199841 913 199803 951 199765 989 199727 1027 199689 1065 199651 1103 199613 1141 199575 1179 199537 1217 199499 1255 199461 1293 199423 1331 199385 1369 199347 1407 199309...
result:
ok OK (19 groups)
Test #14:
score: 0
Accepted
time: 6ms
memory: 3520kb
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: 3812kb
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: 4ms
memory: 3508kb
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: 5ms
memory: 3592kb
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: 0ms
memory: 3812kb
input:
16831
output:
-1
result:
ok OK (impossible)
Test #19:
score: 0
Accepted
time: 1ms
memory: 3596kb
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: 3616kb
input:
28979
output:
-1
result:
ok OK (impossible)
Test #21:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
20173
output:
-1
result:
ok OK (impossible)
Test #22:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
78401
output:
-1
result:
ok OK (impossible)
Test #23:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
52067
output:
-1
result:
ok OK (impossible)
Test #24:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
94727
output:
-1
result:
ok OK (impossible)
Test #25:
score: 0
Accepted
time: 2ms
memory: 3800kb
input:
35657
output:
181 197 1 723 1083 1443 1803 2163 2523 2883 3243 3603 3963 4323 4683 5043 5403 5763 6123 6483 6843 7203 7563 7923 8283 8643 9003 9363 9723 10083 10443 10803 11163 11523 11883 12243 12603 12963 13323 13683 14043 14403 14763 15123 15483 15843 16203 16563 16923 17283 17643 18003 18363 18723 19083 19443...
result:
ok OK (181 groups)
Test #26:
score: 0
Accepted
time: 2ms
memory: 3732kb
input:
41449
output:
181 229 1 723 1083 1443 1803 2163 2523 2883 3243 3603 3963 4323 4683 5043 5403 5763 6123 6483 6843 7203 7563 7923 8283 8643 9003 9363 9723 10083 10443 10803 11163 11523 11883 12243 12603 12963 13323 13683 14043 14403 14763 15123 15483 15843 16203 16563 16923 17283 17643 18003 18363 18723 19083 19443...
result:
ok OK (181 groups)
Test #27:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
7367
output:
53 139 1 211 315 419 523 627 731 835 939 1043 1147 1251 1355 1459 1563 1667 1771 1875 1979 2083 2187 2291 2395 2499 2603 2707 2811 2915 3019 3123 3227 3331 3435 3539 3643 3747 3851 3955 4059 4163 4267 4371 4475 4579 4683 4787 4891 4995 5099 5203 5307 5411 5515 5619 14733 5725 14627 5831 14521 5937 1...
result:
ok OK (53 groups)
Test #28:
score: 0
Accepted
time: 1ms
memory: 3912kb
input:
12191
output:
73 167 1 291 435 579 723 867 1011 1155 1299 1443 1587 1731 1875 2019 2163 2307 2451 2595 2739 2883 3027 3171 3315 3459 3603 3747 3891 4035 4179 4323 4467 4611 4755 4899 5043 5187 5331 5475 5619 5763 5907 6051 6195 6339 6483 6627 6771 6915 7059 7203 7347 7491 7635 7779 7923 8067 8211 8355 8499 8643 8...
result:
ok OK (73 groups)
Test #29:
score: 0
Accepted
time: 2ms
memory: 3868kb
input:
43847
output:
163 269 1 651 975 1299 1623 1947 2271 2595 2919 3243 3567 3891 4215 4539 4863 5187 5511 5835 6159 6483 6807 7131 7455 7779 8103 8427 8751 9075 9399 9723 10047 10371 10695 11019 11343 11667 11991 12315 12639 12963 13287 13611 13935 14259 14583 14907 15231 15555 15879 16203 16527 16851 17175 17499 178...
result:
ok OK (163 groups)
Test #30:
score: 0
Accepted
time: 1ms
memory: 3944kb
input:
20819
output:
109 191 1 435 651 867 1083 1299 1515 1731 1947 2163 2379 2595 2811 3027 3243 3459 3675 3891 4107 4323 4539 4755 4971 5187 5403 5619 5835 6051 6267 6483 6699 6915 7131 7347 7563 7779 7995 8211 8427 8643 8859 9075 9291 9507 9723 9939 10155 10371 10587 10803 11019 11235 11451 11667 11883 12099 12315 12...
result:
ok OK (109 groups)
Test #31:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
9943
output:
61 163 1 243 363 483 603 723 843 963 1083 1203 1323 1443 1563 1683 1803 1923 2043 2163 2283 2403 2523 2643 2763 2883 3003 3123 3243 3363 3483 3603 3723 3843 3963 4083 4203 4323 4443 4563 4683 4803 4923 5043 5163 5283 5403 5523 5643 5763 5883 6003 6123 6243 6363 6483 6603 6723 6843 6963 7083 7203 732...
result:
ok OK (61 groups)
Test #32:
score: 0
Accepted
time: 0ms
memory: 3628kb
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: 1ms
memory: 3668kb
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: 0ms
memory: 3556kb
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: 3ms
memory: 4132kb
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: 0ms
memory: 3612kb
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)