Submission #733480

#TimeUsernameProblemLanguageResultExecution timeMemory
733480JellyTheOctopusBosses (BOI16_bosses)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int N; bool adjMat[5001][5001]; long long bfs(int root) { vector<bool> seen(N+1); queue<array<int, 2>> q; // node, depth q.push({root, 1}); // starting depth at one seen[root] = true; long long ans = 0; while (!q.empty()) { array<int, 2> cur = q.front(); int u = cur[0]; int depth = cur[1]; q.pop(); ans += (long long)depth; for (int v = 1; v <= N; v++) { if (adjMat[u][v] && !seen[v]) { q.push({v, depth+1}); seen[v] = true; } } } return ans; } int main() { cin >> N; cin.ignore(); for (int v = 1; v <= N; v++) { string line; getline(cin, line); istringstream iss(line); int u; while (iss >> u) { adjMat[u][v] = true; } } long long ans = LLONG_MAX; for (int i = 1; i <= N; i++) { if (adjMat[i][i]) continue; ans = min(ans, bfs(i)); } cout << ans << "\n";

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:46:21: error: expected '}' at end of input
   46 |  cout << ans << "\n";
      |                     ^
bosses.cpp:29:12: note: to match this '{'
   29 | int main() {
      |            ^