Submission #385699

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3856992021-04-04 18:41:39bladefan960Traffic (IOI10_traffic)C++17
100 / 100
1353 ms152956 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using std::cout;
using std::endl;
using std::vector;
vector<int> city_sub_num;
vector<int> parent;
int calc_sub_fans(int at, int prev, int P[], const vector<vector<int>>& neighbors) {
city_sub_num[at] = P[at];
parent[at] = prev;
for (int n : neighbors[at]) {
if (n != prev) {
city_sub_num[at] += calc_sub_fans(n, at, P, neighbors);
}
}
return city_sub_num[at];
}
int LocateCentre(int N, int P[], int S[], int D[]) {
city_sub_num = vector<int>(N);
parent = vector<int>(N);
vector<vector<int>> neighbors(N);
for (int i = 0; i < N - 1; i++) {
neighbors[S[i]].push_back(D[i]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...