Submission #388014

#TimeUsernameProblemLanguageResultExecution timeMemory
388014b00n0rpBiochips (IZhO12_biochips)C++17
100 / 100
295 ms399256 KiB
/* not my code. checking to submit whether the site is even working */ #include<bits/stdc++.h> using namespace std; int val[200001], m, t; vector<int> g[200001]; int dp[200001][501], par[200001]; void dfs(int c) { par[c] = t; for(int e : g[c]) dfs(e); for(int i=1;i<=m;i++) dp[t+1][i] = max(dp[t][i],dp[par[c]][i-1]+val[c]); t++; } int main() { int n, r; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { int p; scanf("%d%d",&p,val+i); if(!p) r = i; else g[p].push_back(i); } for(int i=1;i<=m;i++) dp[0][i] = -1e9; dfs(r); printf("%d\n",dp[n][m]); }

Compilation message (stderr)

biochips.cpp: In function 'int main()':
biochips.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
biochips.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |         scanf("%d%d",&p,val+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~
biochips.cpp:32:8: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |     dfs(r);
      |     ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...