Submission #453686

#TimeUsernameProblemLanguageResultExecution timeMemory
453686Blobo2_Blobo2Bosses (BOI16_bosses)C++14
0 / 100
1 ms204 KiB
/* Editor: Abdelrahman Hossam Nickname: Blobo2_Blobo2 IOI next year isA :) */ /*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/ #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define all(v) v.begin(),v.end() #define gen(arr,n,nxt) generate(arr,arr+n,nxt) #define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0); const int mo=1e9+7,INF=1e18; int nxt(){int x;cin>>x;return x;} signed main(){ Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty int n=nxt(); vector<int>adj[n+1]; for(int i=0;i<n;i++){ int x=nxt(); for(int j=0;j<x;j++){ int node = nxt()-1; adj[node].push_back(i); } } int mn=1e18; for(int i=0;i<n;i++){ priority_queue<pair<int,int> >q; bool vis[n]; memset(vis,0,sizeof vis); q.push({0,i}); int level[n]; memset(level,0,sizeof level); vis[i]=1; level[0]++; int cnt=1; while(q.size()){ pair<int,int> u=q.top(); q.pop(); for(auto v:adj[u.second]){ if(!vis[v]){ level[(-u.first)+1]++; q.push({u.first-1,v}); vis[v]=1; cnt++; } } if(cnt==n)break; } int c=0; for(int i=n-2;i>=0;i--) level[i]+=level[i+1]; for(int i=n-1;i>=0;i--) c+=level[i]; mn=min(mn,c); } cout<<mn; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...