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<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define F first
#define S second
#define ll long long
// #define int ll
#define pb push_back
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,i) memset(a,i,sizeof(a))
#define in insert
#define lb lower_bound
#define ub upper_bound
#define y1 yy
#define ppb pop_back
#define ull unsigned ll
const int MAX=1e5+55;
const int inf=1e9;
const int N=2e5;
const int C=331;
const int C1=431;
const int mod=1e9+9;
const int mod1=1e9+9;
#include "friend.h"
int a[MAX],b[MAX];
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
for(int i=0;i<n;i++)a[i]=confidence[i];
for(int i=n-1;i>=1;i--){
int p=host[i];
int ap=a[p];
int bp=b[p];
if(protocol[i]==0){
a[p]=b[i]+ap;
b[p]=max(bp+a[i],bp+b[i]);
}
if(protocol[i]==1){
a[p]=max({ap+a[i],ap+b[i],bp+a[i]});
b[p]=bp+b[i];
}
if(protocol[i]==2){
a[p]=max(ap+b[i],bp+a[i]);
b[p]=bp+b[i];
}
}
return max(a[0],b[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... |