QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305170 | #8004. Bit Component | ucup-team266# | AC ✓ | 10ms | 4624kb | C++14 | 1.8kb | 2024-01-14 19:51:04 | 2024-01-14 19:51:05 |
Judging History
answer
/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest
9. module on time
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
void print(int x)
{
for(int i=9;i>=0;i--)
{
if(x&(1<<i)) cout<<"1";
else cout<<"0";
}
cout<<"\n";
}
void solve()
{
int n;
cin>>n;
if(n==1)
{
cout<<"YES\n1\n";
return;
}
if(n==3)
{
cout<<"YES\n1 3 2\n";
return;
}
int lg=0;
while((1<<lg)<n) lg++;
if((1<<lg)==n)
{
cout<<"NO\n";
return;
}
lg--;
if(n<=(1<<lg)+(1<<(lg-1)))
{
cout<<"NO\n";
return;
}
vector <int> vec;
vec.pb(0);
for(int i=0;i<lg;i++)
{
for(int j=vec.size()-1;j>=0;j--) vec.pb(vec[j]+(1<<i));
}
int pat=(1<<lg)+(1<<(lg-1));
vector <int> ans;
for(int i=1;i<vec.size();i++) if(vec[i]!=(1<<(lg-1)))
{
ans.pb(vec[i]);
if(vec[i]+(1<<lg)>pat&&vec[i]+(1<<lg)<=n) ans.pb(vec[i]+(1<<lg));
}
for(int i=1;i<(1<<(lg-1));i++) ans.pb(vec[i]+(1<<lg));
ans.pb(1<<lg),ans.pb(pat),ans.pb(1<<(lg-1));
cout<<"YES\n";
for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
cout<<"\n";
// for(int i=0;i<ans.size();i++) print(ans[i]);
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int _=1;
// cin>>_;
while(_--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
1
output:
YES 1
result:
ok answer is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2
output:
NO
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
3
output:
YES 1 3 2
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4
output:
NO
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5
output:
NO
result:
ok answer is 0
Test #6:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
6
output:
NO
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
7
output:
YES 1 3 7 5 4 6 2
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
8
output:
NO
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
9
output:
NO
result:
ok answer is 0
Test #10:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
10
output:
NO
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
11
output:
NO
result:
ok answer is 0
Test #12:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
12
output:
NO
result:
ok answer is 0
Test #13:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
13
output:
YES 1 3 2 6 7 5 13 9 11 10 8 12 4
result:
ok answer is 1
Test #14:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
14
output:
YES 1 3 2 6 14 7 5 13 9 11 10 8 12 4
result:
ok answer is 1
Test #15:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
15
output:
YES 1 3 2 6 14 7 15 5 13 9 11 10 8 12 4
result:
ok answer is 1
Test #16:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
16
output:
NO
result:
ok answer is 0
Test #17:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
17
output:
NO
result:
ok answer is 0
Test #18:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
23
output:
NO
result:
ok answer is 0
Test #19:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
24
output:
NO
result:
ok answer is 0
Test #20:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
25
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 25 17 19 18 22 23 21 20 16 24 8
result:
ok answer is 1
Test #21:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
26
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 26 11 9 25 17 19 18 22 23 21 20 16 24 8
result:
ok answer is 1
Test #22:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
27
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 26 11 27 9 25 17 19 18 22 23 21 20 16 24 8
result:
ok answer is 1
Test #23:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
40
output:
NO
result:
ok answer is 0
Test #24:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
53
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 52 21 53 23 22 18 50 19 51 17 49 33 35 34 38 39 37 36 44 45 47 46 42 43 41 40 32 48 16
result:
ok answer is 1
Test #25:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
93
output:
NO
result:
ok answer is 0
Test #26:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
105
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 104 41 105 43 42 46 47 45 44 36 100 37 101 39 103 38 102 34 98 35 99 33 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 83...
result:
ok answer is 1
Test #27:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
132
output:
NO
result:
ok answer is 0
Test #28:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
221
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #29:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
373
output:
NO
result:
ok answer is 0
Test #30:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
473
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #31:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
513
output:
NO
result:
ok answer is 0
Test #32:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
934
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #33:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
1356
output:
NO
result:
ok answer is 0
Test #34:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1651
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #35:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2263
output:
NO
result:
ok answer is 0
Test #36:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3330
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #37:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4375
output:
NO
result:
ok answer is 0
Test #38:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
7989
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #39:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
10925
output:
NO
result:
ok answer is 0
Test #40:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
14097
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #41:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
16893
output:
NO
result:
ok answer is 0
Test #42:
score: 0
Accepted
time: 2ms
memory: 3828kb
input:
28913
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #43:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
40092
output:
NO
result:
ok answer is 0
Test #44:
score: 0
Accepted
time: 3ms
memory: 3776kb
input:
54980
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #45:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
88104
output:
NO
result:
ok answer is 0
Test #46:
score: 0
Accepted
time: 5ms
memory: 4024kb
input:
106284
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #47:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
152797
output:
NO
result:
ok answer is 0
Test #48:
score: 0
Accepted
time: 10ms
memory: 4624kb
input:
200000
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #49:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
3073
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #50:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
16383
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #51:
score: 0
Accepted
time: 2ms
memory: 3772kb
input:
32767
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #52:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
399
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 97 99 98 102 103 101 100 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 117 119 118 114 115 ...
result:
ok answer is 1
Test #53:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5757
output:
NO
result:
ok answer is 0
Test #54:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
179
output:
NO
result:
ok answer is 0
Test #55:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
228
output:
YES 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 25 27 26 30 31 29 28 20 21 23 22 18 19 17 16 48 49 51 50 54 55 53 52 60 61 63 62 58 59 57 56 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 32 96 224 97 225 99 227 98 226 102 103 101 100 228 108 109 111 110 106 107 105 104 120 121 123 122 126 127 125 124 116 ...
result:
ok answer is 1
Extra Test:
score: 0
Extra Test Passed