QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#794060#9745. 递增序列pengpeng_fudan#AC ✓129ms5816kbC++231.4kb2024-11-30 10:23:592024-11-30 10:23:59

Judging History

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

  • [2024-11-30 10:23:59]
  • 评测
  • 测评结果:AC
  • 用时:129ms
  • 内存:5816kb
  • [2024-11-30 10:23:59]
  • 提交

answer

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

#define endl '\n'

#define maxn 200005
#define maxlgn 62

int64_t a[maxn];
int choice[maxn];
int64_t suf[maxlgn];

void solve(int t, int l, int r) {
    if (t == -1 || l == r) return;
    int x = -1;
    for (int i = l; i < r; i++)
        if ((a[i] >> t & 1) ^ (a[i + 1] >> t & 1)) {
            if (~x) return choice[t] = 0, void();
            x = i;
        }
    if (!~x) return solve(t - 1, l, r);
    choice[t] &= (1 << (a[x] >> t & 1));
    return solve(t - 1, l, x), solve(t - 1, x + 1, r);
}

void solve(void) {
    int n;
    int64_t k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int t = maxlgn - 1; ~t; t--) choice[t] = 3;
    solve(maxlgn - 1, 1, n);
    for (int i = 0; i < maxlgn; i++)
        if (!choice[i]) return cout << 0 << endl, void();

    suf[0] = 1;
    for (int i = 1; i < maxlgn; i++) suf[i] = suf[i - 1] * __builtin_popcount(choice[i - 1]);

    int64_t ans = 0;
    for (int i = maxlgn - 1; ~i; i--) {
        bool t = (k >> i & 1);
        if (t && (choice[i] & 1)) ans += suf[i];
        if (!(choice[i] >> t & 1)) break;
        if (!i) ans++;
    }

    cout << ans << endl;

    return;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);

    int _ = 1;
    cin >> _;
    while (_--) solve();

    return 0;
}

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

详细

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

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

input:

36156
2 732025001343805266
563399128172323734 55283226774627822
7 388099190813067712
564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124
2 798714574862593347
426890163990834364 434764725667883272
1 414708220571820990
42...

output:

288230376151711744
0
432345564227567616
414708220571820991
716398192192370638
0
1949654914769744
0
0
0
811009189367843523
0
0
0
114457959388827198
36028797018963968
0
0
91540211282631659
0
694703231769895640
144115188075855872
0
0
0
0
432345564227567616
65333152962117911
753346372609875093
180143985...

result:

ok 36156 lines

Test #3:

score: 0
Accepted
time: 49ms
memory: 3600kb

input:

66700
5 574806949
707283080 678928379 541095440 909663418 934562284
2 131740903
1072092807 29505236
1 288553982
996051310
3 327852411
555539857 562077878 310330495
5 43708614
467258834 418367471 258444521 166976259 1064316226
4 128498668
513637339 62151118 158694610 650278927
2 351983999
4118288 333...

output:

33554432
0
288553983
0
0
0
268435456
0
149009740
386781916
437566564
385875968
0
315141961
271302559
33554432
0
0
0
95224229
129359372
134217728
134217728
268435456
0
67108864
33554432
0
0
0
268435456
0
0
134217728
67108864
268435456
212106049
67108864
0
268435456
4450845
268435456
0
67108864
378512...

result:

ok 66700 lines

Test #4:

score: 0
Accepted
time: 28ms
memory: 3628kb

input:

36360
1 96
43
4 13
34 87 65 66
10 19
30 15 3 46 37 35 84 82 83 74
9 4
52 54 49 62 46 31 8 85 85
5 11
47 60 16 125 73
2 82
41 86
6 53
96 106 117 88 37 54
4 88
25 85 70 116
6 77
2 7 10 15 83 79
4 93
41 35 10 121
3 54
39 49 73
8 14
10 1 18 59 62 61 66 89
9 66
58 39 26 17 122 117 107 97 98
9 95
29 23 0 ...

output:

