답안 #719375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719375 2023-04-05T21:09:17 Z n0sk1ll Political Development (BOI17_politicaldevelopment) C++17
39 / 100
348 ms 28612 KB
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;







//Note to self: Check for overflow

struct find_clique
{
    int g[102]; //graph by bitmask
    int dp1[3500]; //first half
    int pc[3500]; //precalced
    int dp2[3500]; //second half

    void clear(int n)
    {
        if (n>10) while (true);
        ff(i,0,n) g[i]=0;
        ff(i,0,(1<<n)) dp1[i]=0;
        ff(i,0,(1<<n)) dp2[i]=0;
    }

    void add(int u, int v)
    {
        if (u>10) while (true);
        if (v>10) while (true);
        g[u]|=(1<<v);
        g[v]|=(1<<u);
    }

    /*int calc(int n)
    {

        int fh=n/2,sh=(n+1)/2,fb=(1<<fh)-1,sb=(1<<sh)-1;
        ff(i,0,(1<<sh)) pc[i]=__builtin_popcount(i);

        ff(mask,1,(1<<fh)) ff(j,0,fh) if (mask&(1<<j)) {
            dp1[mask]=max(dp1[mask],dp1[mask&g[j]]+1);
        }

        ff(mask,1,(1<<sh)) ff(j,0,sh) if (mask&(1<<j)) {
            dp2[mask]=max(dp2[mask],dp2[mask&(g[j]>>fh)]+1);
        }

        int ans=0;
        ff(mask,0,(1<<sh)) if (dp2[mask]==pc[mask])
        {
            int span=0;
            ff(j,0,sh) if (mask&(1<<j)) span|=(g[j]&fb);
            ans=max(ans,pc[mask]+dp1[span]);
        }

        return ans;
    }*/

    int calc(int n)
    {
        if (n>10) while (true);
        int ans=0;
        ff(mask,0,(1<<n))
        {
            bool dobar=true;
            ff(j,0,n) if (((g[j]|(1<<j))&mask)!=mask) dobar=false;
            if (dobar) ans=max(ans,__builtin_popcount(mask));
        }
        return ans;
    }
} ok;

set<pii> pq;
set<int> idemo[100005];

int main()
{
    FAST;

    int n,k; cin>>n>>k;
    ff(i,0,n)
    {
        int d; cin>>d;
        while (d--)
        {
            int x; cin>>x;
            idemo[i].insert(x);
        }
    }
    ff(i,0,n) pq.insert({(int)idemo[i].size(),i});

    int ans=1;
    while (!pq.empty())
    {
        int p=pq.begin()->yy;

        vector<int> cvors;
        cvors.pb(p);

        for (auto it : idemo[p]) cvors.pb(it);

        /*cout<<"consider: ";
        for (auto it : cvors) cout<<it<<" "; cout<<endl;*/

        ok.clear((int)cvors.size());
        ff(i,0,(int)cvors.size())
            ff(j,i+1,(int)cvors.size())
                if (idemo[cvors[i]].count(cvors[j]))
                    ok.add(i,j);

        ans=max(ans,ok.calc((int)cvors.size()));

        for (auto it : idemo[p]) pq.erase({(int)idemo[it].size(),it}),idemo[it].erase(p),pq.insert({(int)idemo[it].size(),it});
        pq.erase({(int)idemo[p].size(),p});
    }

    cout<<ans<<"\n";
}

//Note to self: Check for overflow

