QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#792688#4564. Digital Circuit_8_8_#Compile Error//C++201.3kb2024-11-29 13:00:372024-11-29 13:00:37

Judging History

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

  • [2024-11-29 13:00:37]
  • 评测
  • [2024-11-29 13:00:37]
  • 提交

answer

#include "circuit.h"

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
const int N = (int)1e5 + 12, MOD = 1000002022;

int n, m, f, a[N];
vector<ll> g[N], dp[N], tdp[N];
void add(int &x, int y) {
    x += y;
    x %= MOD;
}
ll pd[N][2];
void dfs(int v) {
    if(v >= n) {
        pd[v][a[v]] = 1;
        pd[v][1 - a[v]] = 0;
        return;
    }
    for(int to : g[v]) {
        dfs(to);
    }
    pd[v][0] = ((pd[g[v][0]][0] * pd[g[v][1]][0]) % MOD * 2ll % MOD + pd[x][0] * pd[y][1] % MOD  + pd[x][1] * pd[y][0] % MOD) % MOD;
    int x = g[v][0], y = g[v][1];
    pd[v][1] = (pd[x][0] * pd[y][1] % MOD  + pd[x][1] * pd[y][0] % MOD + pd[x][1] * pd[y][1] % MOD * 2ll % MOD) % MOD;
}
void init(int32_t NN, int32_t MM, std::vector<int32_t> P, std::vector<int32_t> A) {
    n = NN;
    m = MM;
    f = n + m;
    for(int i = n; i < f; i++) {
        a[i] = A[i - n];
    }
    for(int i = 1; i < f; i++) {
        g[P[i]].push_back(i);
    }

    for(int i = 0; i < f; i++) {
        dp[i].resize((int)g[i].size() + 1);
        tdp[i].resize((int)g[i].size() + 1);
    }
}

int32_t count_ways(int32_t L, int32_t R) {
    if(n > 1000) return 0;
    for(int i = L; i <= R; i++) {
        a[i] ^= 1;
    }
    dfs(0);
    assert(pd[0][1] >= 0);
    return pd[0][1];
}

詳細信息

answer.code: In function ‘void dfs(ll)’:
answer.code:26:74: error: ‘x’ was not declared in this scope
   26 |     pd[v][0] = ((pd[g[v][0]][0] * pd[g[v][1]][0]) % MOD * 2ll % MOD + pd[x][0] * pd[y][1] % MOD  + pd[x][1] * pd[y][0] % MOD) % MOD;
      |                                                                          ^
answer.code:26:85: error: ‘y’ was not declared in this scope
   26 |     pd[v][0] = ((pd[g[v][0]][0] * pd[g[v][1]][0]) % MOD * 2ll % MOD + pd[x][0] * pd[y][1] % MOD  + pd[x][1] * pd[y][0] % MOD) % MOD;
      |                                                                                     ^