# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542661 | alextodoran | Friend (IOI14_friend) | C++17 | 25 ms | 3444 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.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int I_AM_YOUR_FRIEND = 0;
const int MY_FRIENDS_ARE_YOUR_FRIENDS = 1;
const int WE_ARE_YOUR_FRIENDS = 2;
int findSample (int n, int confidence[], int host[], int protocol[]) {
int take[n], skip[n];
for (int u = 0; u < n; u++) {
take[u] = confidence[u];
skip[u] = 0;
}
for (int u = n - 1; u > 0; u--) {
int v = host[u];
int newTake;
int newSkip;
if (protocol[u] == I_AM_YOUR_FRIEND) {
newTake = take[v] + skip[u];
newSkip = skip[v] + max(take[u], skip[u]);
}
if (protocol[u] == MY_FRIENDS_ARE_YOUR_FRIENDS) {
newTake = max({take[u] + take[v], take[u] + skip[v], skip[u] + take[v]});
newSkip = skip[u] + skip[v];
}
if (protocol[u] == WE_ARE_YOUR_FRIENDS) {
newTake = max(take[u] + skip[v], skip[u] + take[v]);
newSkip = skip[u] + skip[v];
}
take[v] = newTake;
skip[v] = newSkip;
}
return max(take[0], skip[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... |