Submission #790790

#TimeUsernameProblemLanguageResultExecution timeMemory
790790makanhuliaBosses (BOI16_bosses)C++17
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; vector<int> e[10000]; for(int i=0; i<N; i++) { int k; cin>>k; for(int j=0; j<k; j++) { int a; cin>>a; a--; e[a].push_back(i); } } int cnt[N]; for(int i=0; i<N; i++) { vector<int> d(N); queue<int> q; q.push(i); d[i]=1; while(!q.empty()) { int u=q.front(); q.pop(); for(int j : e[u]) { if(!d[j]) { d[j]=d[u] + 1; q.push(j); } } } int sum=0; for(int j=0; j<N; j++){ // cout<<d[j]<<" "; sum+=d[j]; } cnt[i]=sum; // cout<<cnt[i]<<endl; } sort(cnt,cnt+N); cout<<cnt[0]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...