QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#683498#7679. Master of Both IVMartian148WA 72ms3756kbC++201.6kb2024-10-27 21:30:442024-10-27 21:30:45

Judging History

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

  • [2024-10-27 21:30:45]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:3756kb
  • [2024-10-27 21:30:44]
  • 提交

answer

#include <bits/stdc++.h>

constexpr int TP = 30;
constexpr int TT = 998244353;
using ll = long long;

struct AS {
    std::vector<int> p;
    AS() : p(TP, 0) {}
    void insert(int x, int &cnt) {
        for (int i = TP - 1; i >= 0; i--) {
            if (x >> i & 1) {
                if (!p[i]) {p[i] = x; return ;}
            }
            x ^= p[i];
        }
        if (x == 0) cnt += 1;
    }

    bool check (int x) {
        for (int i = TP - 1; i >= 0; i--) {
            if (x >> i & 1) x ^= p[i];
        }
        return x == 0;
    }
};

void solve() {
    int n; std::cin >> n;
    std::vector<int> a(n + 1, 0), f(n + 1, 0);
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = 2 * f[i - 1] % TT;

    for (int i = 1; i <= n; i++) std::cin >> a[i];
    int M = *std::max_element(a.begin(), a.end());
    std::vector<int> b(2 * n + 1, 0);
    std::vector<std::vector<int>> g(2 * n + 1);
    for (int i = 1; i <= n; i++) b[a[i]] += 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= 2 * n; j += i)
            g[j].push_back(i);

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        AS as;
        int now = 0;
        for (auto d : g[i]) {
            if (b[d] == 0) continue;
            now += b[d] - 1;
            as.insert(d, now);
        }
        if (as.check(i)) {
            ans = (ans + f[now]) % TT;
        }
    }

    std::cout << ans - 1 << '\n';
}

int main() {
    // std::ios::sync_with_stdio(false);
    // std::cin.tie(0); std::cout.tie(0);
    int T; std::cin >> T;
    while (T--) solve();
    return 0;
}

详细

Test #1:

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

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
11

result:

ok 2 number(s): "4 11"

Test #2:

score: -100
Wrong Answer
time: 72ms
memory: 3580kb

input:

40000
5
4 2 5 5 5
5
5 5 5 5 4
5
1 4 4 4 2
5
2 5 2 4 1
5
3 2 4 5 3
5
1 5 5 3 4
5
5 5 5 4 3
5
4 3 3 5 1
5
4 5 5 2 1
5
2 5 4 2 5
5
3 4 3 4 3
5
5 3 5 1 3
5
5 1 2 4 4
5
4 2 5 1 5
5
5 4 2 5 4
5
5 2 5 2 4
5
1 4 5 4 5
5
4 2 3 2 3
5
1 4 1 3 5
5
1 1 2 1 5
5
5 2 5 1 3
5
3 1 2 5 3
5
5 5 1 1 5
5
2 2 2 1 3
5
3 1 ...

output:

9
16
9
7
6
6
9
6
6
9
13
8
6
6
8
9
12
9
9
15
8
8
17
13
8
11
8
6
8
13
15
7
9
6
6
6
11
7
9
13
15
9
17
9
6
6
8
13
11
8
9
11
6
8
9
15
9
8
9
6
8
15
11
8
17
9
15
6
8
8
12
7
9
11
6
13
9
8
15
6
6
9
6
6
8
15
6
11
13
6
7
11
6
19
9
13
19
17
13
15
6
8
8
9
8
9
13
15
17
9
9
17
7
9
9
9
11
9
9
9
6
9
9
13
15
11
8
11
...

result:

wrong answer 4th numbers differ - expected: '9', found: '7'