Submission #877484

#TimeUsernameProblemLanguageResultExecution timeMemory
877484Beerus13Bosses (BOI16_bosses)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 5e3 + 5; int n; vector<int> g[N]; ll dp[N]; ll bfs(int u) { queue<int> q; memset(dp, 0x3f, sizeof(dp)); dp[u] = 1; q.push(u); while(q.size()) { int s = q.front(); q.pop(); for(int t : g[s]) if(dp[t] > dp[s] + 1) { dp[t] = dp[s] + 1; q.push(t); } } ll res = 0; for(int i = 1; i <= n; ++i) res += dp[i]; return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; ++i) { int k, x; cin >> k; for(int j = 0 j < k; ++j) { cin >> x; g[x].push_back(i); } } ll ans = 1e18; for(int i = 1; i <= n; ++i) ans = min(ans, bfs(i)); cout << ans << '\n'; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:32:22: error: expected ';' before 'j'
   32 |         for(int j = 0 j < k; ++j) {
      |                      ^~
      |                      ;