제출 #31079

#제출 시각아이디문제언어결과실행 시간메모리
31079WhipppedCream친구 (IOI14_friend)C++14
100 / 100
43 ms5144 KiB
#include <bits/stdc++.h> #define ii pair<int, int> #define X first #define Y second #define pb push_back #define mp make_pair #define vi vector<int> #define vii vector< pair<int, int> > typedef long long ll; using namespace std; int Host[100005]; int Prot[100005]; int conf[100005]; int c[100005]; int nc[100005]; int findSample(int n, int *conf, int *Host, int *Prot) { for(int i = 0; i< n; i++) c[i] = conf[i]; for(int i = n-1; i>= 1; i--) { int x = Host[i]; if(Prot[i] == 1) { c[x] = max(max(c[x]+nc[i], c[i]+nc[x]), c[i]+c[x]); nc[x] = nc[x] + nc[i]; } else if(Prot[i] == 2) { c[x] = max(c[x]+nc[i], c[i]+nc[x]); nc[x] = nc[x]+nc[i]; } else { c[x] = c[x]+nc[i]; nc[x] = max(c[i]+nc[x], nc[i]+nc[x]); } } return max(c[0], nc[0]); return 0; }
#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...