Submission #723765

#TimeUsernameProblemLanguageResultExecution timeMemory
723765yahyobekabdunazarovBosses (BOI16_bosses)C++17
0 / 100
1 ms596 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector<int> adj[10009], used(10009); int ans = 0, anss = 0; int dfs(int u){ int ans = 0; for(int i: adj[u]){ if(!used[i]){ used[i] = 1; ans += dfs(i) + 1; } } anss += ans; if(!ans) return 0; return ans; } signed main(){ int n; cin >> n; for(int i = 0; i < n; i++){ int x; cin >> x; for(int j = 0; j < x; j++){ int a; cin >> a; adj[a].push_back(i + 1); } } int mn = INT_MAX; for(int i = 1; i <= n; i++){ ans = 0, anss = 0; dfs(i); mn = min(anss, mn); fill(used.begin(), used.end(), 0); } cout << mn; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...