# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203627 | 2020-02-21T16:34:15 Z | karma | Political Development (BOI17_politicaldevelopment) | C++14 | 1053 ms | 70288 KB |
#include<bits/stdc++.h> #define ll long long #define pb emplace_back #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; typedef pair<int, int> pii; const int N = (int)5e4 + 2; priority_queue<pii, vector<pii>, greater<pii>> pq; int n, k, d, u, cnt, res, ans; int deg[N], lab[N], id[N]; bool del[N], ok; vector<int> adj[N], r[N]; map<pii, bool> edges; pii top; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define FileName "test" if(fopen(FileName".inp", "r")) { freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); } cin >> n >> k; for(int i = 0; i < n; ++i) { cin >> d; adj[i].resize(d); for(int& c: adj[i]) { cin >> c, edges[{i, c}] = 1; r[c].pb(i); } deg[i] = d; pq.push(mp(deg[i], i)); } res = 1; while(pq.size()) { top = pq.top(); pq.pop(); if(top.fi != deg[top.se]) continue; u = top.se; cnt = 0; for(int v: adj[u]) { if(del[v] || !edges[{v, u}]) continue; id[lab[v] = cnt ++] = v; } for(int i = 0; i < (1 << cnt); ++i) { if((ans = __builtin_popcount(i)) < res) continue; ok = 1; for(int j = 0; j < cnt; ++j) { if(!(i >> j & 1)) continue; for(int k = j + 1; k < cnt; ++k) { if((i >> k & 1) && !edges[{id[j], id[k]}]) ok = 0; } if(!ok) break; } if(ok) res = ans + 1; } del[u] = 1; for(int v: r[u]) { if(del[v]) continue; --deg[v]; pq.push(mp(deg[v], v)); } } cout << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 6 ms | 2680 KB | Output is correct |
3 | Correct | 13 ms | 3704 KB | Output is correct |
4 | Correct | 11 ms | 3832 KB | Output is correct |
5 | Correct | 12 ms | 3832 KB | Output is correct |
6 | Correct | 12 ms | 3832 KB | Output is correct |
7 | Correct | 13 ms | 3832 KB | Output is correct |
8 | Correct | 6 ms | 2808 KB | Output is correct |
9 | Correct | 7 ms | 2680 KB | Output is correct |
10 | Correct | 7 ms | 2808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 6 ms | 2680 KB | Output is correct |
3 | Correct | 13 ms | 3704 KB | Output is correct |
4 | Correct | 11 ms | 3832 KB | Output is correct |
5 | Correct | 12 ms | 3832 KB | Output is correct |
6 | Correct | 12 ms | 3832 KB | Output is correct |
7 | Correct | 13 ms | 3832 KB | Output is correct |
8 | Correct | 6 ms | 2808 KB | Output is correct |
9 | Correct | 7 ms | 2680 KB | Output is correct |
10 | Correct | 7 ms | 2808 KB | Output is correct |
11 | Correct | 12 ms | 3704 KB | Output is correct |
12 | Correct | 11 ms | 3704 KB | Output is correct |
13 | Correct | 6 ms | 2680 KB | Output is correct |
14 | Correct | 12 ms | 3832 KB | Output is correct |
15 | Correct | 6 ms | 2680 KB | Output is correct |
16 | Correct | 13 ms | 3832 KB | Output is correct |
17 | Correct | 6 ms | 2680 KB | Output is correct |
18 | Correct | 17 ms | 3832 KB | Output is correct |
19 | Correct | 7 ms | 2808 KB | Output is correct |
20 | Correct | 10 ms | 3448 KB | Output is correct |
21 | Correct | 10 ms | 3448 KB | Output is correct |
22 | Correct | 7 ms | 2808 KB | Output is correct |
23 | Correct | 15 ms | 3960 KB | Output is correct |
24 | Correct | 7 ms | 2808 KB | Output is correct |
25 | Correct | 15 ms | 3960 KB | Output is correct |
26 | Correct | 15 ms | 3960 KB | Output is correct |
27 | Correct | 12 ms | 3704 KB | Output is correct |
28 | Correct | 14 ms | 3960 KB | Output is correct |
29 | Correct | 13 ms | 3832 KB | Output is correct |
30 | Correct | 18 ms | 4216 KB | Output is correct |
31 | Correct | 16 ms | 4088 KB | Output is correct |
32 | Correct | 15 ms | 4220 KB | Output is correct |
33 | Correct | 16 ms | 4092 KB | Output is correct |
34 | Correct | 16 ms | 4088 KB | Output is correct |
35 | Correct | 10 ms | 3448 KB | Output is correct |
36 | Correct | 11 ms | 3452 KB | Output is correct |
37 | Correct | 12 ms | 3448 KB | Output is correct |
38 | Correct | 9 ms | 3224 KB | Output is correct |
39 | Correct | 9 ms | 3192 KB | Output is correct |
40 | Correct | 20 ms | 4600 KB | Output is correct |
41 | Correct | 9 ms | 3192 KB | Output is correct |
42 | Correct | 20 ms | 4600 KB | Output is correct |
43 | Correct | 20 ms | 4728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2808 KB | Output is correct |
2 | Correct | 6 ms | 2680 KB | Output is correct |
3 | Correct | 6 ms | 2680 KB | Output is correct |
4 | Correct | 7 ms | 2680 KB | Output is correct |
5 | Correct | 6 ms | 2680 KB | Output is correct |
6 | Correct | 6 ms | 2680 KB | Output is correct |
7 | Correct | 6 ms | 2680 KB | Output is correct |
8 | Correct | 6 ms | 2680 KB | Output is correct |
9 | Correct | 7 ms | 2680 KB | Output is correct |
10 | Correct | 7 ms | 2680 KB | Output is correct |
11 | Correct | 1053 ms | 70244 KB | Output is correct |
12 | Correct | 6 ms | 2680 KB | Output is correct |
13 | Correct | 1050 ms | 70288 KB | Output is correct |
14 | Correct | 6 ms | 2680 KB | Output is correct |
15 | Correct | 1032 ms | 70248 KB | Output is correct |
16 | Correct | 1020 ms | 70244 KB | Output is correct |
17 | Correct | 1049 ms | 70244 KB | Output is correct |
18 | Correct | 1033 ms | 70244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 6 ms | 2680 KB | Output is correct |
3 | Correct | 13 ms | 3704 KB | Output is correct |
4 | Correct | 11 ms | 3832 KB | Output is correct |
5 | Correct | 12 ms | 3832 KB | Output is correct |
6 | Correct | 12 ms | 3832 KB | Output is correct |
7 | Correct | 13 ms | 3832 KB | Output is correct |
8 | Correct | 6 ms | 2808 KB | Output is correct |
9 | Correct | 7 ms | 2680 KB | Output is correct |
10 | Correct | 7 ms | 2808 KB | Output is correct |
11 | Correct | 12 ms | 3704 KB | Output is correct |
12 | Correct | 11 ms | 3704 KB | Output is correct |
13 | Correct | 6 ms | 2680 KB | Output is correct |
14 | Correct | 12 ms | 3832 KB | Output is correct |
15 | Correct | 6 ms | 2680 KB | Output is correct |
16 | Correct | 13 ms | 3832 KB | Output is correct |
17 | Correct | 6 ms | 2680 KB | Output is correct |
18 | Correct | 17 ms | 3832 KB | Output is correct |
19 | Correct | 7 ms | 2808 KB | Output is correct |
20 | Correct | 10 ms | 3448 KB | Output is correct |
21 | Correct | 10 ms | 3448 KB | Output is correct |
22 | Correct | 7 ms | 2808 KB | Output is correct |
23 | Correct | 15 ms | 3960 KB | Output is correct |
24 | Correct | 7 ms | 2808 KB | Output is correct |
25 | Correct | 15 ms | 3960 KB | Output is correct |
26 | Correct | 15 ms | 3960 KB | Output is correct |
27 | Correct | 12 ms | 3704 KB | Output is correct |
28 | Correct | 14 ms | 3960 KB | Output is correct |
29 | Correct | 13 ms | 3832 KB | Output is correct |
30 | Correct | 18 ms | 4216 KB | Output is correct |
31 | Correct | 16 ms | 4088 KB | Output is correct |
32 | Correct | 15 ms | 4220 KB | Output is correct |
33 | Correct | 16 ms | 4092 KB | Output is correct |
34 | Correct | 16 ms | 4088 KB | Output is correct |
35 | Correct | 10 ms | 3448 KB | Output is correct |
36 | Correct | 11 ms | 3452 KB | Output is correct |
37 | Correct | 12 ms | 3448 KB | Output is correct |
38 | Correct | 9 ms | 3224 KB | Output is correct |
39 | Correct | 9 ms | 3192 KB | Output is correct |
40 | Correct | 20 ms | 4600 KB | Output is correct |
41 | Correct | 9 ms | 3192 KB | Output is correct |
42 | Correct | 20 ms | 4600 KB | Output is correct |
43 | Correct | 20 ms | 4728 KB | Output is correct |
44 | Correct | 30 ms | 6136 KB | Output is correct |
45 | Correct | 6 ms | 2680 KB | Output is correct |
46 | Correct | 20 ms | 4732 KB | Output is correct |
47 | Correct | 51 ms | 7796 KB | Output is correct |
48 | Correct | 19 ms | 4728 KB | Output is correct |
49 | Correct | 47 ms | 7668 KB | Output is correct |
50 | Correct | 48 ms | 7796 KB | Output is correct |
51 | Correct | 392 ms | 17776 KB | Output is correct |
52 | Correct | 12 ms | 3832 KB | Output is correct |
53 | Correct | 749 ms | 10868 KB | Output is correct |
54 | Correct | 722 ms | 20848 KB | Output is correct |
55 | Correct | 13 ms | 3832 KB | Output is correct |
56 | Correct | 12 ms | 3832 KB | Output is correct |
57 | Correct | 7 ms | 2808 KB | Output is correct |
58 | Correct | 682 ms | 10744 KB | Output is correct |
59 | Correct | 18 ms | 4472 KB | Output is correct |
60 | Correct | 12 ms | 3836 KB | Output is correct |
61 | Correct | 18 ms | 4472 KB | Output is correct |
62 | Correct | 18 ms | 4472 KB | Output is correct |
63 | Correct | 29 ms | 6136 KB | Output is correct |
64 | Correct | 26 ms | 5752 KB | Output is correct |
65 | Correct | 18 ms | 4472 KB | Output is correct |
66 | Correct | 18 ms | 4472 KB | Output is correct |
67 | Correct | 69 ms | 9080 KB | Output is correct |
68 | Correct | 27 ms | 5752 KB | Output is correct |
69 | Correct | 18 ms | 4344 KB | Output is correct |
70 | Correct | 31 ms | 6136 KB | Output is correct |
71 | Correct | 70 ms | 9076 KB | Output is correct |
72 | Correct | 59 ms | 8440 KB | Output is correct |
73 | Correct | 13 ms | 3832 KB | Output is correct |
74 | Correct | 31 ms | 6264 KB | Output is correct |
75 | Correct | 61 ms | 8568 KB | Output is correct |
76 | Correct | 28 ms | 5496 KB | Output is correct |
77 | Correct | 180 ms | 12532 KB | Output is correct |
78 | Correct | 13 ms | 3832 KB | Output is correct |
79 | Correct | 81 ms | 7544 KB | Output is correct |
80 | Correct | 26 ms | 5368 KB | Output is correct |
81 | Correct | 179 ms | 12532 KB | Output is correct |
82 | Correct | 9 ms | 3192 KB | Output is correct |
83 | Correct | 80 ms | 7572 KB | Output is correct |
84 | Correct | 78 ms | 9336 KB | Output is correct |
85 | Correct | 9 ms | 3192 KB | Output is correct |
86 | Correct | 39 ms | 7032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 6 ms | 2680 KB | Output is correct |
3 | Correct | 13 ms | 3704 KB | Output is correct |
4 | Correct | 11 ms | 3832 KB | Output is correct |
5 | Correct | 12 ms | 3832 KB | Output is correct |
6 | Correct | 12 ms | 3832 KB | Output is correct |
7 | Correct | 13 ms | 3832 KB | Output is correct |
8 | Correct | 6 ms | 2808 KB | Output is correct |
9 | Correct | 7 ms | 2680 KB | Output is correct |
10 | Correct | 7 ms | 2808 KB | Output is correct |
11 | Correct | 12 ms | 3704 KB | Output is correct |
12 | Correct | 11 ms | 3704 KB | Output is correct |
13 | Correct | 6 ms | 2680 KB | Output is correct |
14 | Correct | 12 ms | 3832 KB | Output is correct |
15 | Correct | 6 ms | 2680 KB | Output is correct |
16 | Correct | 13 ms | 3832 KB | Output is correct |
17 | Correct | 6 ms | 2680 KB | Output is correct |
18 | Correct | 17 ms | 3832 KB | Output is correct |
19 | Correct | 7 ms | 2808 KB | Output is correct |
20 | Correct | 10 ms | 3448 KB | Output is correct |
21 | Correct | 10 ms | 3448 KB | Output is correct |
22 | Correct | 7 ms | 2808 KB | Output is correct |
23 | Correct | 15 ms | 3960 KB | Output is correct |
24 | Correct | 7 ms | 2808 KB | Output is correct |
25 | Correct | 15 ms | 3960 KB | Output is correct |
26 | Correct | 15 ms | 3960 KB | Output is correct |
27 | Correct | 12 ms | 3704 KB | Output is correct |
28 | Correct | 14 ms | 3960 KB | Output is correct |
29 | Correct | 13 ms | 3832 KB | Output is correct |
30 | Correct | 18 ms | 4216 KB | Output is correct |
31 | Correct | 16 ms | 4088 KB | Output is correct |
32 | Correct | 15 ms | 4220 KB | Output is correct |
33 | Correct | 16 ms | 4092 KB | Output is correct |
34 | Correct | 16 ms | 4088 KB | Output is correct |
35 | Correct | 10 ms | 3448 KB | Output is correct |
36 | Correct | 11 ms | 3452 KB | Output is correct |
37 | Correct | 12 ms | 3448 KB | Output is correct |
38 | Correct | 9 ms | 3224 KB | Output is correct |
39 | Correct | 9 ms | 3192 KB | Output is correct |
40 | Correct | 20 ms | 4600 KB | Output is correct |
41 | Correct | 9 ms | 3192 KB | Output is correct |
42 | Correct | 20 ms | 4600 KB | Output is correct |
43 | Correct | 20 ms | 4728 KB | Output is correct |
44 | Correct | 7 ms | 2680 KB | Output is correct |
45 | Correct | 398 ms | 35428 KB | Output is correct |
46 | Correct | 173 ms | 17264 KB | Output is correct |
47 | Correct | 422 ms | 36712 KB | Output is correct |
48 | Correct | 410 ms | 35940 KB | Output is correct |
49 | Correct | 84 ms | 13808 KB | Output is correct |
50 | Correct | 410 ms | 37228 KB | Output is correct |
51 | Correct | 412 ms | 36464 KB | Output is correct |
52 | Correct | 86 ms | 14064 KB | Output is correct |
53 | Correct | 92 ms | 13876 KB | Output is correct |
54 | Correct | 14 ms | 3576 KB | Output is correct |
55 | Correct | 419 ms | 37228 KB | Output is correct |
56 | Correct | 62 ms | 10224 KB | Output is correct |
57 | Correct | 82 ms | 14064 KB | Output is correct |
58 | Correct | 148 ms | 17264 KB | Output is correct |
59 | Correct | 63 ms | 10180 KB | Output is correct |
60 | Correct | 64 ms | 10144 KB | Output is correct |
61 | Correct | 140 ms | 17008 KB | Output is correct |
62 | Correct | 102 ms | 13680 KB | Output is correct |
63 | Correct | 202 ms | 19568 KB | Output is correct |
64 | Correct | 64 ms | 10220 KB | Output is correct |
65 | Correct | 268 ms | 23664 KB | Output is correct |
66 | Correct | 106 ms | 13552 KB | Output is correct |
67 | Correct | 201 ms | 19696 KB | Output is correct |
68 | Correct | 261 ms | 23720 KB | Output is correct |
69 | Correct | 252 ms | 23796 KB | Output is correct |
70 | Correct | 109 ms | 13556 KB | Output is correct |
71 | Correct | 261 ms | 23940 KB | Output is correct |
72 | Correct | 195 ms | 19568 KB | Output is correct |
73 | Correct | 370 ms | 32876 KB | Output is correct |
74 | Correct | 107 ms | 13556 KB | Output is correct |
75 | Correct | 110 ms | 13296 KB | Output is correct |
76 | Correct | 212 ms | 20348 KB | Output is correct |
77 | Correct | 365 ms | 32620 KB | Output is correct |
78 | Correct | 164 ms | 17644 KB | Output is correct |
79 | Correct | 120 ms | 13296 KB | Output is correct |
80 | Correct | 44 ms | 8056 KB | Output is correct |
81 | Correct | 158 ms | 17648 KB | Output is correct |
82 | Correct | 236 ms | 22256 KB | Output is correct |
83 | Correct | 43 ms | 8180 KB | Output is correct |
84 | Correct | 225 ms | 21872 KB | Output is correct |