제출 #553160

#제출 시각아이디문제언어결과실행 시간메모리
553160new_accBosses (BOI16_bosses)C++14
100 / 100
639 ms2876 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e5+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod2=998244353; const ll mod=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; int odl[N],n; vi graf[N]; int bfs(int v){ deque<int>deq; deq.push_back(v); for(int i=1;i<=n;i++) odl[i]=0; odl[v]=1; int res=0; while(deq.size()){ int u=deq.front(); deq.pop_front(); res+=odl[u]; for(auto curr:graf[u]) if(odl[curr]==0) odl[curr]=odl[u]+1,deq.push_back(curr); } for(int i=1;i<=n;i++) if(odl[i]==0) res=INFi; return res; } void solve(){ cin>>n; for(int a,i=1;i<=n;i++){ cin>>a; while(a--){ int b; cin>>b; graf[b].push_back(i); } } int res=INFi; for(int i=1;i<=n;i++) res=min(res,bfs(i)); cout<<res<<"\n"; } int main(){ solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...