Submission #46264

#TimeUsernameProblemLanguageResultExecution timeMemory
46264ikura355Bosses (BOI16_bosses)C++14
0 / 100
2 ms752 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 5000 + 5; int n; vector<int> way[maxn]; int d[maxn]; queue<int> q; ll bfs(int x) { memset(d,0,sizeof(d)); d[x] = 1; q.push(x); while(!q.empty()) { int u = q.front(); q.pop(); for(auto v : way[u]) { if(!d[v]) { d[v] = d[u]+1; q.push(v); } } } ll sum = 0; for(int x=1;x<=n;x++) sum += d[x]; return sum; } int main() { scanf("%d",&n); for(int x=1;x<=n;x++) { int m; scanf("%d",&m); while(m--) { int y; scanf("%d",&y); way[y].push_back(x); } } ll ans = 1e9; for(int x=1;x<=n;x++) ans = min(ans, bfs(x)); printf("%lld",ans); }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
bosses.cpp:27:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int m; scanf("%d",&m);
          ~~~~~^~~~~~~~~
bosses.cpp:29:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int y; scanf("%d",&y);
           ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...