Submission #208537

# Submission time Handle Problem Language Result Execution time Memory
208537 2020-03-11T13:21:25 Z eriksuenderhauf Political Development (BOI17_politicaldevelopment) C++11
100 / 100
430 ms 31088 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
set<int> adj[MAXN];
bool vis[MAXN];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    priority_queue<pii, vii, greater<pii>> pq;
    for (int i = 0; i < n; i++) {
        int d;
        scanf("%d", &d);
        pq.push({d, i});
        for (int j = 0; j < d; j++) {
            int u;
            scanf("%d", &u);
            adj[i].insert(u);
        }
    }
    int ans = 1;
    while (!pq.empty()) {
        pii cur = pq.top(); pq.pop();
        int u = cur.se;
        if (vis[u]) 
            continue;
        vis[u] = 1;
        vi tmp = {u};
        for (auto it = adj[u].begin(); it != adj[u].end(); it++) {
            if (!vis[*it]) {
                pq.push({adj[*it].size() - 1, *it});
                tmp.pb(*it);
            }
        }
        bool mrk[11][11] = {};
        for (int i = 0; i < tmp.size(); i++) {
            mrk[i][i] = 1;
            for (int j = 0; j < tmp.size(); j++)
                if (i != j && adj[tmp[i]].find(tmp[j]) != adj[tmp[i]].end())
                    mrk[i][j] = 1;
        }
        int sz = tmp.size();
        for (int j = 1; j < (1 << sz); j += 2) {
            bool fl = 1;
            int cnt = 0;
            for (int l = 0; l < sz; l++) {
                if ((j >> l) % 2 == 0) continue;
                cnt++;
                for (int a = 0; a < sz; a++) {
                    if ((j >> a) % 2 == 0) continue;
                    if (mrk[l][a] == 0)
                        fl = 0;
                }
                if (fl == 0) break;
            }
            if (fl)
                ans = max(ans, cnt);
        }
        for (int j: tmp) {
            if (adj[j].find(u) != adj[j].end())
                adj[j].erase(adj[j].find(u));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:67:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < tmp.size(); i++) {
                         ~~^~~~~~~~~~~~
politicaldevelopment.cpp:69:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < tmp.size(); j++)
                             ~~^~~~~~~~~~~~
politicaldevelopment.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &d);
         ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &u);
             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 13 ms 5624 KB Output is correct
