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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> Pll;
typedef long double ldouble;
int p[100010];
int D[100010][2];
int findSample(int n,int confidence[],int host[],int protocol[]){
rep(i, n) p[i] = -1;
for(int i=1;i<n;i++) {
int h = host[i], c = protocol[i];
if(c == 0) p[i] = h;
else if(c == 1) confidence[h] += confidence[i];
else if(c == 2) confidence[h] = max(confidence[h], confidence[i]);
}
for(int i=n-1;i>=0;i--) if(p[i] != -1) {
D[i][1] += confidence[i];
D[p[i]][0] += max(D[i][0], D[i][1]);
D[p[i]][1] += D[i][0];
}
D[0][1] += confidence[0];
return max(D[0][0], D[0][1]);
}
# | 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... |