Submission #998973

#TimeUsernameProblemLanguageResultExecution timeMemory
998973THXuanSeptember (APIO24_september)C++17
100 / 100
104 ms27592 KiB
#include <bits/stdc++.h> #include "september.h" #define INF 1e9 using namespace std; typedef long long ll; vector<int>adj[800005]; bool visited[800005]; int v = 0; void dfs(int s){ if(visited[s]) return; visited[s] = true; ++v; for(auto u : adj[s]){ dfs(u); } } int solve(int N, int M, vector<int> F, vector<vector<int>>S) { for(int i = 0;i<N;i++){ adj[i].clear(); visited[i] = false; } for(int i =1; i < N;i++){ adj[F[i]].push_back(i); } int ans = 0; for(int i =0;i<N-1;i++){ for(int j =0;j<M;j++)dfs(S[j][i]); ans += !--v; } return ans; }
#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...