Submission #400150

# Submission time Handle Problem Language Result Execution time Memory
400150 2021-05-07T13:12:01 Z johutha Political Development (BOI17_politicaldevelopment) C++14
54 / 100
3000 ms 33168 KB
#include <iostream>
#include <vector>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <set>
 
#define bs bitset<10>
 
using namespace std;
 
struct findcliq
{
    int n;
    bitset<1024> b;
    vector<bitset<1024>> adjmat;
 
    int find()
    {
        assert(n <= 10);
        b[0] = 1;
        int mmax = 0;
 
        for (int i = 1; i < (1<<n); i++)
        {
            for (int ad = 0; ad < n; ad++)
            {
                if (!(i & (1<<ad))) continue;
                int ls = i - (1<<ad);
                if (!b[ls]) continue;
                bool ok = true;
                for (int in = 0; in < n; in++)
                {
                    if ((1<<in) & ls)
                    {
                        if (!adjmat[in][ad]) ok = false;
                    }
                }
                b[i] = b[i] | ok;
            }
            if (b[i]) mmax = max(mmax, (int)__builtin_popcount(i));
        }
        return mmax;
    }
 
    void print()
    {
        cout << n << "\n";
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                cout << adjmat[i][j];
            }
            cout << "\n";
        }
        cout << "\n";
    }
};
 
struct graph
{
    int n;
    vector<unordered_set<int>> adjset;
    multiset<pair<int,int>> act;
 
    int solve()
    {
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            act.insert({adjset[i].size(), i});
        }
 
        while (!act.empty())
        {
            int curr = act.begin()->second;
            act.erase(act.begin());
 
            int sz = adjset[curr].size() + 1;
 
            findcliq fq;
            fq.n = sz;
            fq.adjmat.resize(n, bitset<1024>());
 
            vector<int> all(adjset[curr].begin(), adjset[curr].end());
            all.push_back(curr);
 
            for (int i = 0; i < sz; i++)
            {
                for (int j = 0; j < sz; j++)
                {
                    fq.adjmat[i][j] = adjset[all[i]].count(all[j]);
                }
            }
 
            for (auto next : adjset[curr])
            {
                act.erase({adjset[next].size(), next});
                adjset[next].erase(curr);
                act.insert({adjset[next].size(), next});
            }
            res = max(res, fq.find());
        }
        return res;
    }
};
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
 
    graph g;
    g.n = n;
    g.adjset.resize(n);
 
    for (int i = 0; i < n; i++)
    {
        int cnt;
        cin >> cnt;
        for (int j = 0; j < cnt; j++)
        {
            int a;
            cin >> a;
            g.adjset[i].insert(a);
        }
    }
    cout << g.solve() << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 118 ms 2008 KB Output is correct
