This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |