# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43163 | 2018-03-09T17:01:45 Z | win11905 | Bosses (BOI16_bosses) | C++11 | 1500 ms | 1004 KB |
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int MAXN = 5e3 + 5, MAXM = 1e4 + 5; int n, chk[MAXN], chkn[MAXM], dp[MAXN]; vector<pii> g[MAXN]; int dfs(int u, int x) { int sum = 0; for(auto v : g[u]) if(chkn[v.y] == x) { sum += dfs(v.x, x); } return dp[u] = ++sum; } int find(int x) { queue<int> Q; Q.emplace(x); chk[x] = x; while(!Q.empty()) { auto u = Q.front(); Q.pop(); for(auto v : g[u]) if(chk[v.x] != x) { chk[v.x] = chkn[v.y] = x; Q.push(v.x); } } dfs(x, x); int sum = 0; for(int i = 1; i <= n; ++i) { if(chk[i] != x) return 1000000000; sum += dp[i]; } return sum; } int main() { #ifdef INPUT freopen("r", "r", stdin); #endif scanf("%d", &n); int idx = 1; for(int i = 1; i <= n; ++i) { int t; scanf("%d", &t); while(t--) { int x; scanf("%d", &x); g[x].emplace_back(i, idx++); } } int mn = 1e9; for(int i = 1; i <= n; ++i) { int now = find(i); mn = min(mn ,now); } printf("%d\n", mn); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 480 KB | Output is correct |
3 | Correct | 2 ms | 680 KB | Output is correct |
4 | Correct | 1 ms | 680 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Correct | 2 ms | 692 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 480 KB | Output is correct |
3 | Correct | 2 ms | 680 KB | Output is correct |
4 | Correct | 1 ms | 680 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Correct | 2 ms | 692 KB | Output is correct |
7 | Correct | 2 ms | 692 KB | Output is correct |
8 | Correct | 2 ms | 692 KB | Output is correct |
9 | Correct | 2 ms | 712 KB | Output is correct |
10 | Correct | 2 ms | 712 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 480 KB | Output is correct |
3 | Correct | 2 ms | 680 KB | Output is correct |
4 | Correct | 1 ms | 680 KB | Output is correct |
5 | Correct | 2 ms | 680 KB | Output is correct |
6 | Correct | 2 ms | 692 KB | Output is correct |
7 | Correct | 2 ms | 692 KB | Output is correct |
8 | Correct | 2 ms | 692 KB | Output is correct |
9 | Correct | 2 ms | 712 KB | Output is correct |
10 | Correct | 2 ms | 712 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 16 ms | 876 KB | Output is correct |
13 | Correct | 11 ms | 876 KB | Output is correct |
14 | Correct | 327 ms | 952 KB | Output is correct |
15 | Correct | 7 ms | 952 KB | Output is correct |
16 | Correct | 1495 ms | 1004 KB | Output is correct |
17 | Execution timed out | 1556 ms | 1004 KB | Time limit exceeded |
18 | Halted | 0 ms | 0 KB | - |