97
0
0
0
0
64
0
16
8
16
32
2
4
4
0
0
6
15
79
31
2
0
64
4
4
0
4
6
4
3
0
8
9
8
0
8
0
4
30
0
2
4
4
24
2
4
4
0
2
48
4
2
0
4
13
0
0
32
47
8
0
2
0
21
8
0
0
0
0
4
42
0
16
0
2
64
8
22
16
4
4
32
16
0
0
0
8
0
14
42
29
0
16
8
0
0
0
8
28
71
0
33
16
8
6
4
4
28
0
0
32
4
8
32
82
0
0
0
0
85
16
0
16
19
32
1
4
32
0
1...

result:

ok 36360 lines

Test #5:

score: 0
Accepted
time: 14ms
memory: 5200kb

input:

1
200000 4
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

0

result:

ok single line: '0'

Test #6:

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

input:

1
200000 170
408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408...

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 21ms
memory: 5784kb

input:

1
200000 865898207
813061125 813060760 813056420 813065756 813044547 813049132 813096759 813104748 813103010 813099954 813099388 813080206 813087339 813083402 813082054 813126093 813135656 813129901 813112581 813106621 813121334 813161524 813156690 813155689 813166817 813152106 813146154 812932793 8...

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 18ms
memory: 5136kb

input:

1
200000 204004633456461606
140585709987022702 140591222689166069 140589443726417847 140569943876420335 140565211705149786 140579123983064963 140574687350108660 140574227989465667 140561299482230788 140561248496502165 140556758205037855 140555876365018861 140555729099813644 140555527709799406 140529...

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 10ms
memory: 3792kb

input:

10
9092 903484882148114775
945224776187726245 945249102315576398 945740164177255354 945755815755331821 944765514684436089 944789829155862751 945029343139320849 944077945003077800 944603199987672827 943588903411119994 943650217976656715 943654845686402074 943831888859620789 943877390496700551 9438919...

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 lines

Test #10:

score: 0
Accepted
time: 25ms
memory: 5224kb

input:

1
200000 1000000000000000000
912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 912954724688635084 91295...

output:

1000000000000000001

result:

ok single line: '1000000000000000001'

Test #11:

score: 0
Accepted
time: 30ms
memory: 3608kb

input:

36443
2 887238880391385543
186840099224039318 973399140606519790
5 504927100392638164
568175051373885523 705908225889926215 955216216552140192 358102685018388209 393270275152119765
4 712866624471897419
772741350131704368 694532512465769074 228697933799994740 769093572950716383
1 243875334929773269
3...

output:

576460752303423488
0
0
243875334929773270
0
0
350588512234613783
72461902449893496
0
0
0
0
144115188075855872
765435324537744903
263239629977978757
0
288230376151711744
0
0
0
0
236312543599276923
288230376151711744
116208538605021457
0
333965201073611904
17880911370513824
732354939621419085
0
863664...

result:

ok 36443 lines

Test #12:

score: 0
Accepted
time: 38ms
memory: 3628kb

input:

66494
5 24611696
609808222 774951366 969207354 944307052 638007341
1 987051555
792379226
4 616804483
221993815 853380560 223698778 567420246
1 659348027
603781014
2 83623237
446867845 693980492
2 771771336
152211873 535937538
4 653442771
250470126 232510675 426087912 369236225
4 394191348
482990248 ...

output:

0
987051556
0
659348028
83623238
503335881
67108864
0
791013379
0
401813136
421313965
538235352
0
0
811376194
743242497
728253450
251230343
0
0
402653184
134217728
0
0
333763321
0
0
402653184
517517963
268435456
0
0
0
0
268435456
268435456
238128892
0
0
0
0
0
536870912
0
0
431653316
817497020
0
0
26...

result:

ok 66494 lines

Test #13:

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

input:

36415
1 97
44
5 27
63 63 74 95 92
5 18
70 78 2 72 57
4 48
31 86 79 19
3 55
28 63 4
10 41
3 1 61 96 11 96 27 53 47 85
8 16
20 56 7 40 60 61 66 20
6 87
71 58 23 84 8 2
1 51
95
4 39
12 83 64 21
6 97
28 64 92 17 20 25
9 30
22 48 67 25 19 58 87 24 96
1 27
41
8 21
49 24 52 83 11 72 55 0
2 24
49 41
1 40
2
...

