Submission #723633

# Submission time Handle Problem Language Result Execution time Memory
723633 2023-04-14T06:43:50 Z dxz05 Magic Tree (CEOI19_magictree) C++17
22 / 100
94 ms 32404 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define MP make_pair
const int N = 100500;

vector<int> g[N];

int dp[N][30];
pair<int, int> fruit[N];

void dfs(int v){
    dp[v][fruit[v].first] = fruit[v].second;

    for (int u : g[v]){
        dfs(u);
    }

    for (int t = 1; t <= 20; t++){
        for (int u : g[v]){
            dp[v][t] += *max_element(dp[u], dp[u] + t + 1);
        }
    }
}

void solve(){
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 2; i <= n; i++){
        int p;
        cin >> p;
        g[p].push_back(i);
    }

    for (int i = 0; i < m; i++){
        int v, d, w;
        cin >> v >> d >> w;
        fruit[v] = MP(d, w);
    }

    dfs(1);

    cout << *max_element(dp[1], dp[1] + 30) << endl;

}

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 53 ms 32404 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 16820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 86 ms 16816 KB Output is correct
11 Correct 89 ms 16776 KB Output is correct
12 Correct 94 ms 19540 KB Output is correct
13 Correct 58 ms 15652 KB Output is correct
14 Correct 56 ms 22988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 5588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Incorrect 2 ms 2900 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Runtime error 53 ms 32404 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -