Submission #985373

#TimeUsernameProblemLanguageResultExecution timeMemory
985373Octa_pe_infoBosses (BOI16_bosses)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <queue> #include <climits> // For INT_MAX using namespace std; vector<vector<int>> adj; vector<bool> visited; vector<int> level; void bfs(int root, int n) { queue<int> q; visited.assign(n + 1, false); // Reset visited for each BFS level.assign(n + 1, 0); // Reset level for each BFS visited[root] = true; q.push(root); level[root] = 0; while (!q.empty()) { int current = q.front(); q.pop(); for (int neighbor : adj[current]) { if (!visited[neighbor]) { visited[neighbor] = true; level[neighbor] = level[current] + 1; q.push(neighbor); } } } } int calculateSalaries(int node) { int salary = 1; for (int child : adj[node]) { if (level[child] == level[node] + 1) { salary += calculateSalaries(child); } } return salary; } int main() { int n; cin >> n; adj.resize(n + 1); visited.resize(n + 1); level.resize(n + 1); for (int i = 1; i <= n; ++i) { int k; cin >> k; while (k--) { int x; cin >> x; adj[x].push_back(i); } } int minimalTotalSalary = INT_MAX; for (int i = 1; i <= n; ++i) { bfs(i, n); if (count(visited.begin() + 1, visited.end(), true) == n) { // Check if all nodes are visited int totalSalary = 0; for (int j = 1; j <= n; ++j) { if (level[j] == 0) { // Start DFS only from roots totalSalary += calculateSalaries(j); } } minimalTotalSalary = min(minimalTotalSalary, totalSalary); } } cout << minimalTotalSalary; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:66:13: error: 'count' was not declared in this scope
   66 |         if (count(visited.begin() + 1, visited.end(), true) == n) {  // Check if all nodes are visited
      |             ^~~~~