output:

98
8
0
0
0
0
0
0
52
0
0
0
28
0
9
41
0
0
0
0
64
0
32
90
0
2
0
0
0
16
0
9
0
0
0
0
0
78
0
0
0
0
30
0
52
0
0
68
0
0
55
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
64
0
0
0
0
0
74
20
21
0
52
25
0
0
0
0
0
0
17
2
0
18
0
0
0
0
0
0
0
0
33
53
0
0
0
87
0
7
0
0
0
0
0
0
0
0
0
0
16
0
0
0
0
70
0
19
0
0
0
0
30
22
0
0
0
8
0
0
0...

result:

ok 36415 lines

Test #14:

score: 0
Accepted
time: 13ms
memory: 5112kb

input:

1
197393 8
2 5 0 7 0 7 1 5 7 0 0 3 0 1 2 4 4 8 2 7 8 4 6 5 10 9 2 2 9 6 7 8 9 6 2 10 1 5 2 9 2 5 6 6 6 0 10 3 7 0 3 4 10 1 7 7 7 8 10 10 10 1 4 6 6 10 4 2 4 2 8 3 6 8 5 1 4 3 6 0 2 8 8 6 3 9 5 8 9 0 7 0 9 4 2 8 4 3 0 1 1 3 3 0 3 6 7 10 0 7 3 3 4 0 2 7 8 10 8 0 4 7 7 7 3 8 3 5 4 0 2 3 2 5 9 4 8 3 4 2...

output:

0

result:

ok single line: '0'

Test #15:

score: 0
Accepted
time: 18ms
memory: 5116kb

input:

1
190948 587724539061098378
784858586192471176 907632914707456141 138774188174722545 786123842253718211 985478614552067569 484534600343738433 148059951173155877 483743983652730481 592903979723236920 223987960456137015 219448618804614295 860266487779947426 926736818826167349 112856109668452339 199326...

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 26ms
memory: 5176kb

input:

1
197550 1000000000000000000
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 10000000000...

output:

1000000000000000001

result:

ok single line: '1000000000000000001'

Test #17:

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

input:

200000
1 703211364141151431
387486532616633981
1 523785290437545965
840750859630589581
1 281617778070370680
972321034942325905
1 817078478645521271
51391669923360532
1 535526695388184125
357952973902082491
1 878516649800941451
555179636346595807
1 651589827675226224
959845490903193693
1 568817471044...

output:

703211364141151432
523785290437545966
281617778070370681
817078478645521272
535526695388184126
878516649800941452
651589827675226225
568817471044026337
370345874293646933
999311795970050289
438563422416071978
933936877468949342
301609714341578408
774562761747101791
573983016893592523
518119180261890...

result:

ok 200000 lines

Test #18:

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

input:

200000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000
1 1000000000000000000
1000000000000000000...

output:

1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
1000000000000000001
...

result:

ok 200000 lines

Test #19:

score: 0
Accepted
time: 13ms
memory: 3712kb

input:

10
16642 19612017798034797
77058030376299664 77056646331426970 77054552317878978 77070504579380213 77071207086488643 77077869066878220 77072485492249217 77071815526880948 77085772338657823 77089377799579939 77099216555126517 77121003447276352 76985285761485196 76992800293969850 77009745239211518 770...

output:

0
0
1073741824
1073741824
0
0
0
2147483648
0
0

result:

ok 10 lines

Test #20:

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

input:

10
13903 78864095736997158
119327852045929587 119322529399030695 119325201587461236 119222258571628956 119223511810458437 119228234976795676 119213349774493356 119213307286062573 119209262047379053 119217148746737511 119218666591661459 119258875363303106 119262809854482000 119269457330575599 1192744...

output:

268435456
4294967296
1073741824
536870912
536870912
268435456
1073741824
8589934592
0
68719476736

result:

ok 10 lines

Extra Test:

score: 0
Extra Test Passed