QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#304627 | #8004. Bit Component | ucup-team1631# | AC ✓ | 14ms | 5456kb | C++17 | 2.8kb | 2024-01-13 22:06:33 | 2024-01-13 22:06:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define elif else if
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>
#define repname(a, b, c, d, e, ...) e
#define rep(...) repname(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define rep0(x) for (int rep_counter = 0; rep_counter < (x); ++rep_counter)
#define rep1(i, x) for (int i = 0; i < (x); ++i)
#define rep2(i, l, r) for (int i = (l); i < (r); ++i)
#define rep3(i, l, r, c) for (int i = (l); i < (r); i += (c))
struct ScalarInput {
template<class T>
operator T(){
T ret;
cin >> ret;
return ret;
}
};
struct VectorInput {
size_t n;
VectorInput(size_t n): n(n) {}
template<class T>
operator vector<T>(){
vector<T> ret(n);
for(T &x : ret) cin >> x;
return ret;
}
};
ScalarInput input(){ return ScalarInput(); }
VectorInput input(size_t n){ return VectorInput(n); }
template<typename T>
void print(vector<T> a){
for(int i=0;i<a.size();i++){
cout<<a[i]<<" \n"[i+1==a.size()];
}
}
template<class T>
void print(T x){
cout << x << '\n';
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){
cout << head << ' ';
print(forward<Tail>(tail)...);
}
vector<int> make(int n);
vector<int> make2(int n);
vector<int> make(int n){
// n = 110000000...0001
assert(n>=7);
int B=0;
while((1<<B)<=n){
B+=1;
}
assert(n==((1<<(B-1)))+(1<<(B-2))+1);
if(n==7){
return {1, 3, 2, 6, 4, 5, 7};
}
vector<int>A=make2((1<<(B-1))-1);
A.push_back(n);
vector<int>C=make2((1<<(B-2))-1);
rep(i,C.size()){
A.push_back(C[i]+(1<<(B-1)));
}
A.push_back((1<<(B-1))+(1<<(B-2)));
return A;
}
vector<int>make2(int n){
// n=11111111
int B=0;
while((1<<B)<=n){
B+=1;
}
if(n==1){
return {1};
}
if(n==3){
return {1,3,2};
}
if(n==7){
return {1, 3, 2, 6, 4, 5, 7};
}
if(n<7){
print("NO");
return {};
}
int N=(1<<(B-1))+(1<<(B-2))+1;
if(n<N){
print("NO");
return {};
}
vector<int>A=make(N);
vector<int>C;
int L=(1<<(B-2))+2;
int R=1<<(B-1);
rep(i,N-1){
C.push_back(A[i]);
if(A[i]!=((1<<(B-1))-1)){
if((L<=A[i])&&(A[i]<R)&&(A[i]+(1<<(B-1)))<=n){
C.push_back(A[i]+(1<<(B-1)));
}
}
}
C.push_back((1<<(B-1)));
if(((1<<B)-1)==n){
C.push_back((1<<B)-1);
}
return C;
}
int main(){
//ios::sync_with_stdio(false);
//cin.tie(nullptr);
int n;
cin>>n;
vector<int>ans=make2(n);
if((int)ans.size()!=0){
print("YES");
print(ans);
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3472kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
3
output:
YES 1 3 2
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
7
output:
YES 1 3 2 6 4 5 7
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
13
output:
YES 1 3 2 6 4 5 7 13 9 11 10 12 8
result:
ok answer is 1
Test #14:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
14
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 12 8
result:
ok answer is 1
Test #15:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
15
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 12 8 15
result:
ok answer is 1
Test #16:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
16
output:
NO
result:
ok answer is 0
Test #17:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
17
output:
NO
result:
ok answer is 0
Test #18:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
23
output:
NO
result:
ok answer is 0
Test #19:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
24
output:
NO
result:
ok answer is 0
Test #20:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
25
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 12 8 15 25 17 19 18 22 20 21 23 24 16
result:
ok answer is 1
Test #21:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
26
output:
YES 1 3 2 6 14 4 5 7 13 9 11 10 26 12 8 15 25 17 19 18 22 20 21 23 24 16
result:
ok answer is 1
Test #22:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
27
output:
YES 1 3 2 6 14 4 5 7 13 9 11 27 10 26 12 8 15 25 17 19 18 22 20 21 23 24 16
result:
ok answer is 1
Test #23:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
40
output:
NO
result:
ok answer is 0
Test #24:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
53
output:
YES 1 3 2 6 14 30 4 5 7 13 29 9 11 27 10 26 12 28 8 15 25 17 19 51 18 50 22 20 52 21 53 23 24 16 31 49 33 35 34 38 46 36 37 39 45 41 43 42 44 40 47 48 32
result:
ok answer is 1
Test #25:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
93
output:
NO
result:
ok answer is 0
Test #26:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
105
output:
YES 1 3 2 6 14 30 62 4 5 7 13 29 61 9 11 27 59 10 26 58 12 28 60 8 15 25 57 17 19 51 18 50 22 54 20 52 21 53 23 55 24 56 16 31 49 33 35 99 34 98 38 102 46 36 100 37 101 39 103 45 41 105 43 42 44 40 104 47 48 32 63 97 65 67 66 70 78 94 68 69 71 77 93 73 75 91 74 90 76 92 72 79 89 81 83 82 86 84 85 87...
result:
ok answer is 1
Test #27:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
132
output:
NO
result:
ok answer is 0
Test #28:
score: 0
Accepted
time: 0ms
memory: 3424kb
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 12 28 60 124 8 15 25 57 121 17 19 51 115 18 50 114 22 54 118 20 52 116 21 53 117 23 55 119 24 56 120 16 31 49 113 33 35 99 34 98 38 102 46 110 36 100 37 101 39 103 45 109 41 105 43 107 42 106 44 108 40 104 47 111 48 112 32 63 97...
result:
ok answer is 1
Test #29:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
373
output:
NO
result:
ok answer is 0
Test #30:
score: 0
Accepted
time: 0ms
memory: 3428kb
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 12 28 60 124 252 8 15 25 57 121 249 17 19 51 115 243 18 50 114 242 22 54 118 246 20 52 116 244 21 53 117 245 23 55 119 247 24 56 120 248 16 31 49 113 241 33 35 99 227 34 98 226 38 102 230 46 110 238 36 100 228 37...
result:
ok answer is 1
Test #31:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
513
output:
NO
result:
ok answer is 0
Test #32:
score: 0
Accepted
time: 1ms
memory: 3436kb
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 12 28 60 124 252 508 8 15 25 57 121 249 505 17 19 51 115 243 499 18 50 114 242 498 22 54 118 246 502 20 52 116 244 500 21 53 117 245 501 23 55 119 247 503 24 56 120 248 504 16 31 49 113 241 497 33...
result:
ok answer is 1
Test #33:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
1356
output:
NO
result:
ok answer is 0
Test #34:
score: 0
Accepted
time: 1ms
memory: 3488kb
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 12 28 60 124 252 508 1020 8 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 20 52 116 244 500 1012 21 53 117 245 501 1013 23 5...
result:
ok answer is 1
Test #35:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
2263
output:
NO
result:
ok answer is 0
Test #36:
score: 0
Accepted
time: 1ms
memory: 3476kb
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 12 28 60 124 252 508 1020 2044 8 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 20 52...
result:
ok answer is 1
Test #37:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
4375
output:
NO
result:
ok answer is 0
Test #38:
score: 0
Accepted
time: 1ms
memory: 3652kb
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 12 28 60 124 252 508 1020 2044 4092 8 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: 3424kb
input:
10925
output:
NO
result:
ok answer is 0
Test #40:
score: 0
Accepted
time: 2ms
memory: 3552kb
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 12 28 60 124 252 508 1020 2044 4092 8188 8 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: 3424kb
input:
16893
output:
NO
result:
ok answer is 0
Test #42:
score: 0
Accepted
time: 0ms
memory: 3572kb
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 12 28 60 124 252 508 1020 2044 4092 8188 16380 8 15 25 57 121 249 505 1017 2041 4089 8185 16...
result:
ok answer is 1
Test #43:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
40092
output:
NO
result:
ok answer is 0
Test #44:
score: 0
Accepted
time: 4ms
memory: 3680kb
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 12 28 60 124 252 508 1020 2044 4092 8188 16380 32764 8 15 25 57 121 ...
result:
ok answer is 1
Test #45:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
88104
output:
NO
result:
ok answer is 0
Test #46:
score: 0
Accepted
time: 3ms
memory: 4480kb
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 12 28 60 124 252 508 1020 2044 4092 8188 163...
result:
ok answer is 1
Test #47:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
152797
output:
NO
result:
ok answer is 0
Test #48:
score: 0
Accepted
time: 14ms
memory: 5456kb
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 12 28 60 124 252...
result:
ok answer is 1
Test #49:
score: 0
Accepted
time: 1ms
memory: 3536kb
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 12 28 60 124 252 508 1020 2044 8 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 20 52...
result:
ok answer is 1
Test #50:
score: 0
Accepted
time: 2ms
memory: 3592kb
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 12 28 60 124 252 508 1020 2044 4092 8188 16380 8 15 25 57 121 249 505 1017 2041 4089 8185 16...
result:
ok answer is 1
Test #51:
score: 0
Accepted
time: 3ms
memory: 3596kb
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 12 28 60 124 252 508 1020 2044 4092 8188 16380 32764 8 15 25 57 121 ...
result:
ok answer is 1
Test #52:
score: 0
Accepted
time: 0ms
memory: 3476kb
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 12 28 60 124 252 8 15 25 57 121 249 17 19 51 115 243 18 50 114 242 22 54 118 246 20 52 116 244 21 53 117 245 23 55 119 247 24 56 120 248 16 31 49 113 241 33 35 99 227 34 98 226 38 102 230 46 110 238 36 100 228 37...
result:
ok answer is 1
Test #53:
score: 0
Accepted
time: 1ms
memory: 3424kb
input:
5757
output:
NO
result:
ok answer is 0
Test #54:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
179
output:
NO
result:
ok answer is 0
Test #55:
score: 0
Accepted
time: 0ms
memory: 3472kb
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 12 28 60 124 8 15 25 57 121 17 19 51 115 18 50 114 22 54 118 20 52 116 21 53 117 23 55 119 24 56 120 16 31 49 113 33 35 99 227 34 98 226 38 102 46 110 36 100 228 37 101 39 103 45 109 41 105 43 107 42 106 44 108 40 104 47 111 48 ...
result:
ok answer is 1
Extra Test:
score: 0
Extra Test Passed