# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79526 | 2018-10-15T01:49:09 Z | IOrtroiii | Bosses (BOI16_bosses) | C++14 | 666 ms | 888 KB |
#include <bits/stdc++.h> using namespace std; const int N = 5005; int n; vector<int> g[N]; int F[N]; long long bfs(int root) { for (int i = 1; i <= n; ++i) F[i] = 0; long long sum = 0; int cnt = 0; queue<int> q; q.push(root); F[root] = 1; while (!q.empty()) { int u = q.front(); q.pop(); sum += F[u]; cnt++; for (int v : g[u]) if (F[v] == 0) { F[v] = F[u] + 1; q.push(v); } } if (cnt < n) return 1e18; return sum; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); while (x--) { int u; scanf("%d", &u); g[u].push_back(i); } } long long res = 1e18; for (int i = 1; i <= n; ++i) res = min(res, bfs(i)); cout << res << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 712 KB | Output is correct |
4 | Correct | 2 ms | 712 KB | Output is correct |
5 | Correct | 2 ms | 712 KB | Output is correct |
6 | Correct | 2 ms | 712 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 712 KB | Output is correct |
4 | Correct | 2 ms | 712 KB | Output is correct |
5 | Correct | 2 ms | 712 KB | Output is correct |
6 | Correct | 2 ms | 712 KB | Output is correct |
7 | Correct | 3 ms | 712 KB | Output is correct |
8 | Correct | 2 ms | 712 KB | Output is correct |
9 | Correct | 3 ms | 712 KB | Output is correct |
10 | Correct | 2 ms | 712 KB | Output is correct |
11 | Correct | 2 ms | 712 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 712 KB | Output is correct |
4 | Correct | 2 ms | 712 KB | Output is correct |
5 | Correct | 2 ms | 712 KB | Output is correct |
6 | Correct | 2 ms | 712 KB | Output is correct |
7 | Correct | 3 ms | 712 KB | Output is correct |
8 | Correct | 2 ms | 712 KB | Output is correct |
9 | Correct | 3 ms | 712 KB | Output is correct |
10 | Correct | 2 ms | 712 KB | Output is correct |
11 | Correct | 2 ms | 712 KB | Output is correct |
12 | Correct | 6 ms | 736 KB | Output is correct |
13 | Correct | 5 ms | 736 KB | Output is correct |
14 | Correct | 146 ms | 736 KB | Output is correct |
15 | Correct | 17 ms | 736 KB | Output is correct |
16 | Correct | 630 ms | 864 KB | Output is correct |
17 | Correct | 666 ms | 884 KB | Output is correct |
18 | Correct | 632 ms | 888 KB | Output is correct |