Submission #29403

#TimeUsernameProblemLanguageResultExecution timeMemory
29403cki86201Friend (IOI14_friend)C++11
35 / 100
0 ms4364 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 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=n-1;i;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 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...