이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |