Submission #311274

# Submission time Handle Problem Language Result Execution time Memory
311274 2020-10-09T19:54:49 Z Vladth11 Political Development (BOI17_politicaldevelopment) C++14
100 / 100
2763 ms 29432 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> muchie;
 
const ll NMAX = 100005;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 101;
 
set <int> v[NMAX],st;
int maxim = 1,k;
int deg[NMAX];
set <pii> pq;
void afiseaza(int x){
    for(auto i : v[x])
        debug_with_space(i);
    cerr << "\n";
}
 
void clique(int i) {
    int nrbits = v[i].size();
    // debug(i);
    for(int mask = 1; mask < (1 << nrbits); mask++) {
        int cnt = 1;int bb = __builtin_popcount(mask);
        if(bb + 1 > k || bb + 1 < maxim)
            continue;
        int j = 0,cc = 0;
        st.clear();
        for(auto y : v[i]){
            if(mask & (1 << j))
                st.insert(y);
            j++;
        }
        j = 0;
        for(auto y : st){
            for(auto x : st){
                if(x != y && v[y].find(x) == v[y].end())
                    cnt = 0;
            }
        }
 
         //  debug_with_space(mask);
         //debug(cnt);
        if(cnt == 1)
            maxim = max(maxim, bb + 1);
    }
    //debug(maxim);
    for(auto x : v[i]){
        //if(pq.size())
        pq.erase({v[x].size(),x});
        v[x].erase(i);
        pq.insert({v[x].size(),x});
    }
    //debug(maxim);
}
 
struct cmp{
    bool operator()(int x, int y){
        return v[x].size() < v[y].size();
    }
};
int main() {
    // ifstream cin("catsfood.in");
    // ofstream cout("catsfood.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i, d;
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        int d;
        cin >> d;
        while(d--) {
            int x;
            cin >> x;
            v[i].insert(x + 1);
        }
    }
 
    for(i = 1; i <= n; i++) {
        pq.insert({v[i].size(),i});
    }
    while(!pq.empty()){
        int top = (*pq.begin()).second;
        pq.erase(pq.begin());
        clique(top);
    }
    cout << maxim;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'void clique(int)':
politicaldevelopment.cpp:32:19: warning: unused variable 'cc' [-Wunused-variable]
   32 |         int j = 0,cc = 0;
      |                   ^~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:73:15: warning: unused variable 'd' [-Wunused-variable]
   73 |     int n, i, d;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 9 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Correct 5 ms 5376 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 4 ms 5376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 9 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Correct 5 ms 5376 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 4 ms 5376 KB Output is correct
