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;
typedef long long ll;
typedef pair <ll, ll> pii;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int findSample(int n, int conf[], int host[], int prot[]){
int p[n], q[n];
for(int i = 0; i < n; i++){
p[i] = conf[i];
q[i] = 0;
}
for(int i = n-1; i; i--){
int ph = p[host[i]], qh = q[host[i]], pr = p[i], qr = q[i];
if(!prot[i]){
p[host[i]] = ph+qr;
q[host[i]] = max(pr+qh, qh+qr);
}
else if(prot[i]&1){
p[host[i]] = max(ph+qr, max(pr+qh, ph+pr));
q[host[i]] = qh+qr;
}
else{
p[host[i]] = max(ph+qr, pr+qh);
q[host[i]] = qh+qr;
}
}
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... |