Submission #66408

#TimeUsernameProblemLanguageResultExecution timeMemory
66408khohkoBosses (BOI16_bosses)C++17
0 / 100
41 ms47588 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; #define ll long long #define pb push_back #define fr first #define sc second #define MAX ((ll)(1e9+100)) #define MX ((ll)(1e6+100)) #define ARRS ((ll)(2e6+100)) #define HS ((ll)(233)) #define MOD ((ll)(1e9+7)) #define EP ((double)(1e-9)) #define LG 21 #define mul(a,b) a=((a)*(b))%MOD using namespace std; ll n; ll m,k; vector<ll> v[ARRS]; ll f[ARRS]; int main(){ #ifdef KHOKHO freopen("in.in","r",stdin); freopen("out.out","w",stdout); #endif // KHOKHO ios::sync_with_stdio(0); cin>>n; for(int i=1; i<=n; i++){ cin>>m; while(m--){ cin>>k; v[k].pb(i); } } ll pas=MAX; for(int i=1; i<=n; i++){ for(int i=1; i<=n; i++)f[i]=0; queue<pair<ll,ll> > q; q.push({i,1}); ll p=0; while(q.size()){ auto x=q.front(); q.pop(); if(f[x.fr])continue; f[x.fr]=1; p+=x.sc; for(auto y:v[x.fr]) q.push({y,x.sc+1}); } pas=min(pas,p); } cout<<pas; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...