Submission #29411

#TimeUsernameProblemLanguageResultExecution timeMemory
29411cki86201Friend (IOI14_friend)C++11
35 / 100
0 ms4752 KiB
#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 par[100010]; int D[100010][2]; int p[100010]; int Find(int x) { return p[x] == x ? x : p[x] = Find(p[x]); } int findSample(int n,int confidence[],int host[],int protocol[]){ rep(i, n) par[i] = -1, p[i] = i; for(int i=n-1;i;i--) { int h = host[i], c = protocol[i]; if(c == 0) par[i] = h; else if(c == 1) confidence[h] += confidence[i], p[i] = h; else if(c == 2) confidence[h] = max(confidence[h], confidence[i]), p[i] = h; } for(int i=n-1;i>=0;i--) if(par[i] != -1 && p[i] == i) { D[i][1] += confidence[i]; D[Find(par[i])][0] += max(D[i][0], D[i][1]); D[Find(par[i])][1] += D[i][0]; } D[0][1] += confidence[0]; return max(D[0][0], D[0][1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...