Submission #310669

# Submission time Handle Problem Language Result Execution time Memory
310669 2020-10-07T15:07:49 Z MrDomino Political Development (BOI17_politicaldevelopment) C++14
100 / 100
303 ms 9208 KB
#include <bits/stdc++.h>

using namespace std;

const int N=50000+7;
const int T=10;
int n;
int k;
vector<int> g[N];
bool active[N];
int deg[N];
set<pair<int,int>> _set_;
int sol;
int id[N];
int bits[1<<T];
int mask[1<<T];
int some_bit[1<<T];

bool is_edge(int x,int y)
{
        if (active[x]==0||active[y]==0)
                return 0;
        if ((int)g[x].size()>(int)g[y].size())
                swap(x,y);
        int l=0,r=(int)g[x].size()-1;
        while (l<=r)
        {
                int m=(l+r)/2;
                if (g[x][m]==y)
                        return 1;
                if (g[x][m]<y)
                        l=m+1;
                else
                        r=m-1;
        }
        return 0;
}

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

        for (int i=1;i<(1<<T);i++)
        {
                bits[i]=bits[i/2]+i%2;
                if (i&1)
                        some_bit[i]=1;
                else
                        some_bit[i]=2*some_bit[i/2];
        }
        /** read the input **/
        cin>>n>>k;
        for (int i=0;i<n;i++)
        {
                int len;
                cin>>len;
                g[i].resize(len);
                for (int j=0;j<len;j++)
                        cin>>g[i][j];
                sort(g[i].begin(),g[i].end());
                deg[i]=len;
                active[i]=1;
                _set_.insert({len,i});
        }

        for (int i=0;i<n;i++)
                id[i]=-1;

        /** maximum clique algorithm **/
        while (!_set_.empty())
        {
                int node=_set_.begin()->second;
                _set_.erase({deg[node],node});
                if (active[node]==0)
                        continue;
                for (auto &j:g[node])
                {
                        if (active[j])
                        {
                                _set_.erase({deg[j],j});
                                deg[j]--;
                                _set_.insert({deg[j],j});
                        }
                }
                active[node]=0;
                vector<int> real_g;
                for (auto &x : g[node])
                        if (active[x])
                                real_g.push_back(x);
                int t=(int) real_g.size();
                mask[0]=(1<<t);
                for (int i=1;i<(1<<t);i++)
                        mask[i]=0;
                for (int i=0;i<t;i++)
                        mask[1<<i]+=1<<i;
                for (int i=0;i<(int)real_g.size();i++)
                        for (int j=0;j<i;j++)
                                if (is_edge(real_g[i],real_g[j]))
                                        mask[1<<i]+=1<<j,
                                        mask[1<<j]+=1<<i;
                for (int i=1;i<(1<<t);i++)
                {
                        if (mask[i]==0)
                        {
                                int j=some_bit[i];
                                mask[i]=mask[j]&mask[i^j];
                        }
                        if ((mask[i]&i)==i)
                                sol=max(sol,bits[i]);
                }
        }
        sol++;
        cout<<sol<<"\n";
}
/**

war plan :
(.) get the node with minimum degree using a priority_queue
(.)
(.)
(.)
(.)
(.)
(.)
(.)
(.)
(.)
**/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 5 ms 2048 KB Output is correct
5 Correct 8 ms 2048 KB Output is correct
6 Correct 6 ms 2048 KB Output is correct
7 Correct 6 ms 1920 KB Output is correct
8 Correct 4 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 5 ms 2048 KB Output is correct
5 Correct 8 ms 2048 KB Output is correct
6 Correct 6 ms 2048 KB Output is correct
7 Correct 6 ms 1920 KB Output is correct
8 Correct 4 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
11 Correct 8 ms 1920 KB Output is correct
12 Correct 6 ms 1920 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 7 ms 2048 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 6 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 7 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 4 ms 1792 KB Output is correct
23 Correct 7 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 7 ms 1920 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 7 ms 1920 KB Output is correct
29 Correct 6 ms 1920 KB Output is correct
30 Correct 7 ms 1920 KB Output is correct
31 Correct 7 ms 1920 KB Output is correct
32 Correct 7 ms 1920 KB Output is correct
33 Correct 7 ms 1920 KB Output is correct
34 Correct 7 ms 2048 KB Output is correct
35 Correct 4 ms 1792 KB Output is correct
36 Correct 4 ms 1792 KB Output is correct
37 Correct 4 ms 1792 KB Output is correct
38 Correct 3 ms 1664 KB Output is correct
39 Correct 3 ms 1664 KB Output is correct
40 Correct 10 ms 1920 KB Output is correct
41 Correct 3 ms 1664 KB Output is correct
42 Correct 10 ms 2048 KB Output is correct
43 Correct 10 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1792 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 1 ms 1536 KB Output is correct
7 Correct 1 ms 1536 KB Output is correct
8 Correct 2 ms 1536 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 1 ms 1536 KB Output is correct
11 Correct 274 ms 6776 KB Output is correct
12 Correct 1 ms 1536 KB Output is correct
13 Correct 303 ms 6648 KB Output is correct
14 Correct 2 ms 1536 KB Output is correct
15 Correct 284 ms 6648 KB Output is correct
16 Correct 284 ms 6712 KB Output is correct
17 Correct 285 ms 6648 KB Output is correct
18 Correct 283 ms 6776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 5 ms 2048 KB Output is correct
5 Correct 8 ms 2048 KB Output is correct
6 Correct 6 ms 2048 KB Output is correct
7 Correct 6 ms 1920 KB Output is correct
8 Correct 4 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
11 Correct 8 ms 1920 KB Output is correct
12 Correct 6 ms 1920 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 7 ms 2048 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 6 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 7 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 4 ms 1792 KB Output is correct
23 Correct 7 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 7 ms 1920 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 7 ms 1920 KB Output is correct
29 Correct 6 ms 1920 KB Output is correct
30 Correct 7 ms 1920 KB Output is correct
31 Correct 7 ms 1920 KB Output is correct
32 Correct 7 ms 1920 KB Output is correct
33 Correct 7 ms 1920 KB Output is correct
34 Correct 7 ms 2048 KB Output is correct
35 Correct 4 ms 1792 KB Output is correct
36 Correct 4 ms 1792 KB Output is correct
37 Correct 4 ms 1792 KB Output is correct
38 Correct 3 ms 1664 KB Output is correct
39 Correct 3 ms 1664 KB Output is correct
40 Correct 10 ms 1920 KB Output is correct
41 Correct 3 ms 1664 KB Output is correct
42 Correct 10 ms 2048 KB Output is correct
43 Correct 10 ms 1920 KB Output is correct
44 Correct 13 ms 2048 KB Output is correct
45 Correct 1 ms 1536 KB Output is correct
46 Correct 10 ms 1920 KB Output is correct
47 Correct 20 ms 2048 KB Output is correct
48 Correct 11 ms 1920 KB Output is correct
49 Correct 18 ms 2048 KB Output is correct
50 Correct 18 ms 2168 KB Output is correct
51 Correct 38 ms 2304 KB Output is correct
52 Correct 6 ms 2048 KB Output is correct
53 Correct 34 ms 2176 KB Output is correct
54 Correct 46 ms 2176 KB Output is correct
55 Correct 6 ms 1920 KB Output is correct
56 Correct 6 ms 1920 KB Output is correct
57 Correct 3 ms 1792 KB Output is correct
58 Correct 34 ms 2176 KB Output is correct
59 Correct 8 ms 1920 KB Output is correct
60 Correct 6 ms 1920 KB Output is correct
61 Correct 8 ms 1920 KB Output is correct
62 Correct 8 ms 1920 KB Output is correct
63 Correct 13 ms 2048 KB Output is correct
64 Correct 12 ms 2048 KB Output is correct
65 Correct 9 ms 1920 KB Output is correct
66 Correct 8 ms 1920 KB Output is correct
67 Correct 23 ms 2048 KB Output is correct
68 Correct 12 ms 2048 KB Output is correct
69 Correct 9 ms 1920 KB Output is correct
70 Correct 16 ms 2048 KB Output is correct
71 Correct 21 ms 2048 KB Output is correct
72 Correct 20 ms 2048 KB Output is correct
73 Correct 6 ms 1920 KB Output is correct
74 Correct 17 ms 2048 KB Output is correct
75 Correct 21 ms 2048 KB Output is correct
76 Correct 12 ms 1920 KB Output is correct
77 Correct 26 ms 2048 KB Output is correct
78 Correct 6 ms 1920 KB Output is correct
79 Correct 13 ms 1792 KB Output is correct
80 Correct 11 ms 2048 KB Output is correct
81 Correct 26 ms 2048 KB Output is correct
82 Correct 3 ms 1664 KB Output is correct
83 Correct 13 ms 1792 KB Output is correct
84 Correct 20 ms 2176 KB Output is correct
85 Correct 3 ms 1664 KB Output is correct
86 Correct 19 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 6 ms 1920 KB Output is correct
4 Correct 5 ms 2048 KB Output is correct
5 Correct 8 ms 2048 KB Output is correct
6 Correct 6 ms 2048 KB Output is correct
7 Correct 6 ms 1920 KB Output is correct
8 Correct 4 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 4 ms 1792 KB Output is correct
11 Correct 8 ms 1920 KB Output is correct
12 Correct 6 ms 1920 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 7 ms 2048 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 6 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 7 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 4 ms 1792 KB Output is correct
23 Correct 7 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 7 ms 1920 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 7 ms 1920 KB Output is correct
29 Correct 6 ms 1920 KB Output is correct
30 Correct 7 ms 1920 KB Output is correct
31 Correct 7 ms 1920 KB Output is correct
32 Correct 7 ms 1920 KB Output is correct
33 Correct 7 ms 1920 KB Output is correct
34 Correct 7 ms 2048 KB Output is correct
35 Correct 4 ms 1792 KB Output is correct
36 Correct 4 ms 1792 KB Output is correct
37 Correct 4 ms 1792 KB Output is correct
38 Correct 3 ms 1664 KB Output is correct
39 Correct 3 ms 1664 KB Output is correct
40 Correct 10 ms 1920 KB Output is correct
41 Correct 3 ms 1664 KB Output is correct
42 Correct 10 ms 2048 KB Output is correct
43 Correct 10 ms 1920 KB Output is correct
44 Correct 1 ms 1664 KB Output is correct
45 Correct 177 ms 6288 KB Output is correct
46 Correct 80 ms 6008 KB Output is correct
47 Correct 190 ms 6264 KB Output is correct
48 Correct 181 ms 6264 KB Output is correct
49 Correct 55 ms 6144 KB Output is correct
50 Correct 161 ms 9080 KB Output is correct
51 Correct 183 ms 8104 KB Output is correct
52 Correct 55 ms 6780 KB Output is correct
53 Correct 56 ms 6784 KB Output is correct
54 Correct 20 ms 4352 KB Output is correct
55 Correct 161 ms 9208 KB Output is correct
56 Correct 41 ms 6272 KB Output is correct
57 Correct 55 ms 6800 KB Output is correct
58 Correct 77 ms 6952 KB Output is correct
59 Correct 42 ms 6264 KB Output is correct
60 Correct 48 ms 6392 KB Output is correct
61 Correct 69 ms 6776 KB Output is correct
62 Correct 57 ms 6520 KB Output is correct
63 Correct 139 ms 7168 KB Output is correct
64 Correct 41 ms 6272 KB Output is correct
65 Correct 136 ms 7544 KB Output is correct
66 Correct 58 ms 6520 KB Output is correct
67 Correct 110 ms 7032 KB Output is correct
68 Correct 132 ms 7288 KB Output is correct
69 Correct 137 ms 7416 KB Output is correct
70 Correct 61 ms 6520 KB Output is correct
71 Correct 139 ms 7416 KB Output is correct
72 Correct 88 ms 7032 KB Output is correct
73 Correct 151 ms 7548 KB Output is correct
74 Correct 61 ms 6520 KB Output is correct
75 Correct 51 ms 4300 KB Output is correct
76 Correct 91 ms 7160 KB Output is correct
77 Correct 163 ms 7544 KB Output is correct
78 Correct 65 ms 4472 KB Output is correct
79 Correct 50 ms 4352 KB Output is correct
80 Correct 24 ms 2944 KB Output is correct
81 Correct 66 ms 4600 KB Output is correct
82 Correct 122 ms 7168 KB Output is correct
83 Correct 23 ms 2944 KB Output is correct
84 Correct 114 ms 7168 KB Output is correct