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 push_back
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 5;
int c[MAXN], p[MAXN], q[MAXN];
vi Graph[MAXN];
// Find out best sample
int findSample(int N, int _conf[], int host[], int protocol[])
{
for(int i = 0; i < N; i++)
{
c[i] = _conf[i];
p[i] = c[i];
q[i] = 0;
}
for(int i = N - 1; i > 0; i--)
{
if(protocol[i] == 0)
{
p[host[i]] += q[i];
q[host[i]] += max(p[i], q[i]);
}
else if(protocol[i] == 1)
{
p[host[i]] = max(p[host[i]] + p[i], max(p[host[i]] + q[i], q[host[i]] + p[i]));
q[host[i]] += q[i];
}
else if(protocol[i] == 2)
{
p[host[i]] = max(p[host[i]] + q[i], q[host[i]] + p[i]);
q[host[i]] += 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... |