Submission #755195

#TimeUsernameProblemLanguageResultExecution timeMemory
755195vjudge1Bosses (BOI16_bosses)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; vector <int> ke[5005]; long long oo=1000000000000000; long long kq; long long danhdau[5005]; queue <int> q; long long h[5005]; void bfs(int s) { while (q.size()) q.pop(); q.push(s); long long tong=0; while (q.size()) { int s=q.front(); q.pop(); for (int i=0;i<ke[s].size();i++) { int v=ke[s][i]; if (danhdau[v]==0) { danhdau[v]=1; h[v]=h[s]+1; tong=tong+h[v]; q.push(v); } } } // cout << tong << " " << s << '\n'; kq=min(kq,tong+1); } signed main () { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i=1;i<=n;i++) { int kk; cin >> kk; for (int i2=1;i2<=kk;i2++) { int kkk; cin >> kkk; ke[kkk].push_back(i); } } kq=oo; for (int dinh=1;dinh<=n;dinh++) { for (int i=1;i<=n;i++) { danhdau[i]=0; h[i]=0; } h[dinh]=1; danhdau[dinh]=1; bfs(dinh); } cout << kq; }

Compilation message (stderr)

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