Submission #1017616

#TimeUsernameProblemLanguageResultExecution timeMemory
1017616MohamedFaresNebiliSeptember (APIO24_september)C++17
0 / 100
1 ms2652 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005]; bool act[100005], leaf[100005]; int solve(int N, int M, vector<int> F, vector<vector<int>> S) { for(int l = 0; l < N; l++) adj[l].clear(), act[l] = leaf[l] = 0; for(int l = 1; l < N; l++) adj[F[l]].push_back(l); for(int l = 0; l < N; l++) { if(adj[l].size() > 0) continue; leaf[l] = 1; } int res = 0, cur = 0; for(int l = 0; l < N - 1; l++) { int U = S[0][l]; if(leaf[U]) { leaf[F[U]] = 1; if(act[F[U]]) cur--, act[F[U]] = 0; if(cur == 0) ++res; } else { act[F[U]] = 1; cur++; } } 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...