Submission #776257

#TimeUsernameProblemLanguageResultExecution timeMemory
776257m_bezrutchkaFriend (IOI14_friend)C++14
100 / 100
21 ms3412 KiB
#include <cstdio> #include <algorithm> #include "friend.h"; using namespace std; const int MAXN = 112345; int dp[2][MAXN]; int findSample(int n, int confidence[], int host[], int protocol[]) { for (int i = 0; i < n; i++) { dp[0][i] = 0; dp[1][i] = confidence[i]; } for (int i = n - 1; i > 0; i--) { int w = i; int v = host[i]; if (protocol[i] == 0) { // IAmYourFriend dp[1][v] = dp[1][v] + dp[0][w]; dp[0][v] = dp[0][v] + max(dp[0][w], dp[1][w]); } else if (protocol[i] == 1) { // MyFriendsAreYourFriends dp[1][v] = max(dp[0][v] + dp[1][w], max(dp[1][v] + dp[0][w], dp[1][v] + dp[1][w])); dp[0][v] = dp[0][v] + dp[0][w]; } else { // WeAreYourFriends dp[1][v] = max(dp[0][v] + dp[1][w], dp[1][v] + dp[0][w]); dp[0][v] = dp[0][v] + dp[0][w]; } } return max(dp[0][0], dp[1][0]); }

Compilation message (stderr)

friend.cpp:3:20: warning: extra tokens at end of #include directive
    3 | #include "friend.h";
      |                    ^
#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...