# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211239 | 2020-03-19T16:25:46 Z | Lawliet | Magic Tree (CEOI19_magictree) | C++14 | 2000 ms | 24568 KB |
#include <bits/stdc++.h> using namespace std; const int MAXK = 30; const int MAXN = 100010; int n, m, k; int t[MAXN]; int w[MAXN]; int dp[MAXN][MAXK]; vector< int > adj[MAXN]; void DFS(int cur) { for(int i = 0 ; i < adj[cur].size() ; i++) DFS( adj[cur][i] ); for(int j = 1 ; j <= k ; j++) { int sum = 0; if( t[cur] == j ) sum = w[cur]; for(int i = 0 ; i < adj[cur].size() ; i++) sum += dp[ adj[cur][i] ][j]; dp[cur][j] = max( dp[cur][j - 1] , sum ); } } int main() { scanf("%d %d %d",&n,&m,&k); for(int i = 2 ; i <= n ; i++) { int p; scanf("%d",&p); adj[p].push_back( i ); } for(int i = 1 ; i <= m ; i++) { int node; scanf("%d",&node); scanf("%d %d",&t[node],&w[node]); } DFS( 1 ); printf("%d\n",dp[1][k]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 33 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2094 ms | 17784 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2944 KB | Output is correct |
2 | Correct | 10 ms | 2944 KB | Output is correct |
3 | Correct | 10 ms | 2944 KB | Output is correct |
4 | Execution timed out | 2085 ms | 14032 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 90 ms | 18936 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 33 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Correct | 103 ms | 18296 KB | Output is correct |
11 | Correct | 94 ms | 18300 KB | Output is correct |
12 | Correct | 85 ms | 21112 KB | Output is correct |
13 | Correct | 69 ms | 16876 KB | Output is correct |
14 | Correct | 71 ms | 24568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2088 ms | 5880 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 33 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Correct | 10 ms | 2944 KB | Output is correct |
11 | Correct | 10 ms | 2944 KB | Output is correct |
12 | Correct | 10 ms | 2944 KB | Output is correct |
13 | Execution timed out | 2085 ms | 14032 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 33 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Execution timed out | 2094 ms | 17784 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |