Submission #899389

# Submission time Handle Problem Language Result Execution time Memory
899389 2024-01-06T01:53:38 Z 12345678 Magic Tree (CEOI19_magictree) C++17
34 / 100
2000 ms 33872 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e5+5, kx=21;
ll n, m, k, t[nx], w[nx], p, dp[nx][kx], x, ans, vl;
vector<int> d[nx];

void dfs(int u)
{
    for (auto v:d[u]) 
    {
        dfs(v);
        vl=0;
        for (int i=1; i<=k; i++) vl=max(vl, dp[v][i]), dp[u][i]+=vl;
    }
    dp[u][t[u]]+=w[u];
    for (int i=1; i<=k; i++) ans=max(ans, dp[u][i]);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m>>k;
    for (int i=2; i<=n; i++) cin>>p, d[p].push_back(i);
    for (int i=1; i<=m; i++) cin>>x>>t[x]>>w[x];
    dfs(1);
    cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2067 ms 23176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 24292 KB Output is correct
2 Correct 45 ms 24428 KB Output is correct
3 Correct 48 ms 28364 KB Output is correct
4 Correct 23 ms 22996 KB Output is correct
5 Correct 34 ms 33872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4748 KB Output is correct
10 Correct 44 ms 23644 KB Output is correct
11 Correct 39 ms 23632 KB Output is correct
12 Correct 41 ms 27724 KB Output is correct
13 Correct 25 ms 22236 KB Output is correct
14 Correct 33 ms 33052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2003 ms 7516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4748 KB Output is correct
10 Incorrect 3 ms 4900 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4748 KB Output is correct
10 Execution timed out 2067 ms 23176 KB Time limit exceeded
11 Halted 0 ms 0 KB -