4 Correct 116 ms 2008 KB Output is correct
5 Correct 118 ms 2008 KB Output is correct
6 Correct 121 ms 2008 KB Output is correct
7 Correct 117 ms 2012 KB Output is correct
8 Correct 113 ms 1484 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 109 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 118 ms 2008 KB Output is correct
4 Correct 116 ms 2008 KB Output is correct
5 Correct 118 ms 2008 KB Output is correct
6 Correct 121 ms 2008 KB Output is correct
7 Correct 117 ms 2012 KB Output is correct
8 Correct 113 ms 1484 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 109 ms 1484 KB Output is correct
11 Correct 128 ms 2008 KB Output is correct
12 Correct 114 ms 2008 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 122 ms 2008 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 123 ms 2008 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 118 ms 1952 KB Output is correct
19 Correct 109 ms 1488 KB Output is correct
20 Correct 114 ms 1752 KB Output is correct
21 Correct 112 ms 1752 KB Output is correct
22 Correct 115 ms 1368 KB Output is correct
23 Correct 121 ms 2012 KB Output is correct
24 Correct 122 ms 1372 KB Output is correct
25 Correct 119 ms 2108 KB Output is correct
26 Correct 117 ms 2012 KB Output is correct
27 Correct 118 ms 1996 KB Output is correct
28 Correct 117 ms 1984 KB Output is correct
29 Correct 129 ms 1996 KB Output is correct
30 Correct 118 ms 2136 KB Output is correct
31 Correct 122 ms 2112 KB Output is correct
32 Correct 124 ms 2136 KB Output is correct
33 Correct 121 ms 2136 KB Output is correct
34 Correct 122 ms 2136 KB Output is correct
35 Correct 32 ms 1228 KB Output is correct
36 Correct 33 ms 1228 KB Output is correct
37 Correct 40 ms 1228 KB Output is correct
38 Correct 12 ms 848 KB Output is correct
39 Correct 13 ms 848 KB Output is correct
40 Correct 139 ms 2384 KB Output is correct
41 Correct 11 ms 816 KB Output is correct
42 Correct 123 ms 2376 KB Output is correct
43 Correct 136 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 1368 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Execution timed out 3090 ms 33168 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 118 ms 2008 KB Output is correct
4 Correct 116 ms 2008 KB Output is correct
5 Correct 118 ms 2008 KB Output is correct
6 Correct 121 ms 2008 KB Output is correct
7 Correct 117 ms 2012 KB Output is correct
8 Correct 113 ms 1484 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 109 ms 1484 KB Output is correct
11 Correct 128 ms 2008 KB Output is correct
12 Correct 114 ms 2008 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 122 ms 2008 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 123 ms 2008 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 118 ms 1952 KB Output is correct
19 Correct 109 ms 1488 KB Output is correct
20 Correct 114 ms 1752 KB Output is correct
21 Correct 112 ms 1752 KB Output is correct
22 Correct 115 ms 1368 KB Output is correct
23 Correct 121 ms 2012 KB Output is correct
24 Correct 122 ms 1372 KB Output is correct
25 Correct 119 ms 2108 KB Output is correct
26 Correct 117 ms 2012 KB Output is correct
27 Correct 118 ms 1996 KB Output is correct
28 Correct 117 ms 1984 KB Output is correct
29 Correct 129 ms 1996 KB Output is correct
30 Correct 118 ms 2136 KB Output is correct
31 Correct 122 ms 2112 KB Output is correct
32 Correct 124 ms 2136 KB Output is correct
33 Correct 121 ms 2136 KB Output is correct
34 Correct 122 ms 2136 KB Output is correct
35 Correct 32 ms 1228 KB Output is correct
36 Correct 33 ms 1228 KB Output is correct
37 Correct 40 ms 1228 KB Output is correct
38 Correct 12 ms 848 KB Output is correct
39 Correct 13 ms 848 KB Output is correct
40 Correct 139 ms 2384 KB Output is correct
41 Correct 11 ms 816 KB Output is correct
42 Correct 123 ms 2376 KB Output is correct
43 Correct 136 ms 2388 KB Output is correct
44 Correct 236 ms 3336 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 125 ms 2392 KB Output is correct
47 Correct 139 ms 3288 KB Output is correct
48 Correct 124 ms 2372 KB Output is correct
49 Correct 136 ms 3288 KB Output is correct
50 Correct 142 ms 3372 KB Output is correct
51 Correct 241 ms 5200 KB Output is correct
52 Correct 118 ms 2008 KB Output is correct
53 Correct 372 ms 5668 KB Output is correct
54 Correct 399 ms 5712 KB Output is correct
55 Correct 116 ms 2008 KB Output is correct
56 Correct 114 ms 2008 KB Output is correct
57 Correct 110 ms 1368 KB Output is correct
58 Correct 366 ms 5708 KB Output is correct
59 Correct 121 ms 2392 KB Output is correct
60 Correct 125 ms 2008 KB Output is correct
61 Correct 123 ms 2392 KB Output is correct
62 Correct 119 ms 2372 KB Output is correct
63 Correct 235 ms 3292 KB Output is correct
64 Correct 171 ms 3152 KB Output is correct
65 Correct 120 ms 2268 KB Output is correct
66 Correct 122 ms 2392 KB Output is correct
67 Correct 177 ms 3676 KB Output is correct
68 Correct 171 ms 3160 KB Output is correct
69 Correct 119 ms 2264 KB Output is correct
70 Correct 146 ms 3112 KB Output is correct
71 Correct 178 ms 3676 KB Output is correct
72 Correct 159 ms 3624 KB Output is correct
73 Correct 114 ms 1996 KB Output is correct
74 Correct 139 ms 3216 KB Output is correct
75 Correct 162 ms 3676 KB Output is correct
76 Correct 126 ms 2776 KB Output is correct
77 Correct 182 ms 4184 KB Output is correct
78 Correct 115 ms 1996 KB Output is correct
79 Correct 58 ms 2252 KB Output is correct
80 Correct 128 ms 2776 KB Output is correct
81 Correct 176 ms 4184 KB Output is correct
82 Correct 10 ms 840 KB Output is correct
83 Correct 59 ms 2252 KB Output is correct
84 Correct 152 ms 3568 KB Output is correct
85 Correct 10 ms 844 KB Output is correct
86 Correct 149 ms 3544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 118 ms 2008 KB Output is correct
4 Correct 116 ms 2008 KB Output is correct
5 Correct 118 ms 2008 KB Output is correct
6 Correct 121 ms 2008 KB Output is correct
7 Correct 117 ms 2012 KB Output is correct
8 Correct 113 ms 1484 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 109 ms 1484 KB Output is correct
11 Correct 128 ms 2008 KB Output is correct
12 Correct 114 ms 2008 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 122 ms 2008 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 123 ms 2008 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 118 ms 1952 KB Output is correct
19 Correct 109 ms 1488 KB Output is correct
20 Correct 114 ms 1752 KB Output is correct
21 Correct 112 ms 1752 KB Output is correct
22 Correct 115 ms 1368 KB Output is correct
23 Correct 121 ms 2012 KB Output is correct
24 Correct 122 ms 1372 KB Output is correct
25 Correct 119 ms 2108 KB Output is correct
26 Correct 117 ms 2012 KB Output is correct
27 Correct 118 ms 1996 KB Output is correct
28 Correct 117 ms 1984 KB Output is correct
29 Correct 129 ms 1996 KB Output is correct
30 Correct 118 ms 2136 KB Output is correct
31 Correct 122 ms 2112 KB Output is correct
32 Correct 124 ms 2136 KB Output is correct
33 Correct 121 ms 2136 KB Output is correct
34 Correct 122 ms 2136 KB Output is correct
35 Correct 32 ms 1228 KB Output is correct
36 Correct 33 ms 1228 KB Output is correct
37 Correct 40 ms 1228 KB Output is correct
38 Correct 12 ms 848 KB Output is correct
39 Correct 13 ms 848 KB Output is correct
40 Correct 139 ms 2384 KB Output is correct
41 Correct 11 ms 816 KB Output is correct
42 Correct 123 ms 2376 KB Output is correct
43 Correct 136 ms 2388 KB Output is correct
44 Correct 1 ms 208 KB Output is correct
45 Execution timed out 3086 ms 26608 KB Time limit exceeded
46 Halted 0 ms 0 KB -