# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46264 | 2018-04-18T10:53:53 Z | ikura355 | Bosses (BOI16_bosses) | C++14 | 2 ms | 752 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 5000 + 5; int n; vector<int> way[maxn]; int d[maxn]; queue<int> q; ll bfs(int x) { memset(d,0,sizeof(d)); d[x] = 1; q.push(x); while(!q.empty()) { int u = q.front(); q.pop(); for(auto v : way[u]) { if(!d[v]) { d[v] = d[u]+1; q.push(v); } } } ll sum = 0; for(int x=1;x<=n;x++) sum += d[x]; return sum; } int main() { scanf("%d",&n); for(int x=1;x<=n;x++) { int m; scanf("%d",&m); while(m--) { int y; scanf("%d",&y); way[y].push_back(x); } } ll ans = 1e9; for(int x=1;x<=n;x++) ans = min(ans, bfs(x)); printf("%lld",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | Output is correct |
2 | Correct | 2 ms | 752 KB | Output is correct |
3 | Incorrect | 2 ms | 752 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | Output is correct |
2 | Correct | 2 ms | 752 KB | Output is correct |
3 | Incorrect | 2 ms | 752 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | Output is correct |
2 | Correct | 2 ms | 752 KB | Output is correct |
3 | Incorrect | 2 ms | 752 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |