QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61586 | #1807. Distribute the Bars | yanran | AC ✓ | 20ms | 7560kb | C++14 | 1.2kb | 2022-11-14 10:25:17 | 2022-11-14 10:25:18 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS\
ios::sync_with_stdio(false);\
cin.tie(0), cout.tie(0);
using namespace std;
const int N = 1e5 + 3;
int a[N], n;
vector<int> b[N];
void ou(int l, int r, int p) {
if (l > r) return;
int num = (r - l + 1) / p / 2, cnt;
for (int i = 1; i <= p; i++) {
cnt = num;
while (cnt--) {
b[i].push_back(a[l]);
l++;
}
cnt = num;
while (cnt--) {
b[i].push_back(a[r]);
r--;
}
}
}
void ji(int m, int p) {
for (int i = 1; i <= p; i++) {
for (int j = i, now = i; j <= m; j += p) {
b[now].push_back(a[j]);
now--;
if (!now) now = p;
}
}
}
int pd(int x) {
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
return i;
}
}
return 0;
}
signed main() {
IOS;
cin >> n;
int p = pd(n);
if (!p) {
cout << -1;
return 0;
}
for (int i = 1; i <= n; i++) {
a[i] = i * 2 - 1;
}
if (n & 1) {
ji(p * p, p);
ou(p * p + 1, n, p);
}
else {
p = n / 2;
ou(1, n, n / 2);
}
cout << p << '\n';
for (int i = 1; i <= p; i++) {
cout << b[i].size() << ' ';
for (auto x : b[i]) {
cout << x << ' ';
}
cout << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5848kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 2ms
memory: 5740kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 2ms
memory: 5656kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: 0
Accepted
time: 5ms
memory: 5872kb
input:
1659
output:
3 553 1 9 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 ...
result:
ok OK (3 groups)
Test #5:
score: 0
Accepted
time: 5ms
memory: 5672kb
input:
8941
output:
-1
result:
ok OK (impossible)
Test #6:
score: 0
Accepted
time: 1ms
memory: 5700kb
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...
result:
ok OK (229 groups)
Test #7:
score: 0
Accepted
time: 0ms
memory: 5660kb
input:
5
output:
-1
result:
ok OK (impossible)
Test #8:
score: 0
Accepted
time: 5ms
memory: 5744kb
input:
9
output:
3 3 1 9 17 3 13 3 11 3 7 15 5
result:
ok OK (3 groups)
Test #9:
score: 0
Accepted
time: 2ms
memory: 5668kb
input:
25
output:
5 5 1 13 25 37 49 5 41 3 15 27 39 5 31 43 5 17 29 5 21 33 45 7 19 5 11 23 35 47 9
result:
ok OK (5 groups)
Test #10:
score: 0
Accepted
time: 4ms
memory: 5820kb
input:
143
output:
11 13 1 25 49 73 97 121 145 169 193 217 241 243 285 13 221 3 27 51 75 99 123 147 171 195 219 245 283 13 199 223 5 29 53 77 101 125 149 173 197 247 281 13 177 201 225 7 31 55 79 103 127 151 175 249 279 13 155 179 203 227 9 33 57 81 105 129 153 251 277 13 133 157 181 205 229 11 35 59 83 107 131 2...
result:
ok OK (11 groups)
Test #11:
score: 0
Accepted
time: 13ms
memory: 6512kb
input:
85849
output:
293 293 1 589 1177 1765 2353 2941 3529 4117 4705 5293 5881 6469 7057 7645 8233 8821 9409 9997 10585 11173 11761 12349 12937 13525 14113 14701 15289 15877 16465 17053 17641 18229 18817 19405 19993 20581 21169 21757 22345 22933 23521 24109 24697 25285 25873 26461 27049 27637 28225 28813 29401 29989 30...
result:
ok OK (293 groups)
Test #12:
score: 0
Accepted
time: 0ms
memory: 5732kb
input:
99991
output:
-1
result:
ok OK (impossible)
Test #13:
score: 0
Accepted
time: 7ms
memory: 6452kb
input:
99997
output:
19 5263 1 41 81 121 161 201 241 281 321 361 401 441 481 521 561 601 641 681 721 723 725 727 729 731 733 735 737 739 741 743 745 747 749 751 753 755 757 759 761 763 765 767 769 771 773 775 777 779 781 783 785 787 789 791 793 795 797 799 801 803 805 807 809 811 813 815 817 819 821 823 825 827 829 831 ...
result:
ok OK (19 groups)
Test #14:
score: 0
Accepted
time: 14ms
memory: 7560kb
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 ...
result:
ok OK (50000 groups)
Test #15:
score: 0
Accepted
time: 4ms
memory: 6304kb
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 ...
result:
ok OK (14227 groups)
Test #16:
score: 0
Accepted
time: 9ms
memory: 7004kb
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 ...
result:
ok OK (32169 groups)
Test #17:
score: 0
Accepted
time: 20ms
memory: 7332kb
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 ...
result:
ok OK (44039 groups)
Test #18:
score: 0
Accepted
time: 5ms
memory: 5672kb
input:
16831
output:
-1
result:
ok OK (impossible)
Test #19:
score: 0
Accepted
time: 2ms
memory: 5876kb
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 ...
result:
ok OK (5440 groups)
Test #20:
score: 0
Accepted
time: 4ms
memory: 5604kb
input:
28979
output:
-1
result:
ok OK (impossible)
Test #21:
score: 0
Accepted
time: 2ms
memory: 5684kb
input:
20173
output:
-1
result:
ok OK (impossible)
Test #22:
score: 0
Accepted
time: 4ms
memory: 5656kb
input:
78401
output:
-1
result:
ok OK (impossible)
Test #23:
score: 0
Accepted
time: 0ms
memory: 5736kb
input:
52067
output:
-1
result:
ok OK (impossible)
Test #24:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
94727
output:
-1
result:
ok OK (impossible)
Test #25:
score: 0
Accepted
time: 8ms
memory: 5944kb
input:
35657
output:
181 197 1 365 729 1093 1457 1821 2185 2549 2913 3277 3641 4005 4369 4733 5097 5461 5825 6189 6553 6917 7281 7645 8009 8373 8737 9101 9465 9829 10193 10557 10921 11285 11649 12013 12377 12741 13105 13469 13833 14197 14561 14925 15289 15653 16017 16381 16745 17109 17473 17837 18201 18565 18929 19293 1...
result:
ok OK (181 groups)
Test #26:
score: 0
Accepted
time: 3ms
memory: 6008kb
input:
41449
output:
181 229 1 365 729 1093 1457 1821 2185 2549 2913 3277 3641 4005 4369 4733 5097 5461 5825 6189 6553 6917 7281 7645 8009 8373 8737 9101 9465 9829 10193 10557 10921 11285 11649 12013 12377 12741 13105 13469 13833 14197 14561 14925 15289 15653 16017 16381 16745 17109 17473 17837 18201 18565 18929 19293 1...
result:
ok OK (181 groups)
Test #27:
score: 0
Accepted
time: 2ms
memory: 5932kb
input:
7367
output:
53 139 1 109 217 325 433 541 649 757 865 973 1081 1189 1297 1405 1513 1621 1729 1837 1945 2053 2161 2269 2377 2485 2593 2701 2809 2917 3025 3133 3241 3349 3457 3565 3673 3781 3889 3997 4105 4213 4321 4429 4537 4645 4753 4861 4969 5077 5185 5293 5401 5509 5617 5619 5621 5623 5625 5627 5629 5631 5633 ...
result:
ok OK (53 groups)
Test #28:
score: 0
Accepted
time: 0ms
memory: 5836kb
input:
12191
output:
73 167 1 149 297 445 593 741 889 1037 1185 1333 1481 1629 1777 1925 2073 2221 2369 2517 2665 2813 2961 3109 3257 3405 3553 3701 3849 3997 4145 4293 4441 4589 4737 4885 5033 5181 5329 5477 5625 5773 5921 6069 6217 6365 6513 6661 6809 6957 7105 7253 7401 7549 7697 7845 7993 8141 8289 8437 8585 8733 88...
result:
ok OK (73 groups)
Test #29:
score: 0
Accepted
time: 5ms
memory: 6084kb
input:
43847
output:
163 269 1 329 657 985 1313 1641 1969 2297 2625 2953 3281 3609 3937 4265 4593 4921 5249 5577 5905 6233 6561 6889 7217 7545 7873 8201 8529 8857 9185 9513 9841 10169 10497 10825 11153 11481 11809 12137 12465 12793 13121 13449 13777 14105 14433 14761 15089 15417 15745 16073 16401 16729 17057 17385 17713...
result:
ok OK (163 groups)
Test #30:
score: 0
Accepted
time: 2ms
memory: 6056kb
input:
20819
output:
109 191 1 221 441 661 881 1101 1321 1541 1761 1981 2201 2421 2641 2861 3081 3301 3521 3741 3961 4181 4401 4621 4841 5061 5281 5501 5721 5941 6161 6381 6601 6821 7041 7261 7481 7701 7921 8141 8361 8581 8801 9021 9241 9461 9681 9901 10121 10341 10561 10781 11001 11221 11441 11661 11881 12101 12321 125...
result:
ok OK (109 groups)
Test #31:
score: 0
Accepted
time: 6ms
memory: 5804kb
input:
9943
output:
61 163 1 125 249 373 497 621 745 869 993 1117 1241 1365 1489 1613 1737 1861 1985 2109 2233 2357 2481 2605 2729 2853 2977 3101 3225 3349 3473 3597 3721 3845 3969 4093 4217 4341 4465 4589 4713 4837 4961 5085 5209 5333 5457 5581 5705 5829 5953 6077 6201 6325 6449 6573 6697 6821 6945 7069 7193 7317 7441...
result:
ok OK (61 groups)
Test #32:
score: 0
Accepted
time: 5ms
memory: 5764kb
input:
1369
output:
37 37 1 77 153 229 305 381 457 533 609 685 761 837 913 989 1065 1141 1217 1293 1369 1445 1521 1597 1673 1749 1825 1901 1977 2053 2129 2205 2281 2357 2433 2509 2585 2661 2737 37 2665 3 79 155 231 307 383 459 535 611 687 763 839 915 991 1067 1143 1219 1295 1371 1447 1523 1599 1675 1751 1827 1903 1979...
result:
ok OK (37 groups)
Test #33:
score: 0
Accepted
time: 2ms
memory: 5924kb
input:
6241
output:
79 79 1 161 321 481 641 801 961 1121 1281 1441 1601 1761 1921 2081 2241 2401 2561 2721 2881 3041 3201 3361 3521 3681 3841 4001 4161 4321 4481 4641 4801 4961 5121 5281 5441 5601 5761 5921 6081 6241 6401 6561 6721 6881 7041 7201 7361 7521 7681 7841 8001 8161 8321 8481 8641 8801 8961 9121 9281 9441 960...
result:
ok OK (79 groups)
Test #34:
score: 0
Accepted
time: 5ms
memory: 5624kb
input:
841
output:
29 29 1 61 121 181 241 301 361 421 481 541 601 661 721 781 841 901 961 1021 1081 1141 1201 1261 1321 1381 1441 1501 1561 1621 1681 29 1625 3 63 123 183 243 303 363 423 483 543 603 663 723 783 843 903 963 1023 1083 1143 1203 1263 1323 1383 1443 1503 1563 1623 29 1567 1627 5 65 125 185 245 305 365 4...
result:
ok OK (29 groups)
Test #35:
score: 0
Accepted
time: 4ms
memory: 6432kb
input:
69169
output:
263 263 1 529 1057 1585 2113 2641 3169 3697 4225 4753 5281 5809 6337 6865 7393 7921 8449 8977 9505 10033 10561 11089 11617 12145 12673 13201 13729 14257 14785 15313 15841 16369 16897 17425 17953 18481 19009 19537 20065 20593 21121 21649 22177 22705 23233 23761 24289 24817 25345 25873 26401 26929 274...
result:
ok OK (263 groups)
Test #36:
score: 0
Accepted
time: 2ms
memory: 5680kb
input:
121
output:
11 11 1 25 49 73 97 121 145 169 193 217 241 11 221 3 27 51 75 99 123 147 171 195 219 11 199 223 5 29 53 77 101 125 149 173 197 11 177 201 225 7 31 55 79 103 127 151 175 11 155 179 203 227 9 33 57 81 105 129 153 11 133 157 181 205 229 11 35 59 83 107 131 11 111 135 159 183 207 231 13 37 61 85 1...
result:
ok OK (11 groups)