## Submission #582311

# Submission time Handle Problem Language Result Execution time Memory
582311 2022-06-23T16:05:27 Z stevancv Bosses (BOI16_bosses) C++14
100 / 100
634 ms 716 KB
```#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<vector<int>> g(n);
for (int i = 0; i < n; i++) {
int sz; cin >> sz;
while (sz--) {
int x; cin >> x;
x -= 1;
g[x].push_back(i);
}
}
ll ans = 1e9;
for (int i = 0; i < n; i++) {
queue<int> q;
vector<int> d(n, 1e9);
d[i] = 0;
q.push(i);
while (!q.empty()) {
int s = q.front();
q.pop();
for (int u : g[s]) {
if (d[u] > d[s] + 1) {
d[u] = d[s] + 1;
q.push(u);
}
}
}
ll tr = n;
for (int j = 0; j < n; j++) tr += d[j];
smin(ans, tr);
}
cout << ans << en;
return 0;
}
```

#### Subtask #1 22.0 / 22.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct

#### Subtask #2 45.0 / 45.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct

#### Subtask #3 33.0 / 33.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 129 ms 548 KB Output is correct
15 Correct 24 ms 460 KB Output is correct
16 Correct 495 ms 640 KB Output is correct
17 Correct 634 ms 660 KB Output is correct
18 Correct 634 ms 716 KB Output is correct