Submission #938905

#TimeUsernameProblemLanguageResultExecution timeMemory
938905vjudge1Bosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; const int INF = 1e9; const int MAXN = 5e3; int N; vector<int> children[MAXN + 5]; bool vis[MAXN + 5]; int dfs(int cur, int depth) { vis[cur] = true; int ans = depth; for (auto child: children[cur]) { if (vis[child]) continue; ans += dfs(child, depth + 1); } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; for (int i = 0; i < N; i++) { int sz; cin >> sz; while (sz--) { int u; cin >> u; u--; children[i].push_back(u); } } int ans = INF; for (int i = 0; i < N; i++) { memset(vis, false, sizeof vis); ans = min(ans, dfs(i, 1)); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...