4 Correct 13 ms 5624 KB Output is correct
5 Correct 13 ms 5624 KB Output is correct
6 Correct 13 ms 5624 KB Output is correct
7 Correct 14 ms 5624 KB Output is correct
8 Correct 9 ms 5112 KB Output is correct
9 Correct 8 ms 4984 KB Output is correct
10 Correct 10 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 13 ms 5624 KB Output is correct
4 Correct 13 ms 5624 KB Output is correct
5 Correct 13 ms 5624 KB Output is correct
6 Correct 13 ms 5624 KB Output is correct
7 Correct 14 ms 5624 KB Output is correct
8 Correct 9 ms 5112 KB Output is correct
9 Correct 8 ms 4984 KB Output is correct
10 Correct 10 ms 5112 KB Output is correct
11 Correct 14 ms 5624 KB Output is correct
12 Correct 13 ms 5624 KB Output is correct
13 Correct 8 ms 4984 KB Output is correct
14 Correct 13 ms 5624 KB Output is correct
15 Correct 7 ms 4984 KB Output is correct
16 Correct 13 ms 5624 KB Output is correct
17 Correct 7 ms 4984 KB Output is correct
18 Correct 13 ms 5624 KB Output is correct
19 Correct 9 ms 5112 KB Output is correct
20 Correct 11 ms 5372 KB Output is correct
21 Correct 12 ms 5368 KB Output is correct
22 Correct 9 ms 5116 KB Output is correct
23 Correct 15 ms 5752 KB Output is correct
24 Correct 9 ms 5112 KB Output is correct
25 Correct 15 ms 5752 KB Output is correct
26 Correct 14 ms 5624 KB Output is correct
27 Correct 14 ms 5624 KB Output is correct
28 Correct 13 ms 5624 KB Output is correct
29 Correct 12 ms 5624 KB Output is correct
30 Correct 16 ms 5752 KB Output is correct
31 Correct 15 ms 5752 KB Output is correct
32 Correct 15 ms 5752 KB Output is correct
33 Correct 15 ms 5752 KB Output is correct
34 Correct 17 ms 5752 KB Output is correct
35 Correct 12 ms 5496 KB Output is correct
36 Correct 11 ms 5368 KB Output is correct
37 Correct 11 ms 5368 KB Output is correct
38 Correct 10 ms 5368 KB Output is correct
39 Correct 10 ms 5240 KB Output is correct
40 Correct 19 ms 6172 KB Output is correct
41 Correct 10 ms 5240 KB Output is correct
42 Correct 18 ms 6172 KB Output is correct
43 Correct 18 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5112 KB Output is correct
2 Correct 8 ms 4984 KB Output is correct
3 Correct 8 ms 4984 KB Output is correct
4 Correct 7 ms 4984 KB Output is correct
5 Correct 8 ms 4984 KB Output is correct
6 Correct 8 ms 4984 KB Output is correct
7 Correct 8 ms 4984 KB Output is correct
8 Correct 7 ms 4984 KB Output is correct
9 Correct 8 ms 4984 KB Output is correct
10 Correct 8 ms 4984 KB Output is correct
11 Correct 430 ms 30948 KB Output is correct
12 Correct 7 ms 4984 KB Output is correct
13 Correct 405 ms 30956 KB Output is correct
14 Correct 8 ms 4984 KB Output is correct
15 Correct 416 ms 30952 KB Output is correct
16 Correct 412 ms 30952 KB Output is correct
17 Correct 429 ms 31088 KB Output is correct
18 Correct 417 ms 30956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 13 ms 5624 KB Output is correct
4 Correct 13 ms 5624 KB Output is correct
5 Correct 13 ms 5624 KB Output is correct
6 Correct 13 ms 5624 KB Output is correct
7 Correct 14 ms 5624 KB Output is correct
8 Correct 9 ms 5112 KB Output is correct
9 Correct 8 ms 4984 KB Output is correct
10 Correct 10 ms 5112 KB Output is correct
11 Correct 14 ms 5624 KB Output is correct
12 Correct 13 ms 5624 KB Output is correct
13 Correct 8 ms 4984 KB Output is correct
14 Correct 13 ms 5624 KB Output is correct
15 Correct 7 ms 4984 KB Output is correct
16 Correct 13 ms 5624 KB Output is correct
17 Correct 7 ms 4984 KB Output is correct
18 Correct 13 ms 5624 KB Output is correct
19 Correct 9 ms 5112 KB Output is correct
20 Correct 11 ms 5372 KB Output is correct
21 Correct 12 ms 5368 KB Output is correct
22 Correct 9 ms 5116 KB Output is correct
23 Correct 15 ms 5752 KB Output is correct
24 Correct 9 ms 5112 KB Output is correct
25 Correct 15 ms 5752 KB Output is correct
26 Correct 14 ms 5624 KB Output is correct
27 Correct 14 ms 5624 KB Output is correct
28 Correct 13 ms 5624 KB Output is correct
29 Correct 12 ms 5624 KB Output is correct
30 Correct 16 ms 5752 KB Output is correct
31 Correct 15 ms 5752 KB Output is correct
32 Correct 15 ms 5752 KB Output is correct
33 Correct 15 ms 5752 KB Output is correct
34 Correct 17 ms 5752 KB Output is correct
35 Correct 12 ms 5496 KB Output is correct
36 Correct 11 ms 5368 KB Output is correct
37 Correct 11 ms 5368 KB Output is correct
38 Correct 10 ms 5368 KB Output is correct
39 Correct 10 ms 5240 KB Output is correct
40 Correct 19 ms 6172 KB Output is correct
41 Correct 10 ms 5240 KB Output is correct
42 Correct 18 ms 6172 KB Output is correct
43 Correct 18 ms 6172 KB Output is correct
44 Correct 69 ms 7288 KB Output is correct
45 Correct 8 ms 4984 KB Output is correct
46 Correct 18 ms 6136 KB Output is correct
47 Correct 32 ms 7416 KB Output is correct
48 Correct 19 ms 6264 KB Output is correct
49 Correct 32 ms 7420 KB Output is correct
50 Correct 33 ms 7416 KB Output is correct
51 Correct 143 ms 9716 KB Output is correct
52 Correct 13 ms 5624 KB Output is correct
53 Correct 261 ms 10228 KB Output is correct
54 Correct 282 ms 10228 KB Output is correct
55 Correct 13 ms 5624 KB Output is correct
56 Correct 13 ms 5624 KB Output is correct
57 Correct 9 ms 5112 KB Output is correct
58 Correct 257 ms 10352 KB Output is correct
59 Correct 17 ms 6136 KB Output is correct
60 Correct 13 ms 5628 KB Output is correct
61 Correct 17 ms 6136 KB Output is correct
62 Correct 17 ms 6136 KB Output is correct
63 Correct 67 ms 7160 KB Output is correct
64 Correct 39 ms 6904 KB Output is correct
65 Correct 17 ms 6136 KB Output is correct
66 Correct 17 ms 6136 KB Output is correct
67 Correct 53 ms 7800 KB Output is correct
68 Correct 40 ms 6904 KB Output is correct
69 Correct 17 ms 6136 KB Output is correct
70 Correct 29 ms 7032 KB Output is correct
71 Correct 58 ms 7800 KB Output is correct
72 Correct 44 ms 7800 KB Output is correct
73 Correct 12 ms 5624 KB Output is correct
74 Correct 30 ms 7160 KB Output is correct
75 Correct 44 ms 7800 KB Output is correct
76 Correct 24 ms 6648 KB Output is correct
77 Correct 66 ms 8312 KB Output is correct
78 Correct 13 ms 5624 KB Output is correct
79 Correct 37 ms 6652 KB Output is correct
80 Correct 25 ms 6520 KB Output is correct
81 Correct 67 ms 8312 KB Output is correct
82 Correct 10 ms 5240 KB Output is correct
83 Correct 37 ms 6776 KB Output is correct
84 Correct 41 ms 7672 KB Output is correct
85 Correct 10 ms 5240 KB Output is correct
86 Correct 41 ms 7704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4984 KB Output is correct
2 Correct 7 ms 4984 KB Output is correct
3 Correct 13 ms 5624 KB Output is correct
4 Correct 13 ms 5624 KB Output is correct
5 Correct 13 ms 5624 KB Output is correct
6 Correct 13 ms 5624 KB Output is correct
7 Correct 14 ms 5624 KB Output is correct
8 Correct 9 ms 5112 KB Output is correct
9 Correct 8 ms 4984 KB Output is correct
10 Correct 10 ms 5112 KB Output is correct
11 Correct 14 ms 5624 KB Output is correct
12 Correct 13 ms 5624 KB Output is correct
13 Correct 8 ms 4984 KB Output is correct
14 Correct 13 ms 5624 KB Output is correct
15 Correct 7 ms 4984 KB Output is correct
16 Correct 13 ms 5624 KB Output is correct
17 Correct 7 ms 4984 KB Output is correct
18 Correct 13 ms 5624 KB Output is correct
19 Correct 9 ms 5112 KB Output is correct
20 Correct 11 ms 5372 KB Output is correct
21 Correct 12 ms 5368 KB Output is correct
22 Correct 9 ms 5116 KB Output is correct
23 Correct 15 ms 5752 KB Output is correct
24 Correct 9 ms 5112 KB Output is correct
25 Correct 15 ms 5752 KB Output is correct
26 Correct 14 ms 5624 KB Output is correct
27 Correct 14 ms 5624 KB Output is correct
28 Correct 13 ms 5624 KB Output is correct
29 Correct 12 ms 5624 KB Output is correct
30 Correct 16 ms 5752 KB Output is correct
31 Correct 15 ms 5752 KB Output is correct
32 Correct 15 ms 5752 KB Output is correct
33 Correct 15 ms 5752 KB Output is correct
34 Correct 17 ms 5752 KB Output is correct
35 Correct 12 ms 5496 KB Output is correct
36 Correct 11 ms 5368 KB Output is correct
37 Correct 11 ms 5368 KB Output is correct
38 Correct 10 ms 5368 KB Output is correct
39 Correct 10 ms 5240 KB Output is correct
40 Correct 19 ms 6172 KB Output is correct
41 Correct 10 ms 5240 KB Output is correct
42 Correct 18 ms 6172 KB Output is correct
43 Correct 18 ms 6172 KB Output is correct
44 Correct 8 ms 4984 KB Output is correct
45 Correct 221 ms 23200 KB Output is correct
46 Correct 113 ms 13552 KB Output is correct
47 Correct 229 ms 23008 KB Output is correct
48 Correct 225 ms 23020 KB Output is correct
49 Correct 67 ms 10864 KB Output is correct
50 Correct 282 ms 28400 KB Output is correct
51 Correct 228 ms 23020 KB Output is correct
52 Correct 67 ms 10860 KB Output is correct
53 Correct 69 ms 10864 KB Output is correct
54 Correct 21 ms 5748 KB Output is correct
55 Correct 287 ms 28268 KB Output is correct
56 Correct 42 ms 8176 KB Output is correct
57 Correct 67 ms 10784 KB Output is correct
58 Correct 88 ms 13424 KB Output is correct
59 Correct 42 ms 8172 KB Output is correct
60 Correct 42 ms 8176 KB Output is correct
61 Correct 87 ms 13556 KB Output is correct
62 Correct 68 ms 10868 KB Output is correct
63 Correct 126 ms 15472 KB Output is correct
64 Correct 45 ms 8176 KB Output is correct
65 Correct 164 ms 18032 KB Output is correct
66 Correct 65 ms 10868 KB Output is correct
67 Correct 126 ms 15464 KB Output is correct
68 Correct 157 ms 17388 KB Output is correct
69 Correct 166 ms 18032 KB Output is correct
70 Correct 66 ms 10864 KB Output is correct
71 Correct 159 ms 17392 KB Output is correct
72 Correct 139 ms 14960 KB Output is correct
73 Correct 184 ms 19828 KB Output is correct
74 Correct 64 ms 10864 KB Output is correct
75 Correct 67 ms 10740 KB Output is correct
76 Correct 137 ms 14960 KB Output is correct
77 Correct 182 ms 19828 KB Output is correct
78 Correct 87 ms 12404 KB Output is correct
79 Correct 66 ms 10744 KB Output is correct
80 Correct 35 ms 7928 KB Output is correct
81 Correct 87 ms 12404 KB Output is correct
82 Correct 132 ms 16756 KB Output is correct
83 Correct 36 ms 7804 KB Output is correct
84 Correct 136 ms 16752 KB Output is correct