Submission #404168

#TimeUsernameProblemLanguageResultExecution timeMemory
404168peuchFriend (IOI14_friend)C++17
0 / 100
1 ms332 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; int dp[2][MAXN]; int v[MAXN]; vector<int> ar[MAXN]; int getDP(int cur, int p); int findSample(int n,int confidence[],int host[],int protocol[]){ memset(dp, -1, sizeof(dp)); for(int i = 0; i < n; i++) v[i] = confidence[i]; for(int i = 1; i < n; i++) ar[host[i]].push_back(i); return max(getDP(0, 0), getDP(0, 1)); } int getDP(int cur, int p){ if(dp[cur][p] != -1) return dp[cur][p]; dp[cur][p] = 0; for(int i = 0; i < ar[cur].size(); i++){ int viz = ar[cur][i]; dp[cur][p] += getDP(viz, !p); dp[cur][p] += (!p) * getDP(viz, p); } dp[cur][p] += v[cur] * p; return dp[cur][p]; }

Compilation message (stderr)

friend.cpp: In function 'int getDP(int, int)':
friend.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i = 0; i < ar[cur].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...