Submission #79521

#TimeUsernameProblemLanguageResultExecution timeMemory
79521Dat160601Bosses (BOI16_bosses)C++17
0 / 100
2 ms536 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back int n,x,u,v,ans=1e9; vector <int> edge[5007]; int vis[5007]; void go(int root){ queue <int> q; q.push(root); vis[root]=1; int ret=0; while(!q.empty()){ int u=q.front(); q.pop(); ret+=vis[u]; for(int v:edge[u]){ if(!vis[v]){ vis[v]=vis[u]+1; q.push(v); } } } ans=min(ans,ret); } int main(){ ios_base::sync_with_stdio(0); cin>>n; for(int i=1;i<=n;i++){ cin>>x; while(x>0){ x--; cin>>v; edge[v].pb(i); } } for(int i=1;i<=n;i++){ memset(vis,0,sizeof(vis)); go(i); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...