Submission #874099

#TimeUsernameProblemLanguageResultExecution timeMemory
874099itslqFriend (IOI14_friend)C++17
8 / 100
1046 ms560 KiB
#include <bits/stdc++.h> using namespace std; vector<int> children[1005]; int dp(int w[], int id, bool t) { int s = 0; if (t == 0) { for (int c: children[id]) { s += max(dp(w, c, 1), dp(w, c, 0)); } } else { s += w[id]; for (int c: children[id]) { s += dp(w, c, 0); } } return s; } int findSample(int n, int confidence[], int host[], int protocol[]) { if (protocol[1] == 0) { for (int i = 1; i < n; i++) children[host[i]].push_back(i); return max(dp(confidence, 0, 0), dp(confidence, 0, 1)); } else if (protocol[1] == 2) { int m = -1; for (int i = 0; i < n; i++) m = max(m, confidence[i]); return m; } }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
#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...