QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305066#8004. Bit Componentucup-team992AC ✓11ms5488kbC++142.4kb2024-01-14 16:05:412024-01-14 16:05:42

Judging History

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

  • [2024-01-14 16:05:42]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:5488kb
  • [2024-01-14 16:05:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef int uci;
#define int long long
#define F first
#define S second
#define ar array

void solve(){
    int n;
    cin >> n;

    if(n == 1) {
        cout << "YES\n1\n"; return;
    }

    if(n == 3) {
        cout << "YES\n1 3 2\n"; return;
    }

    if(n == 7) {
        cout << "YES\n4 5 7 6 2 3 1\n"; return;
    }

    if(n == 6) {
        cout << "NO\n"; return;
    }


    int mg  = 1;
    while(n >= (1 << mg)) mg++;
    mg--;

    if(n >> (mg - 2) < 0b110) {
        cout << "NO\n";
        return;
    }

    vector<int> v;
    v.push_back(1);
    for(int i{2}; i <= mg-2; ++i){
        vector<int> ne;
        ne.push_back(1<<(i-1));
        for(int j = v.size()-1; j >= 0; --j){
            ne.push_back((1<<(i-1)) | v[j]);
        }
        for(int i : v)
            ne.push_back(i);
        v.swap(ne);
    }

    v.push_back(0);


    vector<int> res;

    int shft = mg - 2;

    if((0b110<<shft)+1 > n) {
        cout << "NO\n"; return;
    }

    if((0b111 << shft) <= n) res.push_back((0b111 << shft));
    res.push_back((0b100 << shft));
    res.push_back((0b110 << shft));
    res.push_back((0b010 << shft));
    res.push_back((0b011 << shft));
    res.push_back((0b001 << shft));

    reverse(v.begin(), v.end());
    for(auto x: v) res.push_back((0b101 << shft) | x);
    reverse(v.begin(), v.end());
    for(auto x: v) if(x) res.push_back((0b100 << shft) | x);

    reverse(v.begin(), v.end());
    for(auto x: v) {
        if(!x) continue;
        int a = (0b110 << shft) | x;
        if(a <= n) res.push_back(a);
        int b = (0b111 << shft) | x;
        if(b <= n) res.push_back(b);
        res.push_back((0b010 << shft) | x);
    }

    reverse(v.begin(), v.end());
    for(auto x: v) if(x) res.push_back((0b011 << shft) | x);
    reverse(v.begin(), v.end());
    for(auto x: v) if(x) res.push_back((0b001 << shft) | x);
    reverse(v.begin(),v.end());
    for(auto x:v) if(x) res.push_back(x);
    
    
    /*cout << "DBG\n";
    for(auto x: res) {
        bitset<10> b(x);
        cout << b << endl;
    }

    set<int> S;
    for(auto x: res) S.insert(x);
    cout << S.size() << " " << res.size() << endl;*/

    cout << "YES\n";
    for(int i : res)
        cout << i << ' ';
    cout << '\n';
}

uci main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

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

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

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

input:

4

output:

NO

result:

ok answer is 0

Test #5:

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

input:

5

output:

NO

result:

ok answer is 0

Test #6:

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

input:

6

output:

NO

result:

ok answer is 0

Test #7:

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

input:

7

output:

YES
4 5 7 6 2 3 1

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

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

input:

9

output:

NO

result:

ok answer is 0

Test #10:

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

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

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

result:

ok answer is 1

Test #14:

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

input:

14

output:

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

result:

ok answer is 1

Test #15:

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

input:

15

output:

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

result:

ok answer is 1

Test #16:

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

input:

16

output:

NO

result:

ok answer is 0

Test #17:

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

input:

17

output:

NO

result:

ok answer is 0

Test #18:

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

input:

23

output:

NO

result:

ok answer is 0

Test #19:

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

input:

24

output:

NO

result:

ok answer is 0

Test #20:

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

input:

25

output:

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

result:

ok answer is 1

Test #21:

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

input:

26

output:

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

result:

ok answer is 1

Test #22:

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

input:

27

output:

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

result:

ok answer is 1

Test #23:

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

input:

40

output:

NO

result:

ok answer is 0

Test #24:

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

input:

53

output:

YES
32 48 16 24 8 40 41 43 42 46 47 45 44 36 37 39 38 34 35 33 49 17 51 19 50 18 22 23 53 21 52 20 28 29 31 30 26 27 25 9 11 10 14 15 13 12 4 5 7 6 2 3 1 

result:

ok answer is 1

Test #25:

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

input:

93

output:

NO

result:

ok answer is 0

Test #26:

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

input:

105

output:

YES
64 96 32 48 16 80 81 83 82 86 87 85 84 92 93 95 94 90 91 89 88 72 73 75 74 78 79 77 76 68 69 71 70 66 67 65 97 33 99 35 98 34 102 38 103 39 101 37 100 36 44 45 47 46 42 43 105 41 104 40 56 57 59 58 62 63 61 60 52 53 55 54 50 51 49 17 19 18 22 23 21 20 28 29 31 30 26 27 25 24 8 9 11 10 14 15 13 1...

result:

ok answer is 1

Test #27:

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

input:

132

output:

NO

result:

ok answer is 0

Test #28:

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

input:

221

output:

YES
128 192 64 96 32 160 161 163 162 166 167 165 164 172 173 175 174 170 171 169 168 184 185 187 186 190 191 189 188 180 181 183 182 178 179 177 176 144 145 147 146 150 151 149 148 156 157 159 158 154 155 153 152 136 137 139 138 142 143 141 140 132 133 135 134 130 131 129 193 65 195 67 194 66 198 70...

result:

ok answer is 1

Test #29:

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

input:

373

output:

NO

result:

ok answer is 0

Test #30:

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

input:

473

output:

YES
448 256 384 128 192 64 320 321 323 322 326 327 325 324 332 333 335 334 330 331 329 328 344 345 347 346 350 351 349 348 340 341 343 342 338 339 337 336 368 369 371 370 374 375 373 372 380 381 383 382 378 379 377 376 360 361 363 362 366 367 365 364 356 357 359 358 354 355 353 352 288 289 291 290 2...

result:

ok answer is 1

Test #31:

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

input:

513

output:

NO

result:

ok answer is 0

Test #32:

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

input:

934

output:

YES
896 512 768 256 384 128 640 641 643 642 646 647 645 644 652 653 655 654 650 651 649 648 664 665 667 666 670 671 669 668 660 661 663 662 658 659 657 656 688 689 691 690 694 695 693 692 700 701 703 702 698 699 697 696 680 681 683 682 686 687 685 684 676 677 679 678 674 675 673 672 736 737 739 738 ...

result:

ok answer is 1

Test #33:

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

input:

1356

output:

NO

result:

ok answer is 0

Test #34:

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

input:

1651

output:

YES
1024 1536 512 768 256 1280 1281 1283 1282 1286 1287 1285 1284 1292 1293 1295 1294 1290 1291 1289 1288 1304 1305 1307 1306 1310 1311 1309 1308 1300 1301 1303 1302 1298 1299 1297 1296 1328 1329 1331 1330 1334 1335 1333 1332 1340 1341 1343 1342 1338 1339 1337 1336 1320 1321 1323 1322 1326 1327 1325...

result:

ok answer is 1

Test #35:

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

input:

2263

output:

NO

result:

ok answer is 0

Test #36:

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

input:

3330

output:

YES
2048 3072 1024 1536 512 2560 2561 2563 2562 2566 2567 2565 2564 2572 2573 2575 2574 2570 2571 2569 2568 2584 2585 2587 2586 2590 2591 2589 2588 2580 2581 2583 2582 2578 2579 2577 2576 2608 2609 2611 2610 2614 2615 2613 2612 2620 2621 2623 2622 2618 2619 2617 2616 2600 2601 2603 2602 2606 2607 26...

result:

ok answer is 1

Test #37:

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

input:

4375

output:

NO

result:

ok answer is 0

Test #38:

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

input:

7989

output:

YES
7168 4096 6144 2048 3072 1024 5120 5121 5123 5122 5126 5127 5125 5124 5132 5133 5135 5134 5130 5131 5129 5128 5144 5145 5147 5146 5150 5151 5149 5148 5140 5141 5143 5142 5138 5139 5137 5136 5168 5169 5171 5170 5174 5175 5173 5172 5180 5181 5183 5182 5178 5179 5177 5176 5160 5161 5163 5162 5166 5...

result:

ok answer is 1

Test #39:

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

input:

10925

output:

NO

result:

ok answer is 0

Test #40:

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

input:

14097

output:

YES
8192 12288 4096 6144 2048 10240 10241 10243 10242 10246 10247 10245 10244 10252 10253 10255 10254 10250 10251 10249 10248 10264 10265 10267 10266 10270 10271 10269 10268 10260 10261 10263 10262 10258 10259 10257 10256 10288 10289 10291 10290 10294 10295 10293 10292 10300 10301 10303 10302 10298 ...

result:

ok answer is 1

Test #41:

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

input:

16893

output:

NO

result:

ok answer is 0

Test #42:

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

input:

28913

output:

YES
28672 16384 24576 8192 12288 4096 20480 20481 20483 20482 20486 20487 20485 20484 20492 20493 20495 20494 20490 20491 20489 20488 20504 20505 20507 20506 20510 20511 20509 20508 20500 20501 20503 20502 20498 20499 20497 20496 20528 20529 20531 20530 20534 20535 20533 20532 20540 20541 20543 2054...

result:

ok answer is 1

Test #43:

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

input:

40092

output:

NO

result:

ok answer is 0

Test #44:

score: 0
Accepted
time: 4ms
memory: 3956kb

input:

54980

output:

YES
32768 49152 16384 24576 8192 40960 40961 40963 40962 40966 40967 40965 40964 40972 40973 40975 40974 40970 40971 40969 40968 40984 40985 40987 40986 40990 40991 40989 40988 40980 40981 40983 40982 40978 40979 40977 40976 41008 41009 41011 41010 41014 41015 41013 41012 41020 41021 41023 41022 410...

result:

ok answer is 1

Test #45:

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

input:

88104

output:

NO

result:

ok answer is 0

Test #46:

score: 0
Accepted
time: 6ms
memory: 4432kb

input:

106284

output:

YES
65536 98304 32768 49152 16384 81920 81921 81923 81922 81926 81927 81925 81924 81932 81933 81935 81934 81930 81931 81929 81928 81944 81945 81947 81946 81950 81951 81949 81948 81940 81941 81943 81942 81938 81939 81937 81936 81968 81969 81971 81970 81974 81975 81973 81972 81980 81981 81983 81982 81...

result:

ok answer is 1

Test #47:

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

input:

152797

output:

NO

result:

ok answer is 0

Test #48:

score: 0
Accepted
time: 11ms
memory: 5488kb

input:

200000

output:

YES
131072 196608 65536 98304 32768 163840 163841 163843 163842 163846 163847 163845 163844 163852 163853 163855 163854 163850 163851 163849 163848 163864 163865 163867 163866 163870 163871 163869 163868 163860 163861 163863 163862 163858 163859 163857 163856 163888 163889 163891 163890 163894 16389...

result:

ok answer is 1

Test #49:

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

input:

3073

output:

YES
2048 3072 1024 1536 512 2560 2561 2563 2562 2566 2567 2565 2564 2572 2573 2575 2574 2570 2571 2569 2568 2584 2585 2587 2586 2590 2591 2589 2588 2580 2581 2583 2582 2578 2579 2577 2576 2608 2609 2611 2610 2614 2615 2613 2612 2620 2621 2623 2622 2618 2619 2617 2616 2600 2601 2603 2602 2606 2607 26...

result:

ok answer is 1

Test #50:

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

input:

16383

output:

YES
14336 8192 12288 4096 6144 2048 10240 10241 10243 10242 10246 10247 10245 10244 10252 10253 10255 10254 10250 10251 10249 10248 10264 10265 10267 10266 10270 10271 10269 10268 10260 10261 10263 10262 10258 10259 10257 10256 10288 10289 10291 10290 10294 10295 10293 10292 10300 10301 10303 10302 ...

result:

ok answer is 1

Test #51:

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

input:

32767

output:

YES
28672 16384 24576 8192 12288 4096 20480 20481 20483 20482 20486 20487 20485 20484 20492 20493 20495 20494 20490 20491 20489 20488 20504 20505 20507 20506 20510 20511 20509 20508 20500 20501 20503 20502 20498 20499 20497 20496 20528 20529 20531 20530 20534 20535 20533 20532 20540 20541 20543 2054...

result:

ok answer is 1

Test #52:

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

input:

399

output:

YES
256 384 128 192 64 320 321 323 322 326 327 325 324 332 333 335 334 330 331 329 328 344 345 347 346 350 351 349 348 340 341 343 342 338 339 337 336 368 369 371 370 374 375 373 372 380 381 383 382 378 379 377 376 360 361 363 362 366 367 365 364 356 357 359 358 354 355 353 352 288 289 291 290 294 2...

result:

ok answer is 1

Test #53:

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

input:

5757

output:

NO

result:

ok answer is 0

Test #54:

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

input:

179

output:

NO

result:

ok answer is 0

Test #55:

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

input:

228

output:

YES
224 128 192 64 96 32 160 161 163 162 166 167 165 164 172 173 175 174 170 171 169 168 184 185 187 186 190 191 189 188 180 181 183 182 178 179 177 176 144 145 147 146 150 151 149 148 156 157 159 158 154 155 153 152 136 137 139 138 142 143 141 140 132 133 135 134 130 131 129 193 225 65 195 227 67 1...

result:

ok answer is 1

Extra Test:

score: 0
Extra Test Passed