QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745351#9745. 递增序列hhoppitree#WA 55ms3900kbC++171.2kb2024-11-14 09:21:522024-11-14 09:21:53

Judging History

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

  • [2024-11-14 09:21:53]
  • 评测
  • 测评结果:WA
  • 用时:55ms
  • 内存:3900kb
  • [2024-11-14 09:21:52]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

long long a[N], b[60], m, f[60];

long long calc(int x, int y) {
    if (!~x) return 1;
    if (!y && ~f[x]) return f[x];
    long long res = 0;
    int L = ((m >> x) & 1);
    for (int i = 0; i <= (y ? L : 1); ++i) {
        if (~b[x] && i != b[x]) continue;
        res += calc(x - 1, y && (i == L));
    }
    if (!y) f[x] = res;
    return res;
}

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        int n;
        scanf("%d%lld", &n, &m);
        for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
        for (int i = 0; i < 60; ++i) b[i] = -1;
        int fl = 1;
        for (int i = 1; i < n; ++i) {
            if (a[i] == a[i + 1]) continue;
            for (int j = 59; ~j; --j) {
                if (((a[i] ^ a[i + 1]) >> j) & 1) {
                    if ((a[i] >> j) & 1) {
                        fl &= (b[j] != 0), b[j] = 1;
                    } else {
                        fl &= (b[j] != 1), b[j] = 0;
                    }
                    break;
                }
            }
        }
        memset(f, -1, sizeof(f));
        printf("%lld\n", calc(59, 1));
    }
    return 0;
}

詳細信息

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 55ms
memory: 3900kb

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
18014398509481984
0
0
811009189367843523
0
75691510499104990
0
114457959388827198
36028797018963968
0
72057594037927936
91540211282631659
18014398509481984
694703231769895640
144115188075855872
0
3602879...

result:

wrong answer 8th lines differ - expected: '0', found: '18014398509481984'