Submission #824270

#TimeUsernameProblemLanguageResultExecution timeMemory
824270AlphaMale06Bosses (BOI16_bosses)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N=5005; vector<int> adj[N]; bool mark[N]; int ans=0; int cnt=0; int gentree(int node){ mark[node]=true; cnt++; int sum=1; for(int to : adj[node]){ if(!mark[to]){ sum+=gentree(to); } } ans+=sum; return sum; } void clearmark(int n){ for(int i=1; i<= n; i++){ mark[i]=0; } } int main() { int n; cin >> n; for(int i=0; i< n; i++){ int k; cin >> k; for(int j=0; j< k; j++){ int kita; cin >> kita; adj[kita].pb(i+1); } } int mn=1e9; for(int i=1; i<=n; i++){ gentree(i); if(cnt==n)mn=min(mn, ans); clearmark(n+1); cnt=0; ans=0; } cout << mn << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...