Submission #993522

#TimeUsernameProblemLanguageResultExecution timeMemory
993522AMel0nSeptember (APIO24_september)C++17
0 / 100
1 ms348 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define rep(a) for(int i=0;i<a;++i) #define ll long long #define vi vector<int> #define node S[j][i] int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) { vi CHILDREN(N); vi LEAVES(N); for(int i=1; i<N; ++i) { CHILDREN[P[i]]++; } rep(N){ if (CHILDREN[i]==0) LEAVES[i] = true; } int res = 0; vector<vi> C(M, CHILDREN); vector<vi> L(M, LEAVES); vector<vi> B(M, vi(N)); int numBranches = 0; rep(N-1) { for(int j = 0; j < M; ++j) { if (L[j][node]) { C[j][P[node]]--; if (C[j][P[node]] == 0 && B[j][P[node]] == true) { B[j][P[node]] = false; numBranches--; } else if (C[j][P[node]] == 0 && B[j][P[node]] == false) { L[j][P[node]] = true; } } else { B[j][node] = true; numBranches++; } } if (numBranches == 0) res += 1; } return res; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...