Submission #631038

# Submission time Handle Problem Language Result Execution time Memory
631038 2022-08-17T15:17:56 Z bachhoangxuan Political Development (BOI17_politicaldevelopment) C++17
39 / 100
343 ms 10684 KB
#include<bits/stdc++.h>
using namespace std;
#define maxn 50005
#define pii pair<int,int>
int n,k,deg[maxn],ans,len,num[maxn],res;
vector<int> edge[maxn],ver;
set<pii> s;
bool check[maxn];
bool ok(){
    for(int i=0;i<len;i++){
        for(int j=0;j<i;j++){
            int a=ver[i],b=ver[j];
            if(*lower_bound(edge[a].begin(),edge[a].end(),b)!=b) return false;
        }
    }
    return true;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> deg[i];s.insert({deg[i],i});
        for(int j=1;j<=deg[i];j++){
            int x;cin >> x;x++;
            edge[i].push_back(x);
        }
        sort(edge[i].begin(),edge[i].end());
    }
    for(int i=1;i<=n;i++){
        pii p=*s.begin();check[p.second]=true;
        s.erase(s.begin());ver={p.second};
        for(int v:edge[p.second]){
            if(check[v]) continue;
            ver.push_back(v);
        }
        len=(int)ver.size();
        for(int mask=(1<<len)-1;mask>=(1<<ans);mask--){
            int cnt=0;
            for(int j=0;j<len;j++) cnt+=(mask>>j)&1;
            if(cnt<=ans) continue;
            if(ok()) ans=cnt;
        }
        for(int v:edge[p.second]){
            if(check[v]) continue;
            s.erase({deg[v],v});deg[v]--;
            s.insert({deg[v],v});
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Correct 3 ms 1876 KB Output is correct
5 Correct 4 ms 1876 KB Output is correct
6 Correct 4 ms 1876 KB Output is correct
7 Correct 4 ms 1876 KB Output is correct
8 Correct 2 ms 1748 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Correct 3 ms 1876 KB Output is correct
5 Correct 4 ms 1876 KB Output is correct
6 Correct 4 ms 1876 KB Output is correct
7 Correct 4 ms 1876 KB Output is correct
8 Correct 2 ms 1748 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 5 ms 2004 KB Output is correct
12 Correct 4 ms 1876 KB Output is correct
13 Correct 2 ms 1492 KB Output is correct
14 Correct 3 ms 1876 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 5 ms 1876 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 5 ms 1876 KB Output is correct
19 Correct 2 ms 1748 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Correct 4 ms 1876 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 5 ms 1876 KB Output is correct
24 Correct 2 ms 1748 KB Output is correct
25 Correct 9 ms 1908 KB Output is correct
26 Correct 5 ms 1876 KB Output is correct
27 Correct 4 ms 1876 KB Output is correct
28 Correct 5 ms 1876 KB Output is correct
29 Correct 4 ms 1876 KB Output is correct
30 Correct 5 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 5 ms 1876 KB Output is correct
33 Correct 8 ms 1876 KB Output is correct
34 Correct 6 ms 1876 KB Output is correct
35 Correct 5 ms 1620 KB Output is correct
36 Correct 3 ms 1620 KB Output is correct
37 Correct 3 ms 1620 KB Output is correct
38 Correct 3 ms 1620 KB Output is correct
39 Correct 3 ms 1620 KB Output is correct
40 Correct 7 ms 1956 KB Output is correct
41 Correct 2 ms 1620 KB Output is correct
42 Correct 7 ms 1960 KB Output is correct
43 Correct 8 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1748 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 2 ms 1492 KB Output is correct
6 Correct 1 ms 1512 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1504 KB Output is correct
9 Correct 2 ms 1492 KB Output is correct
10 Correct 2 ms 1492 KB Output is correct
11 Correct 289 ms 10612 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 343 ms 10684 KB Output is correct
14 Correct 1 ms 1508 KB Output is correct
15 Correct 283 ms 10632 KB Output is correct
16 Correct 324 ms 10548 KB Output is correct
17 Correct 278 ms 10624 KB Output is correct
18 Correct 274 ms 10624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Correct 3 ms 1876 KB Output is correct
5 Correct 4 ms 1876 KB Output is correct
6 Correct 4 ms 1876 KB Output is correct
7 Correct 4 ms 1876 KB Output is correct
8 Correct 2 ms 1748 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 5 ms 2004 KB Output is correct
12 Correct 4 ms 1876 KB Output is correct
13 Correct 2 ms 1492 KB Output is correct
14 Correct 3 ms 1876 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 5 ms 1876 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 5 ms 1876 KB Output is correct
19 Correct 2 ms 1748 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Correct 4 ms 1876 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 5 ms 1876 KB Output is correct
24 Correct 2 ms 1748 KB Output is correct
25 Correct 9 ms 1908 KB Output is correct
26 Correct 5 ms 1876 KB Output is correct
27 Correct 4 ms 1876 KB Output is correct
28 Correct 5 ms 1876 KB Output is correct
29 Correct 4 ms 1876 KB Output is correct
30 Correct 5 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 5 ms 1876 KB Output is correct
33 Correct 8 ms 1876 KB Output is correct
34 Correct 6 ms 1876 KB Output is correct
35 Correct 5 ms 1620 KB Output is correct
36 Correct 3 ms 1620 KB Output is correct
37 Correct 3 ms 1620 KB Output is correct
38 Correct 3 ms 1620 KB Output is correct
39 Correct 3 ms 1620 KB Output is correct
40 Correct 7 ms 1956 KB Output is correct
41 Correct 2 ms 1620 KB Output is correct
42 Correct 7 ms 1960 KB Output is correct
43 Correct 8 ms 1876 KB Output is correct
44 Correct 10 ms 1876 KB Output is correct
45 Correct 1 ms 1492 KB Output is correct
46 Correct 8 ms 1876 KB Output is correct
47 Correct 18 ms 2004 KB Output is correct
48 Correct 8 ms 2004 KB Output is correct
49 Correct 17 ms 2252 KB Output is correct
50 Correct 17 ms 2160 KB Output is correct
51 Correct 88 ms 2648 KB Output is correct
52 Correct 4 ms 1876 KB Output is correct
53 Correct 239 ms 2784 KB Output is correct
54 Correct 157 ms 2756 KB Output is correct
55 Correct 5 ms 2004 KB Output is correct
56 Correct 5 ms 2004 KB Output is correct
57 Correct 2 ms 1748 KB Output is correct
58 Correct 222 ms 2896 KB Output is correct
59 Correct 7 ms 2132 KB Output is correct
60 Correct 5 ms 2004 KB Output is correct
61 Correct 7 ms 2064 KB Output is correct
62 Correct 6 ms 2004 KB Output is correct
63 Correct 10 ms 2156 KB Output is correct
64 Correct 9 ms 2132 KB Output is correct
65 Correct 8 ms 2032 KB Output is correct
66 Correct 6 ms 2004 KB Output is correct
67 Correct 23 ms 2260 KB Output is correct
68 Correct 9 ms 2132 KB Output is correct
69 Correct 7 ms 2028 KB Output is correct
70 Correct 13 ms 2208 KB Output is correct
71 Correct 20 ms 2312 KB Output is correct
72 Correct 19 ms 2280 KB Output is correct
73 Correct 5 ms 1876 KB Output is correct
74 Correct 18 ms 2156 KB Output is correct
75 Correct 19 ms 2256 KB Output is correct
76 Correct 13 ms 2004 KB Output is correct
77 Correct 41 ms 2428 KB Output is correct
78 Correct 5 ms 1976 KB Output is correct
79 Correct 19 ms 1972 KB Output is correct
80 Correct 10 ms 2004 KB Output is correct
81 Correct 45 ms 2428 KB Output is correct
82 Correct 3 ms 1620 KB Output is correct
83 Correct 20 ms 1876 KB Output is correct
84 Correct 24 ms 2260 KB Output is correct
85 Correct 3 ms 1620 KB Output is correct
86 Incorrect 23 ms 2260 KB Output isn't correct
87 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Correct 1 ms 1492 KB Output is correct
3 Correct 5 ms 1876 KB Output is correct
4 Correct 3 ms 1876 KB Output is correct
5 Correct 4 ms 1876 KB Output is correct
6 Correct 4 ms 1876 KB Output is correct
7 Correct 4 ms 1876 KB Output is correct
8 Correct 2 ms 1748 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 5 ms 2004 KB Output is correct
12 Correct 4 ms 1876 KB Output is correct
13 Correct 2 ms 1492 KB Output is correct
14 Correct 3 ms 1876 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 5 ms 1876 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 5 ms 1876 KB Output is correct
19 Correct 2 ms 1748 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Correct 4 ms 1876 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 5 ms 1876 KB Output is correct
24 Correct 2 ms 1748 KB Output is correct
25 Correct 9 ms 1908 KB Output is correct
26 Correct 5 ms 1876 KB Output is correct
27 Correct 4 ms 1876 KB Output is correct
28 Correct 5 ms 1876 KB Output is correct
29 Correct 4 ms 1876 KB Output is correct
30 Correct 5 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 5 ms 1876 KB Output is correct
33 Correct 8 ms 1876 KB Output is correct
34 Correct 6 ms 1876 KB Output is correct
35 Correct 5 ms 1620 KB Output is correct
36 Correct 3 ms 1620 KB Output is correct
37 Correct 3 ms 1620 KB Output is correct
38 Correct 3 ms 1620 KB Output is correct
39 Correct 3 ms 1620 KB Output is correct
40 Correct 7 ms 1956 KB Output is correct
41 Correct 2 ms 1620 KB Output is correct
42 Correct 7 ms 1960 KB Output is correct
43 Correct 8 ms 1876 KB Output is correct
44 Correct 1 ms 1492 KB Output is correct
45 Correct 175 ms 6296 KB Output is correct
46 Correct 54 ms 5672 KB Output is correct
47 Correct 173 ms 6432 KB Output is correct
48 Correct 168 ms 6352 KB Output is correct
49 Correct 39 ms 5764 KB Output is correct
50 Correct 180 ms 6412 KB Output is correct
51 Correct 154 ms 6348 KB Output is correct
52 Correct 46 ms 6488 KB Output is correct
53 Correct 41 ms 6452 KB Output is correct
54 Correct 13 ms 4172 KB Output is correct
55 Correct 190 ms 9028 KB Output is correct
56 Correct 28 ms 6000 KB Output is correct
57 Correct 38 ms 6476 KB Output is correct
58 Correct 49 ms 6568 KB Output is correct
59 Correct 29 ms 6068 KB Output is correct
60 Correct 31 ms 5976 KB Output is correct
61 Correct 49 ms 6588 KB Output is correct
62 Correct 41 ms 6252 KB Output is correct
63 Correct 86 ms 6936 KB Output is correct
64 Correct 28 ms 5948 KB Output is correct
65 Correct 97 ms 7332 KB Output is correct
66 Correct 39 ms 6272 KB Output is correct
67 Correct 94 ms 7036 KB Output is correct
68 Correct 98 ms 7296 KB Output is correct
69 Correct 102 ms 7320 KB Output is correct
70 Correct 45 ms 6308 KB Output is correct
71 Correct 100 ms 7244 KB Output is correct
72 Correct 63 ms 6756 KB Output is correct
73 Correct 130 ms 7692 KB Output is correct
74 Correct 42 ms 6220 KB Output is correct
75 Correct 42 ms 4236 KB Output is correct
76 Correct 88 ms 6896 KB Output is correct
77 Correct 137 ms 7624 KB Output is correct
78 Correct 56 ms 4520 KB Output is correct
79 Correct 42 ms 4208 KB Output is correct
80 Correct 22 ms 2852 KB Output is correct
81 Correct 62 ms 4556 KB Output is correct
82 Correct 95 ms 6864 KB Output is correct
83 Correct 25 ms 2900 KB Output is correct
84 Incorrect 91 ms 6860 KB Output isn't correct
85 Halted 0 ms 0 KB -