QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#351249 | #8004. Bit Component | SolitaryDream# | AC ✓ | 10ms | 6180kb | C++17 | 1.5kb | 2024-03-11 19:12:10 | 2024-03-11 19:12:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
if (n == 1) { cout << "YES\n1\n"; return 0; }
if (n == 3) { cout << "YES\n2 3 1\n"; return 0; }
if (n == 7) { cout << "YES\n1 3 2 6 4 5 7\n"; return 0; }
if (n <= 12) { cout << "NO\n"; return 0; }
int k = __lg(n);
if (n <= (1 << k) + (1 << k - 1)) {
cout << "NO\n";
return 0;
}
vector<int> ans({1, 3, 2, 6, 4, 5, 7});
vector<int> last({0, 1, 3, 2});
for (int i = 3; ; ++i) {
int lim = (1 << i);
int v1 = (1 << i) + (1 << i - 1), v2 = v1 + 1;
ans.push_back(v2);
for (int j = 1; j < last.size(); ++j) ans.push_back(last[j] | (1 << i));
ans.push_back(last[0] | (1 << i));
ans.push_back(v1);
vector<int> nans;
for (int i = 0; i < ans.size(); ++i) {
nans.push_back(ans[i]);
if (ans[i] < lim - 1 && (ans[i] | lim) <= n && (ans[i] | lim) > v2) nans.push_back(ans[i] | lim);
}
if ((lim | lim - 1) <= n) nans.push_back(lim | lim - 1);
ans = nans;
if (nans.size() == n) break;
for (int j = last.size() - 1; ~j; --j) last.push_back(1 << (i - 1) | last[j]);
}
// for (auto x : ans) {
// cout << bitset<5>(x).to_string() << endl;
// }
cout << "YES\n";
for (auto x : ans) cout << x << ' ';
cout << endl;
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
3
output:
YES 2 3 1
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
7
output:
YES 1 3 2 6 4 5 7
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
13
output:
YES 1 3 2 6 4 5 7 13 9 11 10 8 12
result:
ok answer is 1
Test #14:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
14
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 8 12
result:
ok answer is 1
Test #15:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
15
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 8 12 15
result:
ok answer is 1
Test #16:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
16
output:
NO
result:
ok answer is 0
Test #17:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
17
output:
NO
result:
ok answer is 0
Test #18:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
23
output:
NO
result:
ok answer is 0
Test #19:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
24
output:
NO
result:
ok answer is 0
Test #20:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
25
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 8 12 15 25 17 19 18 22 23 21 20 16 24
result:
ok answer is 1
Test #21:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
26
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 26 8 12 15 25 17 19 18 22 23 21 20 16 24
result:
ok answer is 1
Test #22:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
27
output:
YES 1 3 2 6 14 4 5 7 13 9 11 27 10 26 8 12 15 25 17 19 18 22 23 21 20 16 24
result:
ok answer is 1
Test #23:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
40
output:
NO
result:
ok answer is 0
Test #24:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
53
output:
YES 1 3 2 6 14 30 4 5 7 13 29 9 11 27 10 26 8 12 28 15 25 17 19 51 18 50 22 23 21 53 20 52 16 24 31 49 33 35 34 38 39 37 36 44 45 47 46 42 43 41 40 32 48
result:
ok answer is 1
Test #25:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
93
output:
NO
result:
ok answer is 0
Test #26:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
105
output:
YES 1 3 2 6 14 30 62 4 5 7 13 29 61 9 11 27 59 10 26 58 8 12 28 60 15 25 57 17 19 51 18 50 22 54 23 55 21 53 20 52 16 24 56 31 49 33 35 99 34 98 38 102 39 103 37 101 36 100 44 45 47 46 42 43 41 105 40 104 32 48 63 97 65 67 66 70 71 69 68 76 77 79 78 74 75 73 72 88 89 91 90 94 95 93 92 84 85 87 86 82...
result:
ok answer is 1
Test #27:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
132
output:
NO
result:
ok answer is 0
Test #28:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
221
output:
YES 1 3 2 6 14 30 62 126 4 5 7 13 29 61 125 9 11 27 59 123 10 26 58 122 8 12 28 60 124 15 25 57 121 17 19 51 115 18 50 114 22 54 118 23 55 119 21 53 117 20 52 116 16 24 56 120 31 49 113 33 35 99 34 98 38 102 39 103 37 101 36 100 44 108 45 109 47 111 46 110 42 106 43 107 41 105 40 104 32 48 112 63 97...
result:
ok answer is 1
Test #29:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
373
output:
NO
result:
ok answer is 0
Test #30:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
473
output:
YES 1 3 2 6 14 30 62 126 254 4 5 7 13 29 61 125 253 9 11 27 59 123 251 10 26 58 122 250 8 12 28 60 124 252 15 25 57 121 249 17 19 51 115 243 18 50 114 242 22 54 118 246 23 55 119 247 21 53 117 245 20 52 116 244 16 24 56 120 248 31 49 113 241 33 35 99 227 34 98 226 38 102 230 39 103 231 37 101 229 36...
result:
ok answer is 1
Test #31:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
513
output:
NO
result:
ok answer is 0
Test #32:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
934
output:
YES 1 3 2 6 14 30 62 126 254 510 4 5 7 13 29 61 125 253 509 9 11 27 59 123 251 507 10 26 58 122 250 506 8 12 28 60 124 252 508 15 25 57 121 249 505 17 19 51 115 243 499 18 50 114 242 498 22 54 118 246 502 23 55 119 247 503 21 53 117 245 501 20 52 116 244 500 16 24 56 120 248 504 31 49 113 241 497 33...
result:
ok answer is 1
Test #33:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1356
output:
NO
result:
ok answer is 0
Test #34:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1651
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 4 5 7 13 29 61 125 253 509 1021 9 11 27 59 123 251 507 1019 10 26 58 122 250 506 1018 8 12 28 60 124 252 508 1020 15 25 57 121 249 505 1017 17 19 51 115 243 499 1011 18 50 114 242 498 1010 22 54 118 246 502 1014 23 55 119 247 503 1015 21 53 117 245 501 1013 20 5...
result:
ok answer is 1
Test #35:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2263
output:
NO
result:
ok answer is 0
Test #36:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
3330
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4 5 7 13 29 61 125 253 509 1021 2045 9 11 27 59 123 251 507 1019 2043 10 26 58 122 250 506 1018 2042 8 12 28 60 124 252 508 1020 2044 15 25 57 121 249 505 1017 2041 17 19 51 115 243 499 1011 2035 18 50 114 242 498 1010 2034 22 54 118 246 502 1014 2038 23 55...
result:
ok answer is 1
Test #37:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4375
output:
NO
result:
ok answer is 0
Test #38:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
7989
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 4 5 7 13 29 61 125 253 509 1021 2045 4093 9 11 27 59 123 251 507 1019 2043 4091 10 26 58 122 250 506 1018 2042 4090 8 12 28 60 124 252 508 1020 2044 4092 15 25 57 121 249 505 1017 2041 4089 17 19 51 115 243 499 1011 2035 4083 18 50 114 242 498 1010 203...
result:
ok answer is 1
Test #39:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
10925
output:
NO
result:
ok answer is 0
Test #40:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
14097
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 9 11 27 59 123 251 507 1019 2043 4091 8187 10 26 58 122 250 506 1018 2042 4090 8186 8 12 28 60 124 252 508 1020 2044 4092 8188 15 25 57 121 249 505 1017 2041 4089 8185 17 19 51 115 243 499 1011 2035 4...
result:
ok answer is 1
Test #41:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
16893
output:
NO
result:
ok answer is 0
Test #42:
score: 0
Accepted
time: 2ms
memory: 3736kb
input:
28913
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 10 26 58 122 250 506 1018 2042 4090 8186 16378 8 12 28 60 124 252 508 1020 2044 4092 8188 16380 15 25 57 121 249 505 1017 2041 4089 8185 16...
result:
ok answer is 1
Test #43:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
40092
output:
NO
result:
ok answer is 0
Test #44:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
54980
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 32763 10 26 58 122 250 506 1018 2042 4090 8186 16378 32762 8 12 28 60 124 252 508 1020 2044 4092 8188 16380 32764 15 25 57 121 ...
result:
ok answer is 1
Test #45:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
88104
output:
NO
result:
ok answer is 0
Test #46:
score: 0
Accepted
time: 2ms
memory: 4728kb
input:
106284
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 65534 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 65533 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 32763 65531 10 26 58 122 250 506 1018 2042 4090 8186 16378 32762 65530 8 12 28 60 124 252 508 1020 2044 4092 8188 1...
result:
ok answer is 1
Test #47:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
152797
output:
NO
result:
ok answer is 0
Test #48:
score: 0
Accepted
time: 10ms
memory: 6180kb
input:
200000
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 65534 131070 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 65533 131069 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 32763 65531 131067 10 26 58 122 250 506 1018 2042 4090 8186 16378 32762 65530 131066 8 12 28 60 124 2...
result:
ok answer is 1
Test #49:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
3073
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4 5 7 13 29 61 125 253 509 1021 2045 9 11 27 59 123 251 507 1019 2043 10 26 58 122 250 506 1018 2042 8 12 28 60 124 252 508 1020 2044 15 25 57 121 249 505 1017 2041 17 19 51 115 243 499 1011 2035 18 50 114 242 498 1010 2034 22 54 118 246 502 1014 2038 23 55...
result:
ok answer is 1
Test #50:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
16383
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 10 26 58 122 250 506 1018 2042 4090 8186 16378 8 12 28 60 124 252 508 1020 2044 4092 8188 16380 15 25 57 121 249 505 1017 2041 4089 8185 16...
result:
ok answer is 1
Test #51:
score: 0
Accepted
time: 2ms
memory: 3960kb
input:
32767
output:
YES 1 3 2 6 14 30 62 126 254 510 1022 2046 4094 8190 16382 32766 4 5 7 13 29 61 125 253 509 1021 2045 4093 8189 16381 32765 9 11 27 59 123 251 507 1019 2043 4091 8187 16379 32763 10 26 58 122 250 506 1018 2042 4090 8186 16378 32762 8 12 28 60 124 252 508 1020 2044 4092 8188 16380 32764 15 25 57 121 ...
result:
ok answer is 1
Test #52:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
399
output:
YES 1 3 2 6 14 30 62 126 254 4 5 7 13 29 61 125 253 9 11 27 59 123 251 10 26 58 122 250 8 12 28 60 124 252 15 25 57 121 249 17 19 51 115 243 18 50 114 242 22 54 118 246 23 55 119 247 21 53 117 245 20 52 116 244 16 24 56 120 248 31 49 113 241 33 35 99 227 34 98 226 38 102 230 39 103 231 37 101 229 36...
result:
ok answer is 1
Test #53:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
5757
output:
NO
result:
ok answer is 0
Test #54:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
179
output:
NO
result:
ok answer is 0
Test #55:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
228
output:
YES 1 3 2 6 14 30 62 126 4 5 7 13 29 61 125 9 11 27 59 123 10 26 58 122 8 12 28 60 124 15 25 57 121 17 19 51 115 18 50 114 22 54 118 23 55 119 21 53 117 20 52 116 16 24 56 120 31 49 113 33 35 99 227 34 98 226 38 102 39 103 37 101 36 100 228 44 108 45 109 47 111 46 110 42 106 43 107 41 105 40 104 32 ...
result:
ok answer is 1
Extra Test:
score: 0
Extra Test Passed