Submission #860866

#TimeUsernameProblemLanguageResultExecution timeMemory
860866elotelo966Bosses (BOI16_bosses)C++17
100 / 100
490 ms4440 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define int long long #define OYY 1000000000005 #define mod 1000000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mid (start+end)/2 #define lim 100005 vector<int> v[lim]; int dis[lim],n,vis[lim]; inline int bfs(int node){ for (int i=1;i<=n;i++){ dis[i]=OYY; vis[i]=0; } queue <pair<int,int>> pq; pq.push({1,node}); dis[node]=1; vis[node]=1; //cout<<node<<" "<<dis[node]<<endl; while(!pq.empty()){ int nd=pq.front().second; pq.pop(); // cout<<pq.top().first<<" "<<pq.top().second<<" "<<dis[nd]<<endl; for(int i=0;i<v[nd].size();i++){ if(vis[v[nd][i]])continue; dis[v[nd][i]]=min(dis[v[nd][i]],dis[nd]+1); vis[v[nd][i]]=1; pq.push({-dis[v[nd][i]],v[nd][i]}); } } int cev=0; for(int i=1;i<=n;i++){ cev+=dis[i]; } // cout<<cev<<endl; return cev; } int32_t main(){ faster cin>>n; for(int i=1;i<=n;i++){ int deg,tut;cin>>deg; for(int j=0;j<deg;j++){ cin>>tut; v[tut].push_back(i); } } int cev=OYY; for(int i=1;i<=n;i++){ cev=min(cev,bfs(i)); } cout<<cev<<'\n'; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'long long int bfs(long long int)':
bosses.cpp:28:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=0;i<v[nd].size();i++){
      |                     ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...