Submission #467902

# Submission time Handle Problem Language Result Execution time Memory
467902 2021-08-25T14:38:53 Z JovanB Political Development (BOI17_politicaldevelopment) C++17
100 / 100
307 ms 28556 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

const int N = 50000;

set <int> graf[N+5];

bool ima[15][15];
bool moze[(1<<15)];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> q;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        for(int j=1; j<=x; j++){
            int y;
            cin >> y;
            y++;
            graf[i].insert(y);
        }
        q.push({graf[i].size(), i});
    }
    int res = 1;
    while(!q.empty()){
        int v = q.top().second;
        int deg = q.top().first;
        q.pop();
        if(graf[v].size() != deg) continue;
        vector <int> vec;
        for(auto c : graf[v]) vec.push_back(c);
        for(int i=0; i<deg; i++){
            for(int j=i+1; j<deg; j++){
                ima[i][j] = ima[j][i] = 0;
                if(graf[vec[i]].find(vec[j]) != graf[vec[i]].end()) ima[i][j] = ima[j][i] = 1;
            }
        }
        for(int mask=1; mask<(1<<deg); mask++) moze[mask] = 0;
        moze[0] = 1;
        for(int mask=0; mask<(1<<deg); mask++){
            for(int j=0; j<deg; j++){
                if((1 << j) & mask){
                    int x = mask ^ (1 << j);
                    if(!moze[x]) break;
                    moze[mask] = 1;
                    for(int k=j+1; k<deg; k++) if((1 << k) & mask) moze[mask] &= ima[j][k];
                    break;
                }
            }
            if(moze[mask]) res = max(res, 1 + __builtin_popcount(mask));
        }
        for(auto c : graf[v]){
            graf[c].erase(v);
            q.push({graf[c].size(), c});
        }
        graf[v].clear();
    }
    cout << res << "\n";
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:38:27: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if(graf[v].size() != deg) continue;
      |            ~~~~~~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 7 ms 3148 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 7 ms 3184 KB Output is correct
