# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49474 | 2018-05-29T11:38:13 Z | rzbt | Bosses (BOI16_bosses) | C++14 | 1500 ms | 1148 KB |
#include <bits/stdc++.h> #define MAXN 5005 #define pb push_back using namespace std; int n; vector<int> niz[MAXN]; vector<int> cudni[MAXN]; queue<int> q; bool posecen[MAXN]; int tp; void bfs(int t){ memset(posecen,0,sizeof(posecen)); for(int i=0;i<MAXN;i++)cudni[i].clear(); tp=0; q.push(t); posecen[t]=true; while(!q.empty()){ tp++; t=q.front(); q.pop(); for(auto x:niz[t]){ if(posecen[x])continue; cudni[t].pb(x); posecen[x]=true; q.push(x); } } } int res=1e9; int ucena; int dfs(int t){ int cena=1; for(auto x:cudni[t]) cena+=dfs(x); ucena+=cena; return cena; } int main() { scanf("%d", &n); for(int i=1;i<=n;i++){ int tk; scanf("%d", &tk); for(int j=0;j<tk;j++){ int t; scanf("%d", &t); niz[t].pb(i); } } for(int i=1;i<=n;i++){ bfs(i); if(tp!=n)continue; ucena=0; dfs(i); res=min(res,ucena); } printf("%d",res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 508 KB | Output is correct |
2 | Correct | 3 ms | 744 KB | Output is correct |
3 | Correct | 2 ms | 744 KB | Output is correct |
4 | Correct | 2 ms | 744 KB | Output is correct |
5 | Correct | 2 ms | 744 KB | Output is correct |
6 | Correct | 2 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 508 KB | Output is correct |
2 | Correct | 3 ms | 744 KB | Output is correct |
3 | Correct | 2 ms | 744 KB | Output is correct |
4 | Correct | 2 ms | 744 KB | Output is correct |
5 | Correct | 2 ms | 744 KB | Output is correct |
6 | Correct | 2 ms | 768 KB | Output is correct |
7 | Correct | 3 ms | 768 KB | Output is correct |
8 | Correct | 3 ms | 768 KB | Output is correct |
9 | Correct | 3 ms | 828 KB | Output is correct |
10 | Correct | 3 ms | 828 KB | Output is correct |
11 | Correct | 3 ms | 828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 508 KB | Output is correct |
2 | Correct | 3 ms | 744 KB | Output is correct |
3 | Correct | 2 ms | 744 KB | Output is correct |
4 | Correct | 2 ms | 744 KB | Output is correct |
5 | Correct | 2 ms | 744 KB | Output is correct |
6 | Correct | 2 ms | 768 KB | Output is correct |
7 | Correct | 3 ms | 768 KB | Output is correct |
8 | Correct | 3 ms | 768 KB | Output is correct |
9 | Correct | 3 ms | 828 KB | Output is correct |
10 | Correct | 3 ms | 828 KB | Output is correct |
11 | Correct | 3 ms | 828 KB | Output is correct |
12 | Correct | 10 ms | 892 KB | Output is correct |
13 | Correct | 7 ms | 892 KB | Output is correct |
14 | Correct | 218 ms | 1088 KB | Output is correct |
15 | Correct | 39 ms | 1088 KB | Output is correct |
16 | Correct | 778 ms | 1088 KB | Output is correct |
17 | Execution timed out | 1556 ms | 1148 KB | Time limit exceeded |
18 | Halted | 0 ms | 0 KB | - |