답안 #898914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898914 2024-01-05T09:02:33 Z vjudge1 Magic Tree (CEOI19_magictree) C++17
15 / 100
39 ms 19572 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);
    }

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

    if (k > 2)
        cout << poop << '\n';
    else
    {
        Init();
        cout << sum[1][2] + dp[1] << '\n';
    }

    return (0 ^ 0);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 9048 KB Output is correct
2 Correct 17 ms 9312 KB Output is correct
3 Correct 29 ms 8460 KB Output is correct
4 Correct 26 ms 8408 KB Output is correct
5 Correct 33 ms 8784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 9372 KB Output is correct
2 Correct 39 ms 10644 KB Output is correct
3 Correct 36 ms 14672 KB Output is correct
4 Correct 24 ms 9428 KB Output is correct
5 Correct 37 ms 19572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 7004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -