QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350288#8004. Bit Componentucup-team004#AC ✓5ms5720kbC++201.6kb2024-03-10 16:45:512024-03-10 16:45:51

Judging History

你现在查看的是最新测评结果

  • [2024-03-10 16:45:51]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:5720kb
  • [2024-03-10 16:45:51]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using namespace std;
const int N=300005;
int n,q,fa[N];
vector<int> v[N];
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define pb push_back
vector<int> f(int n){
    if(n==0)return {};
    if(n==1)return {1};
    auto t=f(n/2),tt=t;
    int w=n/2+1;
    reverse(tt.begin(),tt.end());
    for(auto i:tt)t.pb(i+w);
    t.pb(w);
    return t;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin>>n;
    auto ans=f(7);
    //for(auto i:ans)cout<<i<<" "; return 0;
    if(n==1||n==3)ans=f(n);
    else{
        int t=log2(n),gb=(1<<t)+(1<<(t-1))+1;
        if(n<gb){
            puts("NO");
            return 0;
        }else{
            auto f1=f((1<<(t-1))-1),f2=f((1<<t)-1);
            f2.pop_back(); f2.pop_back(); f2.pb((1<<(t-1))+1);
            f2.pb(gb);
            for(auto i:f1)f2.pb(i+(1<<t));
            //for(auto i:f2)cerr<<i<<" "; cerr<<endl;
            ans={};
            for(auto i:f2){
                ans.pb(i);
                if((i>gb-(1<<t))&&i<=n-(1<<t)){
                    ans.pb(i+(1<<t));
                }
                if(i==(1<<(t-1))+(1<<(t-2))){ans.pb((1<<(t-1))); ans.pb((1<<(t-1))+(1<<t));}
            }
            ans.pb((1<<t));
        }
    }
    cout<<"YES\n";
    For(i,0,ans.size()-1)cout<<ans[i]<<(i==ans.size()-1?'\n':' ');
}
/*
14
1 3 2 6 7 5 4 pkuicpc2@pkuicpc:~/20240310$ cd "/home/pkuicpc2/20240310/" && g++ b.cpp -o b && "/home/pkuicpc2/20240310/"b
14
1 3 2 6 7 4 12 5 13 9 11 10 
1 3 2 6 14 7 4 12 5 13 9 11 10 8
*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3508kb

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

2

output:

NO

result:

ok answer is 0

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

4

output:

NO

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

5

output:

NO

result:

ok answer is 0

Test #6:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

6

output:

NO

result:

ok answer is 0

Test #7:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

7

output:

YES
1 3 2 6 7 5 4

result:

ok answer is 1

Test #8:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

8

output:

NO

result:

ok answer is 0

Test #9:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

9

output:

NO

result:

ok answer is 0

Test #10:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

10

output:

NO

result:

ok answer is 0

Test #11:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

11

output:

NO

result:

ok answer is 0

Test #12:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

12

output:

NO

result:

ok answer is 0

Test #13:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

13

output:

YES
1 3 2 6 4 12 7 5 13 9 11 10 8

result:

ok answer is 1

Test #14:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

14

output:

YES
1 3 2 6 14 4 12 7 5 13 9 11 10 8

result:

ok answer is 1

Test #15:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

15

output:

YES
1 3 2 6 14 4 12 7 15 5 13 9 11 10 8

result:

ok answer is 1

Test #16:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

16

output:

NO

result:

ok answer is 0

Test #17:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

17

output:

NO

result:

ok answer is 0

Test #18:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

23

output:

NO

result:

ok answer is 0

Test #19:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

24

output:

NO

result:

ok answer is 0

Test #20:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

25

output:

YES
1 3 2 6 7 5 4 12 8 24 13 15 14 10 11 9 25 17 19 18 22 23 21 20 16

result:

ok answer is 1

Test #21:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

26

output:

YES
1 3 2 6 7 5 4 12 8 24 13 15 14 10 26 11 9 25 17 19 18 22 23 21 20 16

result:

ok answer is 1

Test #22:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

27

output:

YES
1 3 2 6 7 5 4 12 8 24 13 15 14 10 26 11 27 9 25 17 19 18 22 23 21 20 16

result:

ok answer is 1

Test #23:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

40

output:

NO

result:

ok answer is 0

Test #24:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

53

output:

YES
1 3 2 6 7 5 4 12 13 15 14 10 11 9 8 24 16 48 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

result:

ok answer is 1

Test #25:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

93

output:

NO

result:

ok answer is 0

Test #26:

score: 0
Accepted
time: 1ms
memory: 3656kb

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 32 96 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...

result:

ok answer is 1

Test #27:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

132

output:

NO

result:

ok answer is 0

Test #28:

score: 0
Accepted
time: 1ms
memory: 3760kb

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 64 192 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 1...

result:

ok answer is 1

Test #29:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

373

output:

NO

result:

ok answer is 0

Test #30:

score: 0
Accepted
time: 1ms
memory: 3764kb

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: 1ms
memory: 3888kb

input:

513

output:

NO

result:

ok answer is 0

Test #32:

score: 0
Accepted
time: 1ms
memory: 3836kb

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: 1ms
memory: 3652kb

input:

1356

output:

NO

result:

ok answer is 0

Test #34:

score: 0
Accepted
time: 1ms
memory: 3648kb

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: 1ms
memory: 3540kb

input:

2263

output:

NO

result:

ok answer is 0

Test #36:

score: 0
Accepted
time: 1ms
memory: 3880kb

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: 1ms
memory: 3736kb

input:

4375

output:

NO

result:

ok answer is 0

Test #38:

score: 0
Accepted
time: 1ms
memory: 3672kb

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: 1ms
memory: 3820kb

input:

10925

output:

NO

result:

ok answer is 0

Test #40:

score: 0
Accepted
time: 1ms
memory: 3740kb

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: 1ms
memory: 3624kb

input:

16893

output:

NO

result:

ok answer is 0

Test #42:

score: 0
Accepted
time: 2ms
memory: 3984kb

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: 1ms
memory: 3888kb

input:

40092

output:

NO

result:

ok answer is 0

Test #44:

score: 0
Accepted
time: 3ms
memory: 4072kb

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: 1ms
memory: 3676kb

input:

88104

output:

NO

result:

ok answer is 0

Test #46:

score: 0
Accepted
time: 2ms
memory: 4512kb

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: 1ms
memory: 3816kb

input:

152797

output:

NO

result:

ok answer is 0

Test #48:

score: 0
Accepted
time: 5ms
memory: 5720kb

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: 1ms
memory: 3620kb

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: 2ms
memory: 3676kb

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: 3988kb

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: 1ms
memory: 3680kb

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: 1ms
memory: 3820kb

input:

5757

output:

NO

result:

ok answer is 0

Test #54:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

179

output:

NO

result:

ok answer is 0

Test #55:

score: 0
Accepted
time: 0ms
memory: 3816kb

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 64 192 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 1...

result:

ok answer is 1

Extra Test:

score: 0
Extra Test Passed