Submission #1018353

#TimeUsernameProblemLanguageResultExecution timeMemory
1018353MohamedFaresNebiliSeptember (APIO24_september)C++17
0 / 100
1 ms3420 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005]; int act[100005], rem[100005]; bool 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) act[l] = (int)adj[l].size(); else leaf[l] = 1; } vector<int> pos(N); for(int l = 0; l < N - 1; l++) pos[S[0][l]] = l; int res = 1; int hi = -1; for(int l = 0; l < N - 1; l++) { for(auto u : adj[l]) hi = max(hi, pos[u]); if(hi == l) res++; } 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...