Submission #1095755

#TimeUsernameProblemLanguageResultExecution timeMemory
1095755alexander707070Magic Tree (CEOI19_magictree)C++14
34 / 100
85 ms40764 KiB
#include<bits/stdc++.h> #define MAXN 100007 using namespace std; int n,m,k,p[MAXN],a,d,w; pair<int,int> cost[MAXN]; vector<int> v[MAXN]; long long dp[MAXN][27]; bool vis[MAXN][27]; long long ff(int x,int day){ if(vis[x][day])return dp[x][day]; vis[x][day]=true; if(day==cost[x].first)dp[x][day]+=cost[x].second; for(int i=0;i<v[x].size();i++){ dp[x][day]+=ff(v[x][i],day); } if(day>1)dp[x][day]=max(dp[x][day],ff(x,day-1)); return dp[x][day]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m>>k; for(int i=2;i<=n;i++){ cin>>p[i]; v[p[i]].push_back(i); } for(int i=1;i<=m;i++){ cin>>a>>d>>w; cost[a]={d,w}; } cout<<ff(1,20)<<"\n"; return 0; }

Compilation message (stderr)

magictree.cpp: In function 'long long int ff(int, int)':
magictree.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<v[x].size();i++){
      |              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...