QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#142694#4564. Digital CircuitQwerty1232#Compile Error//C++202.3kb2023-08-19 18:01:242024-07-04 02:40:21

Judging History

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

  • [2024-07-04 02:40:21]
  • 评测
  • [2023-08-19 18:01:24]
  • 提交

answer

#pragma GCC optimize("O3")
#pragma GCC target("avx512vl,avx512dq,avx512bw")
#include "circuit.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>

constexpr int mod = 1e9 + 2022;
int add(int a, int b) {
    return a + b - mod * (a + b >= mod);
}
int mul(int a, int b) {
    return a * 1ULL * b % mod;
}

int n, m;
std::vector<int> prv;
std::vector<uint> data;
std::vector<int> all;
std::vector<uint> shit;
std::vector<std::vector<int>> nxt;

// void count() {
//     for (int i = n - 1; i >= 0; i--) {
//         int all = 1, sum = 0;
//         for (int id = 0; id < nxt[i].size(); id++) {
//             int t = nxt[i][id];
//             int s = dp[t][0];

//             sum = add(mul(sum, s), mul(all, dp[t][1]));
//             all = mul(all, s);
//         }

//         all = mul(all, nxt[i].size());
//         dp[i] = {all, sum};
//     }
// }

void init(int n, int m, std::vector<int> P, std::vector<int> A) {
    ::n = n;
    ::m = m;
    prv = P;
    data.resize(m);
    for (int i = 0; i < m; i++) {
        if (A[i]) {
            data[i] = uint(-1);
        }
    }

    all.assign(n + m, 1);
    nxt.resize(n);
    for (int i = 1; i < n + m; i++) {
        nxt[prv[i]].push_back(i);
    }
    for (int i = n - 1; i >= 0; i--) {
        int& s = all[i];
        for (int t : nxt[i]) {
            s = mul(s, all[t]);
        }
        s = mul(s, nxt[i].size());
    }
    shit.assign(m, 0);

    auto fuck = [&](auto fuck, int i, int val) {
        if (i >= n) {
            shit[i - n] = val;
            return;
        }
        int g = nxt[i].size();
        std::vector<int> prf(g + 1, 1), suf(g + 1, 1);
        for (int j = 0; j < g; j++) {
            prf[j + 1] = mul(prf[j], all[nxt[i][j]]);
            suf.rbegin()[j + 1] = mul(suf.rbegin()[j], all[nxt[i].rbegin()[j]]);
        }
        for (int j = 0; j < g; j++) {
            int t = nxt[i][j];
            fuck(fuck, t, mul(val, mul(prf[j], suf[j + 1])));
        }
    };
    fuck(fuck, 0, 1);
}

int count_ways(int L, int R) {
    L -= n;
    R -= n;
    R++;
    for (int i = L; i < R; i++) {
        data[i] ^= uint32_t(-1);
    }

    int64_t sum = 0;
    for (int i = 0; i < m; i++) {
        sum += shit[i] & data[i];
    }
    sum %= mod;
    return sum;
}

詳細信息

answer.code: In function ‘int count_ways(int, int)’:
answer.code:91:20: error: ‘uint32_t’ was not declared in this scope
   91 |         data[i] ^= uint32_t(-1);
      |                    ^~~~~~~~
answer.code:9:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    8 | #include <iostream>
  +++ |+#include <cstdint>
    9 | #include <vector>