Submission #458008

# Submission time Handle Problem Language Result Execution time Memory
458008 2021-08-07T18:26:30 Z julian33 Political Development (BOI17_politicaldevelopment) C++14
100 / 100
1149 ms 26324 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);} 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=5e4+5; //make sure this is right
const int mod=1e9+7;

int n,k,deg[mxN],seen[mxN];
set<int> graph[mxN];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    cin>>n>>k;
    priority_queue<pii,vector<pii>,greater<pii>> q;
    for(int i=0;i<n;i++){
        cin>>deg[i];
        for(int j=0;j<deg[i];j++){
            int x; cin>>x;
            graph[i].insert(x);
        }
        q.push({deg[i],i});
    }
    int ans=1;
    while(sz(q)){
        pii cur=q.top(); q.pop();
        if(cur.first!=deg[cur.second])
            continue;
        int at=cur.second;
        seen[at]=1;
        vector<int> nd={at};
        for(int i:graph[at]){
            if(!seen[i]){
                deg[i]--;
                q.push({deg[i],i});
                nd.pb(i);
            }
        }
        int adj[15][15]{};
        for(int i=0;i<sz(nd);i++){
            adj[i][i]=1;
            for(int j=0;j<sz(nd);j++){
                if(graph[nd[i]].count(nd[j]))
                    adj[i][j]=1;
            }
        }
        for(int mask=0;mask<(1<<sz(nd));mask++){
            int yes=1;
            for(int i=0;i<sz(nd);i++){
                if(!(mask&(1<<i)))
                    continue;
                for(int j=0;j<sz(nd);j++){
                    if(!(mask&(1<<j)))
                        continue;
                    yes&=adj[i][j];
                    yes&=adj[j][i];
                }
            }
            if(yes)
                maxa(ans,__builtin_popcount(mask));
        }
    }
    cout<<ans<<"\n";
}
# 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 6 ms 3148 KB Output is correct
4 Correct 7 ms 3224 KB Output is correct
5 Correct 8 ms 3148 KB Output is correct
6 Correct 9 ms 3148 KB Output is correct
7 Correct 6 ms 3140 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2752 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 6 ms 3148 KB Output is correct
4 Correct 7 ms 3224 KB Output is correct
5 Correct 8 ms 3148 KB Output is correct
6 Correct 9 ms 3148 KB Output is correct
7 Correct 6 ms 3140 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2752 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 8 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3148 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 7 ms 3148 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3128 KB Output is correct
19 Correct 3 ms 2764 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 8 ms 3344 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 8 ms 3276 KB Output is correct
26 Correct 8 ms 3276 KB Output is correct
27 Correct 6 ms 3228 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 3284 KB Output is correct
31 Correct 8 ms 3276 KB Output is correct
32 Correct 8 ms 3276 KB Output is correct
33 Correct 8 ms 3276 KB Output is correct
34 Correct 8 ms 3292 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 5 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 11 ms 3724 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 3736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2764 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2644 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 589 ms 26236 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 591 ms 26140 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 600 ms 26224 KB Output is correct
16 Correct 595 ms 26248 KB Output is correct
17 Correct 607 ms 26324 KB Output is correct
18 Correct 608 ms 26224 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 6 ms 3148 KB Output is correct
4 Correct 7 ms 3224 KB Output is correct
5 Correct 8 ms 3148 KB Output is correct
6 Correct 9 ms 3148 KB Output is correct
7 Correct 6 ms 3140 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2752 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 8 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3148 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 7 ms 3148 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3128 KB Output is correct
19 Correct 3 ms 2764 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 8 ms 3344 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 8 ms 3276 KB Output is correct
26 Correct 8 ms 3276 KB Output is correct
27 Correct 6 ms 3228 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 3284 KB Output is correct
31 Correct 8 ms 3276 KB Output is correct
32 Correct 8 ms 3276 KB Output is correct
33 Correct 8 ms 3276 KB Output is correct
34 Correct 8 ms 3292 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 5 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 11 ms 3724 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 3736 KB Output is correct
44 Correct 104 ms 4632 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 11 ms 3788 KB Output is correct
47 Correct 27 ms 4804 KB Output is correct
48 Correct 11 ms 3716 KB Output is correct
49 Correct 27 ms 4812 KB Output is correct
50 Correct 27 ms 4884 KB Output is correct
51 Correct 451 ms 7156 KB Output is correct
52 Correct 9 ms 3148 KB Output is correct
53 Correct 1149 ms 7452 KB Output is correct
54 Correct 1102 ms 7584 KB Output is correct
55 Correct 7 ms 3148 KB Output is correct
56 Correct 6 ms 3148 KB Output is correct
57 Correct 3 ms 2764 KB Output is correct
58 Correct 1107 ms 7552 KB Output is correct
59 Correct 11 ms 3660 KB Output is correct
60 Correct 7 ms 3236 KB Output is correct
61 Correct 10 ms 3660 KB Output is correct
62 Correct 11 ms 3660 KB Output is correct
63 Correct 105 ms 4620 KB Output is correct
64 Correct 51 ms 4384 KB Output is correct
65 Correct 10 ms 3660 KB Output is correct
66 Correct 11 ms 3696 KB Output is correct
67 Correct 88 ms 5288 KB Output is correct
68 Correct 50 ms 4368 KB Output is correct
69 Correct 10 ms 3660 KB Output is correct
70 Correct 24 ms 4556 KB Output is correct
71 Correct 72 ms 5256 KB Output is correct
72 Correct 53 ms 5180 KB Output is correct
73 Correct 6 ms 3148 KB Output is correct
74 Correct 25 ms 4556 KB Output is correct
75 Correct 55 ms 5208 KB Output is correct
76 Correct 16 ms 4044 KB Output is correct
77 Correct 155 ms 5700 KB Output is correct
78 Correct 6 ms 3148 KB Output is correct
79 Correct 75 ms 4164 KB Output is correct
80 Correct 16 ms 4044 KB Output is correct
81 Correct 153 ms 5664 KB Output is correct
82 Correct 5 ms 2892 KB Output is correct
83 Correct 79 ms 4164 KB Output is correct
84 Correct 56 ms 5132 KB Output is correct
85 Correct 4 ms 2892 KB Output is correct
86 Correct 54 ms 5088 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 6 ms 3148 KB Output is correct
4 Correct 7 ms 3224 KB Output is correct
5 Correct 8 ms 3148 KB Output is correct
6 Correct 9 ms 3148 KB Output is correct
7 Correct 6 ms 3140 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2752 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 6 ms 3148 KB Output is correct
12 Correct 8 ms 3148 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 6 ms 3148 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 7 ms 3148 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 7 ms 3128 KB Output is correct
19 Correct 3 ms 2764 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 8 ms 3344 KB Output is correct
24 Correct 3 ms 2764 KB Output is correct
25 Correct 8 ms 3276 KB Output is correct
26 Correct 8 ms 3276 KB Output is correct
27 Correct 6 ms 3228 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 3284 KB Output is correct
31 Correct 8 ms 3276 KB Output is correct
32 Correct 8 ms 3276 KB Output is correct
33 Correct 8 ms 3276 KB Output is correct
34 Correct 8 ms 3292 KB Output is correct
35 Correct 5 ms 3036 KB Output is correct
36 Correct 5 ms 3020 KB Output is correct
37 Correct 5 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 11 ms 3724 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 3736 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 189 ms 19180 KB Output is correct
46 Correct 93 ms 10632 KB Output is correct
47 Correct 215 ms 19128 KB Output is correct
48 Correct 190 ms 19144 KB Output is correct
49 Correct 62 ms 8124 KB Output is correct
50 Correct 307 ms 23752 KB Output is correct
51 Correct 206 ms 20916 KB Output is correct
52 Correct 69 ms 8776 KB Output is correct
53 Correct 58 ms 8760 KB Output is correct
54 Correct 19 ms 3660 KB Output is correct
55 Correct 319 ms 26120 KB Output is correct
56 Correct 33 ms 6168 KB Output is correct
57 Correct 62 ms 8768 KB Output is correct
58 Correct 76 ms 11380 KB Output is correct
59 Correct 32 ms 6200 KB Output is correct
60 Correct 36 ms 6304 KB Output is correct
61 Correct 75 ms 11368 KB Output is correct
62 Correct 51 ms 8792 KB Output is correct
63 Correct 119 ms 13380 KB Output is correct
64 Correct 31 ms 6084 KB Output is correct
65 Correct 138 ms 15980 KB Output is correct
66 Correct 49 ms 8808 KB Output is correct
67 Correct 108 ms 13440 KB Output is correct
68 Correct 128 ms 15264 KB Output is correct
69 Correct 140 ms 15960 KB Output is correct
70 Correct 53 ms 8724 KB Output is correct
71 Correct 130 ms 15360 KB Output is correct
72 Correct 122 ms 12872 KB Output is correct
73 Correct 178 ms 17640 KB Output is correct
74 Correct 56 ms 8764 KB Output is correct
75 Correct 61 ms 8504 KB Output is correct
76 Correct 121 ms 12928 KB Output is correct
77 Correct 164 ms 17736 KB Output is correct
78 Correct 73 ms 10056 KB Output is correct
79 Correct 51 ms 8504 KB Output is correct
80 Correct 27 ms 5580 KB Output is correct
81 Correct 74 ms 10084 KB Output is correct
82 Correct 118 ms 14636 KB Output is correct
83 Correct 28 ms 5564 KB Output is correct
84 Correct 112 ms 14676 KB Output is correct