/*

5 3
2 1 2
3 0 2 3
3 0 1 4
2 1 4
2 2 3

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5036 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 8 ms 5716 KB Output is correct
4 Correct 7 ms 5716 KB Output is correct
5 Correct 7 ms 5716 KB Output is correct
6 Correct 8 ms 5708 KB Output is correct
7 Correct 9 ms 5692 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5036 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 8 ms 5716 KB Output is correct
4 Correct 7 ms 5716 KB Output is correct
5 Correct 7 ms 5716 KB Output is correct
6 Correct 8 ms 5708 KB Output is correct
7 Correct 9 ms 5692 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 7 ms 5716 KB Output is correct
12 Correct 7 ms 5716 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5740 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 8 ms 5616 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 8 ms 5716 KB Output is correct
19 Correct 5 ms 5204 KB Output is correct
20 Correct 5 ms 5460 KB Output is correct
21 Correct 7 ms 5460 KB Output is correct
22 Correct 4 ms 5204 KB Output is correct
23 Correct 9 ms 5844 KB Output is correct
24 Correct 4 ms 5180 KB Output is correct
25 Correct 9 ms 5852 KB Output is correct
26 Correct 8 ms 5716 KB Output is correct
27 Correct 7 ms 5716 KB Output is correct
28 Correct 8 ms 5716 KB Output is correct
29 Correct 7 ms 5716 KB Output is correct
30 Correct 11 ms 5844 KB Output is correct
31 Correct 10 ms 5888 KB Output is correct
32 Correct 10 ms 5844 KB Output is correct
33 Correct 11 ms 5844 KB Output is correct
34 Correct 9 ms 5844 KB Output is correct
35 Correct 6 ms 5460 KB Output is correct
36 Correct 6 ms 5460 KB Output is correct
37 Correct 6 ms 5332 KB Output is correct
38 Correct 5 ms 5204 KB Output is correct
39 Correct 7 ms 5204 KB Output is correct
40 Correct 14 ms 6204 KB Output is correct
41 Correct 5 ms 5316 KB Output is correct
42 Correct 14 ms 6124 KB Output is correct
43 Correct 12 ms 6100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5204 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4920 KB Output is correct
9 Correct 4 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 328 ms 28508 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 336 ms 28496 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 348 ms 28496 KB Output is correct
16 Correct 342 ms 28468 KB Output is correct
17 Correct 286 ms 28612 KB Output is correct
18 Correct 300 ms 28464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5036 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 8 ms 5716 KB Output is correct
4 Correct 7 ms 5716 KB Output is correct
5 Correct 7 ms 5716 KB Output is correct
6 Correct 8 ms 5708 KB Output is correct
7 Correct 9 ms 5692 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 7 ms 5716 KB Output is correct
12 Correct 7 ms 5716 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5740 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 8 ms 5616 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 8 ms 5716 KB Output is correct
19 Correct 5 ms 5204 KB Output is correct
20 Correct 5 ms 5460 KB Output is correct
21 Correct 7 ms 5460 KB Output is correct
22 Correct 4 ms 5204 KB Output is correct
23 Correct 9 ms 5844 KB Output is correct
24 Correct 4 ms 5180 KB Output is correct
25 Correct 9 ms 5852 KB Output is correct
26 Correct 8 ms 5716 KB Output is correct
27 Correct 7 ms 5716 KB Output is correct
28 Correct 8 ms 5716 KB Output is correct
29 Correct 7 ms 5716 KB Output is correct
30 Correct 11 ms 5844 KB Output is correct
31 Correct 10 ms 5888 KB Output is correct
32 Correct 10 ms 5844 KB Output is correct
33 Correct 11 ms 5844 KB Output is correct
34 Correct 9 ms 5844 KB Output is correct
35 Correct 6 ms 5460 KB Output is correct
36 Correct 6 ms 5460 KB Output is correct
37 Correct 6 ms 5332 KB Output is correct
38 Correct 5 ms 5204 KB Output is correct
39 Correct 7 ms 5204 KB Output is correct
40 Correct 14 ms 6204 KB Output is correct
41 Correct 5 ms 5316 KB Output is correct
42 Correct 14 ms 6124 KB Output is correct
43 Correct 12 ms 6100 KB Output is correct
44 Correct 21 ms 7144 KB Output is correct
45 Correct 2 ms 4948 KB Output is correct
46 Correct 12 ms 6100 KB Output is correct
47 Correct 21 ms 7124 KB Output is correct
48 Correct 11 ms 6188 KB Output is correct
49 Correct 21 ms 7052 KB Output is correct
50 Correct 24 ms 7120 KB Output is correct
51 Correct 65 ms 9012 KB Output is correct
52 Correct 7 ms 5716 KB Output is correct
53 Correct 80 ms 9428 KB Output is correct
54 Correct 91 ms 9428 KB Output is correct
55 Correct 9 ms 5716 KB Output is correct
56 Correct 6 ms 5716 KB Output is correct
57 Correct 4 ms 5204 KB Output is correct
58 Correct 79 ms 9428 KB Output is correct
59 Correct 9 ms 6100 KB Output is correct
60 Correct 7 ms 5736 KB Output is correct
61 Correct 10 ms 6200 KB Output is correct
62 Correct 10 ms 6184 KB Output is correct
63 Correct 22 ms 7148 KB Output is correct
64 Correct 21 ms 6876 KB Output is correct
65 Correct 14 ms 6080 KB Output is correct
66 Correct 10 ms 6100 KB Output is correct
67 Correct 27 ms 7508 KB Output is correct
68 Correct 17 ms 6896 KB Output is correct
69 Correct 10 ms 5972 KB Output is correct
70 Correct 18 ms 6948 KB Output is correct
71 Correct 26 ms 7492 KB Output is correct
72 Correct 25 ms 7424 KB Output is correct
73 Correct 6 ms 5716 KB Output is correct
74 Correct 20 ms 6976 KB Output is correct
75 Correct 26 ms 7344 KB Output is correct
76 Correct 17 ms 6612 KB Output is correct
77 Correct 35 ms 7940 KB Output is correct
78 Correct 7 ms 5716 KB Output is correct
79 Correct 23 ms 6428 KB Output is correct
80 Correct 15 ms 6516 KB Output is correct
81 Correct 41 ms 7932 KB Output is correct
82 Correct 4 ms 5204 KB Output is correct
83 Correct 19 ms 6484 KB Output is correct
84 Correct 25 ms 7252 KB Output is correct
85 Correct 4 ms 5204 KB Output is correct
86 Incorrect 30 ms 7252 KB Output isn't correct
87 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5036 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 8 ms 5716 KB Output is correct
4 Correct 7 ms 5716 KB Output is correct
5 Correct 7 ms 5716 KB Output is correct
6 Correct 8 ms 5708 KB Output is correct
7 Correct 9 ms 5692 KB Output is correct
8 Correct 4 ms 5204 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 4 ms 5204 KB Output is correct
11 Correct 7 ms 5716 KB Output is correct
12 Correct 7 ms 5716 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 8 ms 5740 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 8 ms 5616 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 8 ms 5716 KB Output is correct
19 Correct 5 ms 5204 KB Output is correct
20 Correct 5 ms 5460 KB Output is correct
21 Correct 7 ms 5460 KB Output is correct
22 Correct 4 ms 5204 KB Output is correct
23 Correct 9 ms 5844 KB Output is correct
24 Correct 4 ms 5180 KB Output is correct
25 Correct 9 ms 5852 KB Output is correct
26 Correct 8 ms 5716 KB Output is correct
27 Correct 7 ms 5716 KB Output is correct
28 Correct 8 ms 5716 KB Output is correct
29 Correct 7 ms 5716 KB Output is correct
30 Correct 11 ms 5844 KB Output is correct
31 Correct 10 ms 5888 KB Output is correct
32 Correct 10 ms 5844 KB Output is correct
33 Correct 11 ms 5844 KB Output is correct
34 Correct 9 ms 5844 KB Output is correct
35 Correct 6 ms 5460 KB Output is correct
36 Correct 6 ms 5460 KB Output is correct
37 Correct 6 ms 5332 KB Output is correct
38 Correct 5 ms 5204 KB Output is correct
39 Correct 7 ms 5204 KB Output is correct
40 Correct 14 ms 6204 KB Output is correct
41 Correct 5 ms 5316 KB Output is correct
42 Correct 14 ms 6124 KB Output is correct
43 Correct 12 ms 6100 KB Output is correct
44 Correct 3 ms 4948 KB Output is correct
45 Correct 178 ms 21448 KB Output is correct
46 Correct 86 ms 14524 KB Output is correct
47 Correct 202 ms 21472 KB Output is correct
48 Correct 195 ms 21448 KB Output is correct
49 Correct 59 ms 12024 KB Output is correct
50 Correct 195 ms 26144 KB Output is correct
51 Correct 180 ms 21324 KB Output is correct
52 Correct 54 ms 12056 KB Output is correct
53 Correct 58 ms 11960 KB Output is correct
54 Correct 22 ms 7376 KB Output is correct
55 Correct 208 ms 26224 KB Output is correct
56 Correct 34 ms 9684 KB Output is correct
57 Correct 54 ms 11988 KB Output is correct
58 Correct 69 ms 14408 KB Output is correct
59 Correct 45 ms 9704 KB Output is correct
60 Correct 38 ms 9628 KB Output is correct
61 Correct 80 ms 14316 KB Output is correct
62 Correct 54 ms 11964 KB Output is correct
63 Correct 112 ms 15588 KB Output is correct
64 Correct 35 ms 9684 KB Output is correct
65 Correct 153 ms 17848 KB Output is correct
66 Correct 60 ms 12060 KB Output is correct
67 Correct 111 ms 15576 KB Output is correct
68 Correct 140 ms 17324 KB Output is correct
69 Correct 184 ms 17852 KB Output is correct
70 Correct 62 ms 12060 KB Output is correct
71 Correct 144 ms 17236 KB Output is correct
72 Correct 124 ms 15188 KB Output is correct
73 Correct 145 ms 19404 KB Output is correct
74 Correct 58 ms 11968 KB Output is correct
75 Correct 53 ms 10708 KB Output is correct
76 Correct 109 ms 15180 KB Output is correct
77 Correct 161 ms 19436 KB Output is correct
78 Correct 71 ms 12128 KB Output is correct
79 Correct 61 ms 10768 KB Output is correct
80 Correct 26 ms 7924 KB Output is correct
81 Correct 69 ms 12108 KB Output is correct
82 Correct 123 ms 16688 KB Output is correct
83 Correct 25 ms 7892 KB Output is correct
84 Incorrect 114 ms 16752 KB Output isn't correct
85 Halted 0 ms 0 KB -