# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
927455 | Gilwall | Friend (IOI14_friend) | C++14 | 19 ms | 3520 KiB |
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 <vector>
using namespace std;
// Find out best sample
int findSample(int n, int confidence[], int host[], int protocol[]){
int ans = 0;
vector<int> M(n), NM(n);
for(int i = 0; i < n; i++) {
M[i] = confidence[i];
NM[i] = 0;
}
for(int i = n-1; i > 0; i--) {
// i is person being added
int x = host[i];
int y = i;
if (protocol[i] == 0) {
NM[x] += M[y];
M[x] += NM[y];
} else if (protocol[i] == 1) {
int mx = max(NM[x], M[x]) + max(NM[y], M[y]);
int nmx = NM[x] + NM[y];
M[x] = mx;
NM[x] = nmx;
} else if (protocol[i] == 2) {
int mx = max(NM[x] + M[y], NM[y] + M[x]);
int nmx = NM[x] + NM[y];
M[x] = mx;
NM[x] = nmx;
}
}
return max(M[0], NM[0]);
}
Compilation message (stderr)
# | 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... |