# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044274 | 2024-08-05T08:31:53 Z | vjudge1 | Bosses (BOI16_bosses) | C++14 | 341 ms | 728 KB |
#include <bits/stdc++.h> #define ll long long using namespace std; bool ok = 0; const int maxn = 5000 + 7; int n , h[maxn] , ans = 1e18; vector <int> g[maxn]; void bfs(int s) { for(int i = 1; i <= n; i++) h[i] = -1; queue <int> node; node.push(s); h[s] = 1; while(!node.empty()) { int u = node.front(); for(int v: g[u]) { if(h[v] == -1) { h[v] = h[u] + 1; node.push(v); } } node.pop(); } int cnt = 0; bool check = 1; for(int i = 1; i <= n; i++) { if(h[i] == -1) check = 0; cnt += h[i]; } if(check) ans = min(ans , cnt); } void solve() { cin >> n; for(int i = 1; i <= n; i++) { int s , k; cin >> s; while(s--) { cin >> k; g[k].push_back(i); } } for(int i = 1; i <= n; i++) { bfs(i); } cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 604 KB | Output is correct |
13 | Correct | 2 ms | 604 KB | Output is correct |
14 | Correct | 63 ms | 604 KB | Output is correct |
15 | Correct | 16 ms | 600 KB | Output is correct |
16 | Correct | 339 ms | 604 KB | Output is correct |
17 | Correct | 341 ms | 600 KB | Output is correct |
18 | Correct | 304 ms | 728 KB | Output is correct |