Submission #235315

#TimeUsernameProblemLanguageResultExecution timeMemory
235315GoolakhBosses (BOI16_bosses)C++17
100 / 100
709 ms660 KiB
/// Be Kind :) #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") //#pragma GCC optimize("Os") /* Bitch, where you when I was walkin'? Now I run the game, got the whole world talkin' */ /* You never likes us anyway, fuck your friendship, I meant it */ /* The Chanel or Balenciaga, Louis and Vuitton She know I got Fendi, Prada when I hit Milan */ /* Niggas been counting me out I'm counting my bullets, I'm loading my clips I'm writing down names, I'm making a list */ /* I ran away, I don't think I'm coming back home */ #define F first #define S second #define pb push_back #define SZ(x) (ll)(x.size()) #define all(x) x.begin(),x.end() typedef int ll; typedef pair<ll,ll> pll; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll maxn=5e3+10, maxm=1e5+10, lg=23, mod=1e9+7, inf=1e18; ll n; vector<ll> g[maxn]; ll dis[maxn]; deque<ll> q; int main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; for(int i=1;i<=n;i++){ ll k; cin>>k; while(k--){ ll x; cin>>x; g[x].pb(i); } } ll ans=mod; for(int sr=1;sr<=n;sr++){ memset(dis,69,sizeof(dis)); q.pb(sr), dis[sr]=0; while(!q.empty()){ ll v=q.front(); q.pop_front(); for(auto u:g[v])if(dis[u]>dis[v]+1) dis[u]=dis[v]+1, q.pb(u); } ll nans=0; for(int i=1;i<=n;i++){ if(dis[i]>=mod){ nans=mod; break; } nans+=dis[i]; } ans=min(ans,nans); } cout<<ans+n; return 0; }

Compilation message (stderr)

bosses.cpp:34:58: warning: overflow in implicit constant conversion [-Woverflow]
 const ll maxn=5e3+10, maxm=1e5+10, lg=23, mod=1e9+7, inf=1e18;
                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...