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"
#define pb(x) push_back(x)
using namespace std;
const int MAXN = 1e5+5;
int p[MAXN], q[MAXN];
int findSample(int n,int arr[],int host[],int protocol[]){
for (int i = 0; i < n; i++)
p[i] = arr[i], q[i] = 0;
for (int i = n-1; i > 0; i--){
int pp = protocol[i];
int v = host[i];
if (pp == 2){ //WeAreYourFriends
p[v] = max(p[v] + q[i], p[i] + q[v]);
q[v] = q[v] + q[i];
}
else if (pp == 1){//MyFriendsAreYourFriends
p[v] = max(p[v]+p[i], max(p[v] + q[i], p[i] + q[v]));
q[v] = q[v] + q[i];
}
else{//IamYourFriend
p[v] = p[v] + q[i];
q[v] = max(p[i] + q[v], q[v] + q[i]);
}
}
return max(p[0], q[0]);
}
# | 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... |