제출 #296639

#제출 시각아이디문제언어결과실행 시간메모리
296639emil_physmath친구 (IOI14_friend)C++17
35 / 100
3 ms2816 KiB
#include <algorithm> #include <numeric> #include <vector> #include "friend.h" using namespace std; using llong = long long; const int maxN = 100'005; vector<int> chld[maxN]; enum Protocol { ME = 0, MY = 1, WE = 2 }; pair<int, int> SolveTree(int v, int* a) { pair<int, int> res(a[v], 0); for (int to: chld[v]) { pair<int, int> cur = SolveTree(to, a); res.first += cur.second; res.second += max(cur.first, cur.second); } return res; } // Find out best sample int findSample(int n, int a[], int host[], int prot[]){ if (count(prot + 1, prot + n, ME) == n - 1) { for (int i = 1; i < n; ++i) chld[host[i]].push_back(i); auto p = SolveTree(0, a); return max(p.first, p.second); } if (count(prot + 1, prot + n, MY) == n - 1) return accumulate(a, a + n, 0); if (count(prot + 1, prot + n, WE) == n - 1) return *max_element(a, a + n); }

컴파일 시 표준 에러 (stderr) 메시지

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