# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103802 | naoai | Friend (IOI14_friend) | C++14 | 32 ms | 3236 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 <bits/stdc++.h>
using namespace std;
const int nmax = 1e5 + 5;
int d[nmax + 1][2];
int findSample(int n,int confidence[],int host[],int protocol[]){
for (int i = 0; i < n; ++ i)
d[i][1] = confidence[i];
for (int i = n - 1; i > 0; -- i) {
int h = host[i];
int x = d[h][0], y = d[h][1];
if (protocol[i] == 0) {
d[h][0] = x + max(d[i][0], d[i][1]);
d[h][1] = y + d[i][0];
} else if (protocol[i] == 1) {
d[h][0] = x + d[i][0];
d[h][1] = max(y + max(d[i][0], d[i][1]), x + d[i][1]);
} else {
d[h][0] = x + d[i][0];
d[h][1] = max(x + d[i][1], y + d[i][0]);
}
}
return max(d[0][0], d[0][1]);
}
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... |