6 Correct 6 ms 3240 KB Output is correct
7 Correct 6 ms 3148 KB Output is correct
8 Correct 3 ms 2676 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 7 ms 3148 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 7 ms 3184 KB Output is correct
6 Correct 6 ms 3240 KB Output is correct
7 Correct 6 ms 3148 KB Output is correct
8 Correct 3 ms 2676 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 6 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3188 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 8 ms 3244 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3148 KB Output is correct
19 Correct 3 ms 2676 KB Output is correct
20 Correct 4 ms 2892 KB Output is correct
21 Correct 4 ms 2892 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 7 ms 3276 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 7 ms 3276 KB Output is correct
26 Correct 7 ms 3304 KB Output is correct
27 Correct 6 ms 3148 KB Output is correct
28 Correct 7 ms 3276 KB Output is correct
29 Correct 6 ms 3148 KB Output is correct
30 Correct 8 ms 3404 KB Output is correct
31 Correct 7 ms 3404 KB Output is correct
32 Correct 8 ms 3420 KB Output is correct
33 Correct 8 ms 3404 KB Output is correct
34 Correct 8 ms 3532 KB Output is correct
35 Correct 5 ms 2936 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 4 ms 3020 KB Output is correct
38 Correct 4 ms 2892 KB Output is correct
39 Correct 4 ms 2892 KB Output is correct
40 Correct 10 ms 3856 KB Output is correct
41 Correct 4 ms 2892 KB Output is correct
42 Correct 11 ms 3788 KB Output is correct
43 Correct 11 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2764 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 270 ms 28384 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 307 ms 28556 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 272 ms 28424 KB Output is correct
16 Correct 288 ms 28456 KB Output is correct
17 Correct 281 ms 28532 KB Output is correct
18 Correct 269 ms 28416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 7 ms 3148 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 7 ms 3184 KB Output is correct
6 Correct 6 ms 3240 KB Output is correct
7 Correct 6 ms 3148 KB Output is correct
8 Correct 3 ms 2676 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 6 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3188 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 8 ms 3244 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3148 KB Output is correct
19 Correct 3 ms 2676 KB Output is correct
20 Correct 4 ms 2892 KB Output is correct
21 Correct 4 ms 2892 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 7 ms 3276 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 7 ms 3276 KB Output is correct
26 Correct 7 ms 3304 KB Output is correct
27 Correct 6 ms 3148 KB Output is correct
28 Correct 7 ms 3276 KB Output is correct
29 Correct 6 ms 3148 KB Output is correct
30 Correct 8 ms 3404 KB Output is correct
31 Correct 7 ms 3404 KB Output is correct
32 Correct 8 ms 3420 KB Output is correct
33 Correct 8 ms 3404 KB Output is correct
34 Correct 8 ms 3532 KB Output is correct
35 Correct 5 ms 2936 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 4 ms 3020 KB Output is correct
38 Correct 4 ms 2892 KB Output is correct
39 Correct 4 ms 2892 KB Output is correct
40 Correct 10 ms 3856 KB Output is correct
41 Correct 4 ms 2892 KB Output is correct
42 Correct 11 ms 3788 KB Output is correct
43 Correct 11 ms 3832 KB Output is correct
44 Correct 24 ms 4684 KB Output is correct
45 Correct 2 ms 2672 KB Output is correct
46 Correct 11 ms 3828 KB Output is correct
47 Correct 20 ms 5068 KB Output is correct
48 Correct 11 ms 3788 KB Output is correct
49 Correct 23 ms 5040 KB Output is correct
50 Correct 20 ms 4996 KB Output is correct
51 Correct 50 ms 7360 KB Output is correct
52 Correct 6 ms 3148 KB Output is correct
53 Correct 65 ms 7868 KB Output is correct
54 Correct 65 ms 7800 KB Output is correct
55 Correct 6 ms 3148 KB Output is correct
56 Correct 6 ms 3148 KB Output is correct
57 Correct 3 ms 2680 KB Output is correct
58 Correct 64 ms 7648 KB Output is correct
59 Correct 10 ms 3660 KB Output is correct
60 Correct 6 ms 3148 KB Output is correct
61 Correct 9 ms 3704 KB Output is correct
62 Correct 9 ms 3660 KB Output is correct
63 Correct 25 ms 4792 KB Output is correct
64 Correct 18 ms 4524 KB Output is correct
65 Correct 10 ms 3636 KB Output is correct
66 Correct 11 ms 3704 KB Output is correct
67 Correct 27 ms 5480 KB Output is correct
68 Correct 18 ms 4428 KB Output is correct
69 Correct 9 ms 3660 KB Output is correct
70 Correct 18 ms 4684 KB Output is correct
71 Correct 28 ms 5444 KB Output is correct
72 Correct 25 ms 5324 KB Output is correct
73 Correct 6 ms 3148 KB Output is correct
74 Correct 19 ms 4716 KB Output is correct
75 Correct 25 ms 5420 KB Output is correct
76 Correct 14 ms 4212 KB Output is correct
77 Correct 30 ms 5964 KB Output is correct
78 Correct 6 ms 3148 KB Output is correct
79 Correct 17 ms 4344 KB Output is correct
80 Correct 17 ms 4176 KB Output is correct
81 Correct 32 ms 5952 KB Output is correct
82 Correct 4 ms 2940 KB Output is correct
83 Correct 17 ms 4356 KB Output is correct
84 Correct 22 ms 5284 KB Output is correct
85 Correct 4 ms 2892 KB Output is correct
86 Correct 23 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 7 ms 3148 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 7 ms 3184 KB Output is correct
6 Correct 6 ms 3240 KB Output is correct
7 Correct 6 ms 3148 KB Output is correct
8 Correct 3 ms 2676 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 6 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3188 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 8 ms 3244 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3148 KB Output is correct
19 Correct 3 ms 2676 KB Output is correct
20 Correct 4 ms 2892 KB Output is correct
21 Correct 4 ms 2892 KB Output is correct
22 Correct 3 ms 2764 KB Output is correct
23 Correct 7 ms 3276 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 7 ms 3276 KB Output is correct
26 Correct 7 ms 3304 KB Output is correct
27 Correct 6 ms 3148 KB Output is correct
28 Correct 7 ms 3276 KB Output is correct
29 Correct 6 ms 3148 KB Output is correct
30 Correct 8 ms 3404 KB Output is correct
31 Correct 7 ms 3404 KB Output is correct
32 Correct 8 ms 3420 KB Output is correct
33 Correct 8 ms 3404 KB Output is correct
34 Correct 8 ms 3532 KB Output is correct
35 Correct 5 ms 2936 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 4 ms 3020 KB Output is correct
38 Correct 4 ms 2892 KB Output is correct
39 Correct 4 ms 2892 KB Output is correct
40 Correct 10 ms 3856 KB Output is correct
41 Correct 4 ms 2892 KB Output is correct
42 Correct 11 ms 3788 KB Output is correct
43 Correct 11 ms 3832 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 209 ms 20524 KB Output is correct
46 Correct 88 ms 11068 KB Output is correct
47 Correct 195 ms 20744 KB Output is correct
48 Correct 183 ms 20588 KB Output is correct
49 Correct 48 ms 8380 KB Output is correct
50 Correct 224 ms 25964 KB Output is correct
51 Correct 183 ms 20524 KB Output is correct
52 Correct 50 ms 8380 KB Output is correct
53 Correct 51 ms 8308 KB Output is correct
54 Correct 11 ms 3408 KB Output is correct
55 Correct 225 ms 25756 KB Output is correct
56 Correct 26 ms 5748 KB Output is correct
57 Correct 48 ms 8392 KB Output is correct
58 Correct 63 ms 10940 KB Output is correct
59 Correct 30 ms 5792 KB Output is correct
60 Correct 28 ms 5828 KB Output is correct
61 Correct 66 ms 10984 KB Output is correct
62 Correct 47 ms 8420 KB Output is correct
63 Correct 98 ms 12960 KB Output is correct
64 Correct 26 ms 5736 KB Output is correct
65 Correct 124 ms 15564 KB Output is correct
66 Correct 47 ms 8400 KB Output is correct
67 Correct 99 ms 12960 KB Output is correct
68 Correct 113 ms 14908 KB Output is correct
69 Correct 126 ms 15556 KB Output is correct
70 Correct 49 ms 8348 KB Output is correct
71 Correct 116 ms 14908 KB Output is correct
72 Correct 102 ms 12576 KB Output is correct
73 Correct 132 ms 17208 KB Output is correct
74 Correct 46 ms 8396 KB Output is correct
75 Correct 53 ms 8240 KB Output is correct
76 Correct 100 ms 12504 KB Output is correct
77 Correct 134 ms 17276 KB Output is correct
78 Correct 61 ms 9920 KB Output is correct
79 Correct 45 ms 8284 KB Output is correct
80 Correct 23 ms 5416 KB Output is correct
81 Correct 63 ms 9940 KB Output is correct
82 Correct 98 ms 14268 KB Output is correct
83 Correct 24 ms 5496 KB Output is correct
84 Correct 112 ms 14268 KB Output is correct