QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#801396#9745. 递增序列PhoenixRebirthWA 35ms3844kbC++231.2kb2024-12-06 22:40:022024-12-06 22:40:03

Judging History

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

  • [2024-12-06 22:40:03]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:3844kb
  • [2024-12-06 22:40:02]
  • 提交

answer

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

#define ll long long

const int N = 200005;

ll a[N], K;
int must[60], n;

void sc() {
    memset(must, -1, sizeof(must));
    scanf("%d%lld", &n, &K);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i < n; i++) {
        ll t = a[i] ^ a[i + 1];
        if (t == 0) continue;
        int pos = 63 - __builtin_clzll(t);
        int p = (a[i] >> pos & 1 ? 1 : 0);
        if (must[pos] != -1 && must[pos] != p) {
            puts("0");
            return;
        }
        must[pos] = p;
    }
    
    ll ans = 0;
    for (int b = 59; b >= 0; b--) {
        if (K >> b & 1) {
            // 0 free
            if (must[b] != 1) {
                ll power = 1;
                for (int a = b - 1; a >= 0; a--)
                    if (must[a] == -1)
                        power *= 2;
                ans += power;
            }
            if (must[b] == 0) break;
        } else {
            if (must[b] == 1) break;
        }
    }
    printf("%lld\n", ans);
}

int main() {
    int T; scanf("%d", &T);
    while (T--) sc();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 35ms
memory: 3796kb

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
414708220571820990
716398192192370637
0
1949654914769743
0
0
0
811009189367843522
0
0
0
114457959388827197
36028797018963968
0
0
91540211282631658
0
694703231769895639
144115188075855872
0
0
0
0
432345564227567616
65333152962117910
753346372609875092
180143985...

result:

wrong answer 4th lines differ - expected: '414708220571820991', found: '414708220571820990'