QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49195#4592. Theramoreckiseki#Compile Error//C++2.9kb2022-09-19 18:03:252022-09-19 18:03:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-19 18:03:28]
  • 评测
  • [2022-09-19 18:03:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
const int mod = 1000000007;
const int maxn = 200025;

int modadd(int a, int b) {
    a += b;
    return a >= mod ? a - mod : a;
}
int modsub(int a, int b) {
    a -= b;
    return a < 0 ? a + mod : a;
}
int modmul(int64_t a, int64_t b) {
    return static_cast<int>(a * b % mod);
}

vector<int> g[maxn];
vector<tuple<int,int,int>> evt[maxn];

int sz[maxn], mxs[maxn];
int df_in[maxn], df_cnt, df_ord[maxn];
void dfs_size(int i) {
    df_in[i] = df_cnt;
    df_ord[df_cnt] = i;
    ++df_cnt;
    sz[i] = 1;
    mxs[i] = -1;
    for (int j: g[i]) {
        dfs_size(j);
        sz[i] += sz[j];
        if (mxs[i] == -1 || sz[mxs[i]] < sz[j])
            mxs[i] = j;
    }
}

struct DS {
    int prod[maxn];
    int zcnt[maxn];
    int cp1_p[maxn];
    int suf1_p[maxn];
    void clear() {
        ;
    }
} ds;

void dfs(int i, bool clear) {
    for (int j: g[i]) {
        if (j != mxs[i])
            dfs(j, true);
    }
    if (mxs[i] != -1) {
        dfs(mxs[i], false);
    }
    // TODO add i to DS

    vector<tuple<int,int,int>> other;
    vector<vector<tuple<int,int,int>>> subs;
    for (int j: g[i]) {
        if (j != mxs[i]) {
            vector<tuple<int,int,int>> sub;
            for (int t = 0; t < sz[j]; t++) {
                int x = df_ord[df_in[j] + t];
                for (auto [t, c, p]: evt[x]) {
                    other.emplace_back(t, c, p);
                    sub.emplace_back(t, c, p);
                }
            }
            subs.emplace_back(sub);
        }
    }

    {
        sort(other.begin(), other.end());
        int prod = 1;
        for (int i = int(other.size()) - 1; i >= 0; i--) {
            auto [t, c, p] = other[i];
            int tt = i ? get<0>(other[i-1]) : 0;
            prod = modmul(prod, modsub(1, p));
            ans = modadd(ans, modmul(prod, /*TODO*/)); // DS::query(cp1_p, [tt, t) )
        }
    }

    for (auto [t, c, p]: other) {
        // TODO add (t, c, p) to DS
    }

    for (auto &sub: subs) {
        sort(sub.begin(), sub.end());
        for (auto [t, c, p]: sub) {
            // TODO remove (t, c, p) to DS
        }
        int prod = 1;
        for (int i = int(sub.size()) - 1; i >= 0; i--) {
            auto [t, c, p] = sub[i];
            ans = modadd(ans, modmul(modmul(modmul(c, p), prod), /*TODO*/)); // DS::query(suf1_p, [t, ))
            prod = modmul(prod, modsub(1, p));
        }
        for (auto [t, c, p]: sub) {
            // TODO add (t, c, p) to DS
        }
    }

    if (clear) {
        // BIT.clear();
    }
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        for (int i = 2; i <= n; i++) {
            int f;
            cin >> f;
            g[f].push_back(i);
        }

        for (int i = 1; i <= m; i++) {
            int x, c, p;
            cin >> x >> c >> p;
            evt[x].emplace_back(i, c, p);
        }
    }
    return 0;
}

Details

answer.code: In function ‘void dfs(int, bool)’:
answer.code:81:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   81 |             ans = modadd(ans, modmul(prod, /*TODO*/)); // DS::query(cp1_p, [tt, t) )
      |             ^~~
      |             abs
answer.code:81:52: error: expected primary-expression before ‘)’ token
   81 |             ans = modadd(ans, modmul(prod, /*TODO*/)); // DS::query(cp1_p, [tt, t) )
      |                                                    ^
answer.code:97:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   97 |             ans = modadd(ans, modmul(modmul(modmul(c, p), prod), /*TODO*/)); // DS::query(suf1_p, [t, ))
      |             ^~~
      |             abs
answer.code:97:74: error: expected primary-expression before ‘)’ token
   97 |             ans = modadd(ans, modmul(modmul(modmul(c, p), prod), /*TODO*/)); // DS::query(suf1_p, [t, ))
      |                                                                          ^