Submission #1016060

#TimeUsernameProblemLanguageResultExecution timeMemory
1016060amine_arouaSeptember (APIO24_september)C++17
0 / 100
1 ms348 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<bool> vis; int Time = -1; void dfs(int x) { if(vis[x]) return ; vis[x] = 1; Time++; for(auto u : adj[x]) { dfs(u); } } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { adj.clear(); adj.assign(N , {}); vis.assign(N , 0); Time = -1; for(int i = 1 ; i <= N - 1 ; i++) { adj[F[i]].push_back(i); } dfs(0); int d = 0; vector<int> occ(N); set<int> diff; for(int i = 0 ; i < N - 1 ; i++) { for(int j = 0 ; j < M ; j++) { dfs(S[j][i]); if(occ[S[j][i]] == 0) diff.insert(S[j][i]); if(occ[S[j][i]] + 1 == M) { diff.erase(S[j][i]); } occ[S[j][i]]++; } if(diff.empty() && Time == 0) { d++; } Time--; } return d; }
#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...