제출 #967897

#제출 시각아이디문제언어결과실행 시간메모리
967897PM1Bosses (BOI16_bosses)C++17
0 / 100
1 ms860 KiB
#include <bits/stdc++.h> using namespace std; const int mxn=5e3+5; int n,ans=1e9,mark[mxn]; vector<int>v[mxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++){ int k; cin>>k; while(k--){ int x; cin>>x; v[x].push_back(i); } } for(int i=1;i<=n;i++){ memset(mark,0,sizeof mark); int res=0; queue<int>q; mark[i]=1; q.push(i); while(!q.empty()){ int x=q.front(); q.pop(); res+=mark[x]; for(auto j:v[x]){ if(!mark[j]){ mark[j]=mark[x]+1; q.push(j); } } } for(int j=1;j<=n;j++){ if(mark[j]==0) assert(0); } ans=min(res,ans); } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...