Submission #741662

#TimeUsernameProblemLanguageResultExecution timeMemory
741662baneFriend (IOI14_friend)C++17
100 / 100
31 ms8032 KiB
#include "friend.h" #include<bits/stdc++.h> #define ALL(v) (v).begin(), (v).end() #define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define REPD(i, n) for (int i = (n); i--; ) #define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; ++i) #define FORD(i, b, a) for (int i = (b), _a = (a); --i >= _a; ) #define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORDE(i, b, a) for (int i = (b), _a = (a); i >= _a; --i) using namespace std; template <class A, class B> bool maximize(A &a, B b) { if (a < b) { a = b; return true; } return false; } int findSample(int n, int confidence[], int host[], int protocol[]){ vector <vector <int>> dp(n, vector<int>(2, 0)); REP(i,n)dp[i][1] = confidence[i]; FORD(i,n,1){ if (!protocol[i]) { dp[host[i]][0] += max(dp[i][0], dp[i][1]); dp[host[i]][1] += dp[i][0]; } else if (protocol[i] == 1) { dp[host[i]][1] += max(dp[i][0], dp[i][1]); maximize(dp[host[i]][1], dp[host[i]][0] + dp[i][1]); dp[host[i]][0] += dp[i][0]; } else { dp[host[i]][1] += dp[i][0]; maximize(dp[host[i]][1], dp[host[i]][0] + dp[i][1]); dp[host[i]][0] += dp[i][0]; } } return max(dp[0][0], dp[0][1]); }
#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...