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 p[Nmax], q[Nmax];
int findSample(int n, int confidence[], int host[], int protocol[])
{
int i;
for(i=0; i<n; ++i) p[i] = confidence[i], q[i] = 0;
for(i=n-1; i; --i)
{
int newp, newq, id = host[i];
if(protocol[i] == 0) /// IAmYourFriend
{
newp = p[id] + q[i];
newq = q[id] + p[i];
}
else if(protocol[i] == 1) /// MyFriendsAreYourFriends
{
newp = p[id] + p[i];
newq = q[i] + q[id];
}
else /// WeAreYourFriends
{
newp = max(p[id] + q[i], p[i] + q[id]);
newq = q[i] + q[id];
}
p[id] = max(newq, newp);
q[id] = newq;
}
return p[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... |