11 Correct 9 ms 5760 KB Output is correct
12 Correct 9 ms 5760 KB Output is correct
13 Correct 3 ms 4992 KB Output is correct
14 Correct 9 ms 5760 KB Output is correct
15 Correct 3 ms 4992 KB Output is correct
16 Correct 9 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 9 ms 5760 KB Output is correct
19 Correct 5 ms 5376 KB Output is correct
20 Correct 6 ms 5632 KB Output is correct
21 Correct 8 ms 5632 KB Output is correct
22 Correct 5 ms 5376 KB Output is correct
23 Correct 10 ms 5888 KB Output is correct
24 Correct 5 ms 5376 KB Output is correct
25 Correct 10 ms 5888 KB Output is correct
26 Correct 11 ms 5888 KB Output is correct
27 Correct 8 ms 5760 KB Output is correct
28 Correct 10 ms 5888 KB Output is correct
29 Correct 10 ms 5760 KB Output is correct
30 Correct 11 ms 6016 KB Output is correct
31 Correct 11 ms 6016 KB Output is correct
32 Correct 11 ms 6016 KB Output is correct
33 Correct 10 ms 6016 KB Output is correct
34 Correct 11 ms 6016 KB Output is correct
35 Correct 7 ms 5504 KB Output is correct
36 Correct 7 ms 5504 KB Output is correct
37 Correct 7 ms 5504 KB Output is correct
38 Correct 6 ms 5376 KB Output is correct
39 Correct 6 ms 5376 KB Output is correct
40 Correct 14 ms 6272 KB Output is correct
41 Correct 6 ms 5376 KB Output is correct
42 Correct 15 ms 6400 KB Output is correct
43 Correct 15 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5376 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 4 ms 4992 KB Output is correct
11 Correct 1217 ms 29432 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 1225 ms 29352 KB Output is correct
14 Correct 4 ms 4992 KB Output is correct
15 Correct 1259 ms 29348 KB Output is correct
16 Correct 1249 ms 29432 KB Output is correct
17 Correct 1260 ms 29432 KB Output is correct
18 Correct 1251 ms 29412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 9 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Correct 5 ms 5376 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 4 ms 5376 KB Output is correct
11 Correct 9 ms 5760 KB Output is correct
12 Correct 9 ms 5760 KB Output is correct
13 Correct 3 ms 4992 KB Output is correct
14 Correct 9 ms 5760 KB Output is correct
15 Correct 3 ms 4992 KB Output is correct
16 Correct 9 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 9 ms 5760 KB Output is correct
19 Correct 5 ms 5376 KB Output is correct
20 Correct 6 ms 5632 KB Output is correct
21 Correct 8 ms 5632 KB Output is correct
22 Correct 5 ms 5376 KB Output is correct
23 Correct 10 ms 5888 KB Output is correct
24 Correct 5 ms 5376 KB Output is correct
25 Correct 10 ms 5888 KB Output is correct
26 Correct 11 ms 5888 KB Output is correct
27 Correct 8 ms 5760 KB Output is correct
28 Correct 10 ms 5888 KB Output is correct
29 Correct 10 ms 5760 KB Output is correct
30 Correct 11 ms 6016 KB Output is correct
31 Correct 11 ms 6016 KB Output is correct
32 Correct 11 ms 6016 KB Output is correct
33 Correct 10 ms 6016 KB Output is correct
34 Correct 11 ms 6016 KB Output is correct
35 Correct 7 ms 5504 KB Output is correct
36 Correct 7 ms 5504 KB Output is correct
37 Correct 7 ms 5504 KB Output is correct
38 Correct 6 ms 5376 KB Output is correct
39 Correct 6 ms 5376 KB Output is correct
40 Correct 14 ms 6272 KB Output is correct
41 Correct 6 ms 5376 KB Output is correct
42 Correct 15 ms 6400 KB Output is correct
43 Correct 15 ms 6272 KB Output is correct
44 Correct 20 ms 7168 KB Output is correct
45 Correct 3 ms 4992 KB Output is correct
46 Correct 15 ms 6272 KB Output is correct
47 Correct 47 ms 7296 KB Output is correct
48 Correct 15 ms 6272 KB Output is correct
49 Correct 45 ms 7168 KB Output is correct
50 Correct 52 ms 7168 KB Output is correct
51 Correct 995 ms 9208 KB Output is correct
52 Correct 9 ms 5760 KB Output is correct
53 Correct 2763 ms 9720 KB Output is correct
54 Correct 2269 ms 10104 KB Output is correct
55 Correct 9 ms 5888 KB Output is correct
56 Correct 9 ms 5888 KB Output is correct
57 Correct 5 ms 5376 KB Output is correct
58 Correct 2633 ms 10048 KB Output is correct
59 Correct 12 ms 6400 KB Output is correct
60 Correct 10 ms 5888 KB Output is correct
61 Correct 12 ms 6400 KB Output is correct
62 Correct 12 ms 6400 KB Output is correct
63 Correct 21 ms 7424 KB Output is correct
64 Correct 19 ms 7168 KB Output is correct
65 Correct 13 ms 6272 KB Output is correct
66 Correct 12 ms 6400 KB Output is correct
67 Correct 101 ms 7808 KB Output is correct
68 Correct 18 ms 7168 KB Output is correct
69 Correct 13 ms 6272 KB Output is correct
70 Correct 25 ms 7168 KB Output is correct
71 Correct 94 ms 7808 KB Output is correct
72 Correct 72 ms 7680 KB Output is correct
73 Correct 8 ms 5888 KB Output is correct
74 Correct 26 ms 7296 KB Output is correct
75 Correct 78 ms 7932 KB Output is correct
76 Correct 22 ms 6784 KB Output is correct
77 Correct 327 ms 8320 KB Output is correct
78 Correct 9 ms 5888 KB Output is correct
79 Correct 162 ms 6720 KB Output is correct
80 Correct 22 ms 6784 KB Output is correct
81 Correct 334 ms 8568 KB Output is correct
82 Correct 6 ms 5376 KB Output is correct
83 Correct 166 ms 6776 KB Output is correct
84 Correct 113 ms 7724 KB Output is correct
85 Correct 6 ms 5376 KB Output is correct
86 Correct 31 ms 7680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 9 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Correct 5 ms 5376 KB Output is correct
9 Correct 3 ms 4992 KB Output is correct
10 Correct 4 ms 5376 KB Output is correct
11 Correct 9 ms 5760 KB Output is correct
12 Correct 9 ms 5760 KB Output is correct
13 Correct 3 ms 4992 KB Output is correct
14 Correct 9 ms 5760 KB Output is correct
15 Correct 3 ms 4992 KB Output is correct
16 Correct 9 ms 5760 KB Output is correct
17 Correct 3 ms 4992 KB Output is correct
18 Correct 9 ms 5760 KB Output is correct
19 Correct 5 ms 5376 KB Output is correct
20 Correct 6 ms 5632 KB Output is correct
21 Correct 8 ms 5632 KB Output is correct
22 Correct 5 ms 5376 KB Output is correct
23 Correct 10 ms 5888 KB Output is correct
24 Correct 5 ms 5376 KB Output is correct
25 Correct 10 ms 5888 KB Output is correct
26 Correct 11 ms 5888 KB Output is correct
27 Correct 8 ms 5760 KB Output is correct
28 Correct 10 ms 5888 KB Output is correct
29 Correct 10 ms 5760 KB Output is correct
30 Correct 11 ms 6016 KB Output is correct
31 Correct 11 ms 6016 KB Output is correct
32 Correct 11 ms 6016 KB Output is correct
33 Correct 10 ms 6016 KB Output is correct
34 Correct 11 ms 6016 KB Output is correct
35 Correct 7 ms 5504 KB Output is correct
36 Correct 7 ms 5504 KB Output is correct
37 Correct 7 ms 5504 KB Output is correct
38 Correct 6 ms 5376 KB Output is correct
39 Correct 6 ms 5376 KB Output is correct
40 Correct 14 ms 6272 KB Output is correct
41 Correct 6 ms 5376 KB Output is correct
42 Correct 15 ms 6400 KB Output is correct
43 Correct 15 ms 6272 KB Output is correct
44 Correct 3 ms 4992 KB Output is correct
45 Correct 283 ms 22424 KB Output is correct
46 Correct 113 ms 15224 KB Output is correct
47 Correct 303 ms 22264 KB Output is correct
48 Correct 285 ms 22520 KB Output is correct
49 Correct 74 ms 12792 KB Output is correct
50 Correct 460 ms 27048 KB Output is correct
51 Correct 293 ms 22264 KB Output is correct
52 Correct 69 ms 12792 KB Output is correct
53 Correct 80 ms 12920 KB Output is correct
54 Correct 20 ms 8312 KB Output is correct
55 Correct 472 ms 26876 KB Output is correct
56 Correct 42 ms 10492 KB Output is correct
57 Correct 70 ms 12920 KB Output is correct
58 Correct 87 ms 15224 KB Output is correct
59 Correct 42 ms 10488 KB Output is correct
60 Correct 43 ms 10616 KB Output is correct
61 Correct 88 ms 15224 KB Output is correct
62 Correct 66 ms 12920 KB Output is correct
63 Correct 135 ms 16376 KB Output is correct
64 Correct 43 ms 10488 KB Output is correct
65 Correct 179 ms 18808 KB Output is correct
66 Correct 64 ms 12928 KB Output is correct
67 Correct 134 ms 16376 KB Output is correct
68 Correct 178 ms 18188 KB Output is correct
69 Correct 185 ms 18680 KB Output is correct
70 Correct 76 ms 12792 KB Output is correct
71 Correct 179 ms 18168 KB Output is correct
72 Correct 137 ms 15992 KB Output is correct
73 Correct 234 ms 20344 KB Output is correct
74 Correct 71 ms 12792 KB Output is correct
75 Correct 70 ms 11232 KB Output is correct
76 Correct 138 ms 15996 KB Output is correct
77 Correct 239 ms 20344 KB Output is correct
78 Correct 104 ms 12668 KB Output is correct
79 Correct 71 ms 11136 KB Output is correct
80 Correct 33 ms 8064 KB Output is correct
81 Correct 104 ms 12664 KB Output is correct
82 Correct 154 ms 17528 KB Output is correct
83 Correct 34 ms 8064 KB Output is correct
84 Correct 152 ms 17612 KB Output is correct