제출 #797056

#제출 시각아이디문제언어결과실행 시간메모리
797056christinelynnBosses (BOI16_bosses)C++17
0 / 100
2 ms2644 KiB
#include <bits/stdc++.h> using namespace std; vector<int> e[100000]; int main() { int N, ans = 0; cin>>N; 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); } } for(int i=0; i<N; i++) { int sum = 1; 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; sum += d[j]; //cout<<sum<<" "<<d[j]<<endl; q.push(j); } } } if(i==0){ ans = sum; }else{ ans = min(sum,ans); } } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...