QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801395#9745. 递增序列PhoenixRebirthWA 40ms3968kbC++231.1kb2024-12-06 22:39:102024-12-06 22:39:12

Judging History

This is the latest submission verdict.

  • [2024-12-06 22:39:12]
  • Judged
  • Verdict: WA
  • Time: 40ms
  • Memory: 3968kb
  • [2024-12-06 22:39:10]
  • Submitted

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;
            }
        } else {
            if (must[b] == 1) break;
        }
    }
    printf("%lld\n", ans);
}

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

详细

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 40ms
memory: 3848kb

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
510484198710881603
414708220571820990
716398192192370637
0
1949654914769743
0
0
0
811009189367843522
0
0
0
114457959388827197
53638684746708804
0
0
91540211282631658
0
694703231769895639
264473874823767485
0
0
0
0
478559426710059802
65333152962117910
753346372609875092
180143985...

result:

wrong answer 3rd lines differ - expected: '432345564227567616', found: '510484198710881603'