Submission #998968

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