# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582545 | 2022-06-24T05:06:32 Z | 조영욱(#8372) | Magic Tree (CEOI19_magictree) | C++17 | 66 ms | 42972 KB |
#include <bits/stdc++.h> using namespace std; int n,m,k; long long dp[100001][21]; vector<int> son[100001]; int t[100001]; int val[100001]; long long ans(int v,int d){ if (dp[v][d]!=-1) { return dp[v][d]; } long long ret=0; if (t[v]==d) { ret+=val[v]; } for(int i=0;i<son[v].size();i++){ long long temp=ans(son[v][i],d); if (t[son[v][i]]!=0) { temp=max(temp,ans(son[v][i],t[son[v][i]])); } ret+=temp; } return dp[v][d]=ret; } int main() { scanf("%d %d %d",&n,&m,&k); for(int i=2;i<=n;i++) { int p; scanf("%d",&p); son[p].push_back(i); } memset(dp,-1,sizeof(dp)); for(int i=0;i<m;i++) { int v,d,w; scanf("%d %d %d",&v,&d,&w); t[v]=d; val[v]=w; } printf("%lld",ans(1,k)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 50 ms | 42972 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 19156 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 66 ms | 21468 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 19540 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |