QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290664#6231. 起床困难综合症MoRanSky100 ✓25ms4792kbC++23750b2023-12-25 06:20:482023-12-25 06:20:48

Judging History

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

  • [2023-12-25 06:20:48]
  • 评测
  • 测评结果:100
  • 用时:25ms
  • 内存:4792kb
  • [2023-12-25 06:20:48]
  • 提交

answer

#include <cstdio>
#include <iostream>

using namespace std;

const int N = 100005;

int n, m;

char op[N][5];

int t[N];

void inline work(char opt[], int &v, int d) {
    if (opt[0] == 'O') v |= d;
    else if (opt[0] == 'A') v &= d;
    else v ^= d;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s%d", op[i], &t[i]);
    int ans = 0;
    for (int i = 30; ~i; i--) {
        bool ok = true;
        int v0 = 0, v1 = 1;
        for (int j = 1; j <= n; j++)
            work(op[j], v0, t[j] >> i & 1), work(op[j], v1, t[j] >> i & 1);
        if (v0) ans |= 1 << i;
        else if (v1 && m >= (1 << i)) ans |= 1 << i, m -= 1 << i;
    }
    printf("%d\n", ans);
    return 0;
}
 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

95 0
AND 767
XOR 72
XOR 376
AND 1015
OR 32
XOR 992
AND 1019
XOR 648
OR 264
AND 735
OR 36
AND 1023
XOR 987
OR 268
AND 723
OR 256
OR 296
OR 40
OR 288
XOR 201
AND 1015
AND 979
XOR 38
AND 1019
AND 1015
OR 12
XOR 918
OR 268
OR 292
AND 991
OR 8
XOR 255
AND 755
XOR 134
AND 735
AND 759
XOR 458
OR 300
AND 75...

output:

940

result:

ok 1 number(s): "940"

Test #2:

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

input:

986 136
AND 957
AND 619
OR 432
OR 7
AND 521
AND 924
OR 326
OR 35
OR 212
XOR 331
OR 338
AND 557
OR 145
OR 86
AND 728
XOR 167
OR 5
XOR 107
OR 400
OR 37
XOR 318
AND 714
AND 715
XOR 216
AND 603
XOR 948
AND 954
AND 730
AND 907
OR 263
XOR 776
XOR 848
AND 623
AND 587
XOR 941
XOR 763
XOR 689
OR 179
OR 244
X...

output:

203

result:

ok 1 number(s): "203"

Test #3:

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

input:

903 906
XOR 204
OR 455
XOR 514
XOR 606
XOR 999
AND 480
AND 632
XOR 120
OR 449
OR 653
XOR 573
OR 713
XOR 379
AND 890
AND 48
AND 44
AND 309
AND 703
OR 220
AND 316
OR 595
OR 386
OR 533
AND 484
XOR 227
AND 674
OR 661
XOR 595
XOR 724
XOR 906
XOR 863
XOR 728
XOR 38
XOR 32
AND 104
AND 1000
AND 480
OR 648
A...

output:

511

result:

ok 1 number(s): "511"

Test #4:

score: 10
Accepted
time: 25ms
memory: 4580kb

input:

97092 93581
OR 68909
AND 111418
AND 41917
XOR 99282
XOR 10458
AND 62037
XOR 19531
OR 3073
AND 61426
AND 42943
OR 16559
XOR 63853
XOR 28239
AND 124629
AND 46999
OR 2179
OR 67907
AND 61180
XOR 47408
XOR 7087
XOR 5880
AND 44694
OR 89418
XOR 50409
XOR 19254
OR 5483
XOR 99643
XOR 55681
OR 5515
XOR 27024
...

output:

9382

result:

ok 1 number(s): "9382"

Test #5:

score: 10
Accepted
time: 10ms
memory: 4792kb

input:

99222 32963
XOR 68308
XOR 47555
XOR 45053
XOR 77617
XOR 56215
XOR 2028
XOR 68992
XOR 30441
XOR 11846
XOR 93552
XOR 43300
XOR 76462
XOR 3606
XOR 11701
XOR 43353
XOR 38755
XOR 85404
XOR 95385
XOR 68417
XOR 82029
XOR 96614
XOR 13499
XOR 13665
XOR 67922
XOR 7764
XOR 78332
XOR 99675
XOR 41668
XOR 84162
X...

output:

131071

result:

ok 1 number(s): "131071"

Test #6:

score: 10
Accepted
time: 25ms
memory: 4740kb

input:

98308 98395
XOR 77821
XOR 15362
OR 12517
XOR 47294
OR 7062
XOR 60596
OR 65652
XOR 88840
AND 34191
OR 78249
XOR 35644
OR 84789
AND 34594
AND 101878
OR 23284
XOR 58276
XOR 75983
OR 90280
AND 50572
OR 96485
OR 4952
OR 12497
AND 54937
OR 31623
AND 101931
AND 114091
AND 52865
AND 34558
OR 26918
XOR 28682...

output:

44459

result:

ok 1 number(s): "44459"

Test #7:

score: 10
Accepted
time: 11ms
memory: 4716kb

input:

90419 310984152
AND 992857623
AND 326463285
AND 859634153
AND 321845875
AND 921558717
AND 930044916
AND 375816054
AND 465366535
AND 381679644
AND 398350542
AND 841318374
AND 980252977
AND 853863762
AND 331246663
AND 870599973
AND 863960120
AND 385796797
AND 310378161
AND 921009423
AND 514817164
AND ...

output:

304367616

result:

ok 1 number(s): "304367616"

Test #8:

score: 10
Accepted
time: 25ms
memory: 4668kb

input:

96017 17382677
OR 916710986
AND 202611135
XOR 946458103
XOR 779637239
OR 892363296
XOR 389494106
OR 239274570
AND 366645917
AND 649690607
OR 453524488
OR 917004098
XOR 243213360
AND 547049151
XOR 262324133
XOR 434195396
XOR 31552267
XOR 914675328
AND 857393575
OR 904093498
AND 617349837
XOR 14693876...

output:

84677543

result:

ok 1 number(s): "84677543"

Test #9:

score: 10
Accepted
time: 17ms
memory: 4580kb

input:

79414 218066470
XOR 439273946
XOR 163467919
XOR 216093181
AND 955766119
OR 126363841
XOR 591805669
AND 955776894
XOR 46837932
OR 33581145
XOR 559548955
XOR 920834537
XOR 420698737
OR 33571392
OR 532552
OR 100673664
OR 59261072
AND 972537767
XOR 512006551
XOR 814937092
XOR 81285139
XOR 83548273
XOR 7...

output:

805289471

result:

ok 1 number(s): "805289471"

Test #10:

score: 10
Accepted
time: 25ms
memory: 4640kb

input:

92647 665522854
AND 644152866
XOR 807591487
XOR 808699462
XOR 252071755
OR 371065298
AND 977628810
AND 745404093
OR 589174936
OR 832438529
AND 744224386
OR 185213376
XOR 822634525
AND 668098252
OR 733063339
AND 384825184
XOR 867103476
XOR 939782395
XOR 90343157
OR 639377445
XOR 215975812
OR 71625738...

output:

1073741823

result:

ok 1 number(s): "1073741823"

Extra Test:

score: 0
Extra Test Passed