Submission #1116012

# Submission time Handle Problem Language Result Execution time Memory
1116012 2024-11-21T07:43:00 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
169 ms 21236 KB
#include <bits/stdc++.h>
using namespace std;

#define isz(a) (int)(a).size()

const int NM = 5e4, KM = 10, BL = 320;

int N, K;
vector <int> adj[NM+5];
vector <vector <int> > clique[KM+5];

vector <int> common(vector <int> &a, vector <int> &b){
    vector <int> c = {};
    if (isz(a) > isz(b)){
        for (int i = 0; i < isz(b); i++){
            if (b[i] > a.back()) break;
            int j = lower_bound(a.begin(), a.end(), b[i])-a.begin();
            if (b[i] == a[j]) c.push_back(b[i]);
        }
    }
    else{
        for (int i = 0; i < isz(a); i++){
            if (a[i] > b.back()) break;
            int j = lower_bound(b.begin(), b.end(), a[i])-b.begin();
            if (a[i] == b[j]) c.push_back(a[i]);
        }
    }
    return c;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> K;
    for (int i = 0; i < N; i++){
        int k; cin >> k;
        adj[i].resize(k);
        for (int &j : adj[i]) cin >> j;
        sort(adj[i].begin(), adj[i].end());
    }
    for (int i = 0; i < N; i++) clique[1].push_back({i});
    for (int i = 1; i < K; i++){
        vector <int> vlist, arr_next;
        for (vector <int> arr : clique[i]){
            int mn = 0;
            for (int j = 1; j < i; j++)
                if (isz(adj[arr[j]]) < isz(adj[arr[mn]])) mn = j;
            vlist = adj[arr[mn]];
            for (int j = 0; j < i; j++)
                if (j != mn) vlist = common(vlist, adj[arr[j]]);
            for (int x : vlist){
                if (x <= arr.back()) continue;
                arr_next = arr;
                arr_next.push_back(x);
                clique[i+1].push_back(arr_next);
            }
        }
    }
    int res = K;
    while (isz(clique[res]) == 0) res--;
    cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 3 ms 2384 KB Output is correct
4 Correct 3 ms 2384 KB Output is correct
5 Correct 4 ms 2372 KB Output is correct
6 Correct 3 ms 2384 KB Output is correct
7 Correct 3 ms 2384 KB Output is correct
8 Correct 2 ms 1872 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 3 ms 2384 KB Output is correct
4 Correct 3 ms 2384 KB Output is correct
5 Correct 4 ms 2372 KB Output is correct
6 Correct 3 ms 2384 KB Output is correct
7 Correct 3 ms 2384 KB Output is correct
8 Correct 2 ms 1872 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1872 KB Output is correct
11 Correct 4 ms 2560 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 3 ms 2384 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 4 ms 2640 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 4 ms 2384 KB Output is correct
19 Correct 2 ms 1872 KB Output is correct
20 Correct 4 ms 2128 KB Output is correct
21 Correct 3 ms 2128 KB Output is correct
22 Correct 2 ms 1872 KB Output is correct
23 Correct 4 ms 2384 KB Output is correct
24 Correct 2 ms 1892 KB Output is correct
25 Correct 4 ms 2384 KB Output is correct
26 Correct 4 ms 2304 KB Output is correct
27 Correct 4 ms 2552 KB Output is correct
28 Correct 4 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 4 ms 2384 KB Output is correct
31 Correct 4 ms 2452 KB Output is correct
32 Correct 4 ms 2392 KB Output is correct
33 Correct 5 ms 2556 KB Output is correct
34 Correct 4 ms 2384 KB Output is correct
35 Correct 3 ms 1872 KB Output is correct
36 Correct 3 ms 1872 KB Output is correct
37 Correct 4 ms 1872 KB Output is correct
38 Correct 3 ms 1872 KB Output is correct
39 Correct 2 ms 1872 KB Output is correct
40 Correct 5 ms 2552 KB Output is correct
41 Correct 2 ms 1872 KB Output is correct
42 Correct 5 ms 2640 KB Output is correct
43 Correct 6 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1872 KB Output is correct
2 Correct 2 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 2 ms 1616 KB Output is correct
6 Correct 2 ms 1616 KB Output is correct
7 Correct 2 ms 1616 KB Output is correct
8 Correct 2 ms 1616 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1616 KB Output is correct
11 Correct 88 ms 19672 KB Output is correct
12 Correct 1 ms 1616 KB Output is correct
13 Correct 96 ms 19944 KB Output is correct
14 Correct 2 ms 1616 KB Output is correct
15 Correct 86 ms 19708 KB Output is correct
16 Correct 91 ms 19712 KB Output is correct
17 Correct 88 ms 21236 KB Output is correct
18 Correct 88 ms 19716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 3 ms 2384 KB Output is correct
4 Correct 3 ms 2384 KB Output is correct
5 Correct 4 ms 2372 KB Output is correct
6 Correct 3 ms 2384 KB Output is correct
7 Correct 3 ms 2384 KB Output is correct
8 Correct 2 ms 1872 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1872 KB Output is correct
11 Correct 4 ms 2560 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 3 ms 2384 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 4 ms 2640 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 4 ms 2384 KB Output is correct
19 Correct 2 ms 1872 KB Output is correct
20 Correct 4 ms 2128 KB Output is correct
21 Correct 3 ms 2128 KB Output is correct
22 Correct 2 ms 1872 KB Output is correct
23 Correct 4 ms 2384 KB Output is correct
24 Correct 2 ms 1892 KB Output is correct
25 Correct 4 ms 2384 KB Output is correct
26 Correct 4 ms 2304 KB Output is correct
27 Correct 4 ms 2552 KB Output is correct
28 Correct 4 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 4 ms 2384 KB Output is correct
31 Correct 4 ms 2452 KB Output is correct
32 Correct 4 ms 2392 KB Output is correct
33 Correct 5 ms 2556 KB Output is correct
34 Correct 4 ms 2384 KB Output is correct
35 Correct 3 ms 1872 KB Output is correct
36 Correct 3 ms 1872 KB Output is correct
37 Correct 4 ms 1872 KB Output is correct
38 Correct 3 ms 1872 KB Output is correct
39 Correct 2 ms 1872 KB Output is correct
40 Correct 5 ms 2552 KB Output is correct
41 Correct 2 ms 1872 KB Output is correct
42 Correct 5 ms 2640 KB Output is correct
43 Correct 6 ms 2640 KB Output is correct
44 Correct 137 ms 18704 KB Output is correct
45 Correct 2 ms 1616 KB Output is correct
46 Correct 7 ms 2640 KB Output is correct
47 Correct 11 ms 3212 KB Output is correct
48 Correct 6 ms 2640 KB Output is correct
49 Correct 11 ms 3212 KB Output is correct
50 Correct 11 ms 3384 KB Output is correct
51 Correct 29 ms 4872 KB Output is correct
52 Correct 4 ms 2384 KB Output is correct
53 Correct 20 ms 5280 KB Output is correct
54 Correct 38 ms 5128 KB Output is correct
55 Correct 4 ms 2384 KB Output is correct
56 Correct 4 ms 2384 KB Output is correct
57 Correct 2 ms 1872 KB Output is correct
58 Correct 19 ms 4872 KB Output is correct
59 Correct 10 ms 3468 KB Output is correct
60 Correct 4 ms 2556 KB Output is correct
61 Correct 11 ms 3468 KB Output is correct
62 Correct 10 ms 3468 KB Output is correct
63 Correct 169 ms 18640 KB Output is correct
64 Correct 67 ms 10748 KB Output is correct
65 Correct 5 ms 2640 KB Output is correct
66 Correct 10 ms 3468 KB Output is correct
67 Correct 61 ms 7016 KB Output is correct
68 Correct 68 ms 10748 KB Output is correct
69 Correct 5 ms 2640 KB Output is correct
70 Correct 14 ms 3592 KB Output is correct
71 Correct 60 ms 6964 KB Output is correct
72 Correct 36 ms 5384 KB Output is correct
73 Correct 4 ms 2416 KB Output is correct
74 Correct 17 ms 3424 KB Output is correct
75 Correct 37 ms 5384 KB Output is correct
76 Correct 7 ms 2712 KB Output is correct
77 Correct 13 ms 3760 KB Output is correct
78 Correct 4 ms 2384 KB Output is correct
79 Correct 12 ms 2444 KB Output is correct
80 Correct 7 ms 2700 KB Output is correct
81 Correct 13 ms 3592 KB Output is correct
82 Correct 2 ms 1872 KB Output is correct
83 Correct 8 ms 2700 KB Output is correct
84 Correct 10 ms 3336 KB Output is correct
85 Correct 3 ms 1872 KB Output is correct
86 Correct 11 ms 3336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 3 ms 2384 KB Output is correct
4 Correct 3 ms 2384 KB Output is correct
5 Correct 4 ms 2372 KB Output is correct
6 Correct 3 ms 2384 KB Output is correct
7 Correct 3 ms 2384 KB Output is correct
8 Correct 2 ms 1872 KB Output is correct
9 Correct 2 ms 1616 KB Output is correct
10 Correct 2 ms 1872 KB Output is correct
11 Correct 4 ms 2560 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
13 Correct 1 ms 1616 KB Output is correct
14 Correct 3 ms 2384 KB Output is correct
15 Correct 1 ms 1616 KB Output is correct
16 Correct 4 ms 2640 KB Output is correct
17 Correct 2 ms 1616 KB Output is correct
18 Correct 4 ms 2384 KB Output is correct
19 Correct 2 ms 1872 KB Output is correct
20 Correct 4 ms 2128 KB Output is correct
21 Correct 3 ms 2128 KB Output is correct
22 Correct 2 ms 1872 KB Output is correct
23 Correct 4 ms 2384 KB Output is correct
24 Correct 2 ms 1892 KB Output is correct
25 Correct 4 ms 2384 KB Output is correct
26 Correct 4 ms 2304 KB Output is correct
27 Correct 4 ms 2552 KB Output is correct
28 Correct 4 ms 2384 KB Output is correct
29 Correct 3 ms 2384 KB Output is correct
30 Correct 4 ms 2384 KB Output is correct
31 Correct 4 ms 2452 KB Output is correct
32 Correct 4 ms 2392 KB Output is correct
33 Correct 5 ms 2556 KB Output is correct
34 Correct 4 ms 2384 KB Output is correct
35 Correct 3 ms 1872 KB Output is correct
36 Correct 3 ms 1872 KB Output is correct
37 Correct 4 ms 1872 KB Output is correct
38 Correct 3 ms 1872 KB Output is correct
39 Correct 2 ms 1872 KB Output is correct
40 Correct 5 ms 2552 KB Output is correct
41 Correct 2 ms 1872 KB Output is correct
42 Correct 5 ms 2640 KB Output is correct
43 Correct 6 ms 2640 KB Output is correct
44 Correct 2 ms 1616 KB Output is correct
45 Correct 67 ms 17576 KB Output is correct
46 Correct 50 ms 12340 KB Output is correct
47 Correct 66 ms 17400 KB Output is correct
48 Correct 65 ms 17528 KB Output is correct
49 Correct 23 ms 9220 KB Output is correct
50 Correct 71 ms 19192 KB Output is correct
51 Correct 69 ms 17404 KB Output is correct
52 Correct 27 ms 9132 KB Output is correct
53 Correct 22 ms 8956 KB Output is correct
54 Correct 8 ms 4356 KB Output is correct
55 Correct 74 ms 19268 KB Output is correct
56 Correct 25 ms 7428 KB Output is correct
57 Correct 25 ms 8968 KB Output is correct
58 Correct 45 ms 13816 KB Output is correct
59 Correct 15 ms 7340 KB Output is correct
60 Correct 15 ms 7428 KB Output is correct
61 Correct 44 ms 13816 KB Output is correct
62 Correct 31 ms 9792 KB Output is correct
63 Correct 39 ms 11524 KB Output is correct
64 Correct 17 ms 7428 KB Output is correct
65 Correct 67 ms 13092 KB Output is correct
66 Correct 24 ms 9732 KB Output is correct
67 Correct 39 ms 11564 KB Output is correct
68 Correct 44 ms 12024 KB Output is correct
69 Correct 54 ms 13128 KB Output is correct
70 Correct 21 ms 8708 KB Output is correct
71 Correct 47 ms 12024 KB Output is correct
72 Correct 39 ms 11796 KB Output is correct
73 Correct 48 ms 13060 KB Output is correct
74 Correct 21 ms 8708 KB Output is correct
75 Correct 20 ms 6572 KB Output is correct
76 Correct 39 ms 11724 KB Output is correct
77 Correct 50 ms 13064 KB Output is correct
78 Correct 26 ms 7332 KB Output is correct
79 Correct 20 ms 6576 KB Output is correct
80 Correct 13 ms 4032 KB Output is correct
81 Correct 33 ms 7172 KB Output is correct
82 Correct 38 ms 11476 KB Output is correct
83 Correct 11 ms 4112 KB Output is correct
84 Correct 35 ms 11696 KB Output is correct