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 IAmYourFriend = 0;
const int MyFriendsAreYourFriends = 1;
const int WeAreYourFriends = 2;
int solve(int n, vector<int> values, vector<int> host, vector<int> type) {
int to_add = 0;
for(int i = n; i >= 1; i--) {
if(type[i] == WeAreYourFriends) {
values[host[i]] = max(values[host[i]], values[i]);
}
if(type[i] == MyFriendsAreYourFriends) {
values[host[i]] = values[host[i]] + values[i];
}
if(type[i] == IAmYourFriend) {
to_add += values[i];
values[host[i]] = max(0, values[host[i]] - values[i]);
}
}
return (to_add + values[0]);
}
int findSample(int n,int confidence[],int host[],int protocol[]){
int _n = n - 1;
vector<int> _values(1 + _n, 0);
vector<int> _host(1 + _n, 0);
vector<int> _type(1 + _n, 0);
_values[0] = confidence[0];
for(int i = 1; i <= _n; i++) {
_values[i] = confidence[i];
_host[i] = host[i];
_type[i] = protocol[i];
}
return solve(_n, _values, _host, _type);
}
# | 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... |