# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39775 | 2018-01-18T13:06:25 Z | nonocut | Bosses (BOI16_bosses) | C++14 | 0 ms | 2316 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 5e3 + 5; int n; int vis[maxn]; long long val[maxn]; vector<int> way[maxn], p[maxn]; queue<int> q; void dfs(int u) { for(auto v : p[u]) dfs(v), val[u] += val[v]; val[u]++; } ll bfs(int u) { int i; memset(vis,0,sizeof(vis)); memset(val,0,sizeof(val)); for(i=1;i<=n;i++) p[i].clear(); vis[u] = 1; q.push(u); while(!q.empty()) { int x = q.front(); q.pop(); for(auto y : way[x]) { if(!vis[y]) { vis[y] = 1; p[x].push_back(y); q.push(y); } } } dfs(u); long long ans = 0; for(i=1;i<=n;i++) ans += val[i]; return ans; } int main() { int i,x,k; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&k); while(k--) { scanf("%d",&x); way[x].push_back(i); } } ll ans = (long long)1e18; for(i=1;i<=n;i++) ans = min(ans, bfs(i)); printf("%lld",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2316 KB | Output is correct |
2 | Correct | 0 ms | 2316 KB | Output is correct |
3 | Incorrect | 0 ms | 2316 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2316 KB | Output is correct |
2 | Correct | 0 ms | 2316 KB | Output is correct |
3 | Incorrect | 0 ms | 2316 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2316 KB | Output is correct |
2 | Correct | 0 ms | 2316 KB | Output is correct |
3 | Incorrect | 0 ms | 2316 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |