Submission #898891

# Submission time Handle Problem Language Result Execution time Memory
898891 2024-01-05T08:47:22 Z vjudge1 Magic Tree (CEOI19_magictree) C++17
0 / 100
32 ms 9296 KB
// Parsa Jokar 2023 https://github.com/phictus/ioi

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

constexpr int64_t maxn = 100000;
int64_t n, m, k, fruitType[maxn + 1], fruitCount[maxn + 1], sum[maxn + 1][3], dp[maxn + 1];
vector<int64_t> adj[maxn + 1];

void Init(int64_t v = 1)
{
    sum[v][fruitType[v]] += fruitCount[v];
    for (int64_t u : adj[v])
    {
        Init(u);

        sum[v][1] += sum[u][1];
        sum[v][2] += sum[u][2];

        dp[v] += max(sum[u][1] - sum[u][2], dp[u]);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> k;
    for (int64_t i = 2; i <= n; i++)
    {
        int64_t p;
        cin >> p;
        adj[p].push_back(i);
    }

    for (int64_t i = 1; i < m; i++)
    {
        int64_t v;
        cin >> v;
        cin >> fruitType[v] >> fruitCount[v];
    }

    Init();
    cout << sum[1][2] + dp[1] << '\n';

    return (0 ^ 0);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 9208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 9296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -