# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405174 | 2021-05-15T20:20:25 Z | T0p_ | Bosses (BOI16_bosses) | C++14 | 1 ms | 588 KB |
#include <bits/stdc++.h> using namespace std; int ans; int deg_in[5050], deg_out[5050], sub[5050]; bool mark[5050], pushed[5050]; vector<int> g[5050], gt[5050], edge[5050]; void dfs(int u) { sub[u] = 1; for(auto x : edge[u]) { dfs(x); sub[u] += sub[x]; } ans += sub[u]; } int main() { int n; scanf(" %d",&n); for(int i=1 ; i<=n ; i++) { scanf(" %d",°_in[i]); for(int j=1 ; j<=deg_in[i] ; j++) { int d; scanf(" %d",&d); g[d].push_back(i); gt[i].push_back(d); deg_out[d]++; } } int root; for(int i=1 ; i<=n ; i++) { int u = 0; for(int j=1 ; j<=n ; j++) { if(mark[j]) continue; if(deg_out[j] > deg_out[u]) u = j; } mark[u] = true; if(i == 1) root = u; for(auto x : g[u]) { if(mark[x] || pushed[x]) continue; pushed[x] = true; edge[u].push_back(x); } for(auto x : gt[u]) { deg_out[x]--; } } dfs(root); printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Incorrect | 1 ms | 588 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Incorrect | 1 ms | 588 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Incorrect | 1 ms | 588 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |