# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533185 |
2022-03-05T05:15:15 Z |
gilbirb |
Bosses (BOI16_bosses) |
C++14 |
|
622 ms |
648 KB |
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
typedef long long ll;
using namespace std;
ll n, ans = 1e9;
vector<ll>adj[5005];
ll p[5005];
void bfs(ll s){
memset(p, 0, sizeof(p));
p[s] = 1;
queue<ll>q;
q.push(s);
while(!q.empty()){
ll cur = q.front();
q.pop();
for(int x : adj[cur]){
if(!p[x]){
p[x] = p[cur]+1;
q.push(x);
}
}
}
ll total = 0;
for(int i = 1; i <= n; i++){
if(!p[i]) return;
total += p[i];
}
ans = min(ans, total);
return;
}
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
int m;
cin >> m;
for(int j = 1; j <= m; j++){
ll x; cin >> x;
adj[x].pb(i);
}
}
for(int i = 1; i <= n; i++){
bfs(i);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
408 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
408 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
412 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
408 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
408 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
412 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
408 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
588 KB |
Output is correct |
13 |
Correct |
4 ms |
588 KB |
Output is correct |
14 |
Correct |
121 ms |
460 KB |
Output is correct |
15 |
Correct |
10 ms |
552 KB |
Output is correct |
16 |
Correct |
499 ms |
588 KB |
Output is correct |
17 |
Correct |
617 ms |
644 KB |
Output is correct |
18 |
Correct |
622 ms |
648 KB |
Output is correct |