QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745349#9745. 递增序列hhoppitree#RE 1ms3800kbC++171.2kb2024-11-14 09:21:292024-11-14 09:21:29

Judging History

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

  • [2024-11-14 09:21:29]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3800kb
  • [2024-11-14 09:21:29]
  • 提交

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 < m; ++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: 1ms
memory: 3800kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Runtime Error

input:

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

output:


result: