Submission #673333

#TimeUsernameProblemLanguageResultExecution timeMemory
673333smartmonkyBiochips (IZhO12_biochips)C++14
10 / 100
248 ms290980 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int long long using namespace std; void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} const int N = 200005; vector <int> g[N]; int coast[N], dp[500][N]; int m; void dfs(int v){ for(auto to : g[v]){ dfs(to); for(int i = m; i > 0; i--){ dp[i][v] = max(dp[i - 1][v] + dp[1][to], dp[i][v]); } } dp[1][v] = max(dp[1][v], coast[v]); } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //fp("game"); int n; cin >> n >> m; int ind = -1; for(int i = 0; i < n; i++){ int a, b; cin >> a >> b; coast[i + 1] = b; if(a == 0){ ind = i + 1; continue; } g[a].pb(i + 1); } dfs(ind); cout << dp[m][ind]; }

Compilation message (stderr)

biochips.cpp:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      | ^~~~
biochips.cpp: In function 'void fp(std::string)':
biochips.cpp:12:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
biochips.cpp:12:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...