Submission #239316

# Submission time Handle Problem Language Result Execution time Memory
239316 2020-06-15T11:21:24 Z dsjong Political Development (BOI17_politicaldevelopment) C++14
54 / 100
3000 ms 64264 KB
#include <bits/stdc++.h>
using namespace std;
int sz[100005];
bool good[2000];
vector<int>adj[100005];
map<pair<int, int>, int> mp;
int main(){
    int n, k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int x;
            cin>>x;
            adj[i].push_back(x);
            mp[{i, x}]=true;
        }
        sz[i]=d;
    }
    int ans=1;
    for(int t=0;t<n;t++){
        int mini=INT_MAX, idx;
        for(int i=0;i<n;i++){
            if(sz[i]<mini){
                mini=sz[i];
                idx=i;
            }
        }
       // cout<<idx<<endl;
        vector<int>v;
        for(int i:adj[idx]){
            if(sz[i]<=n) v.push_back(i);
        }
        int m=v.size();
        good[0]=true;
        for(int i=1;i<(1<<m);i++){
            int lg=log2(i);
            int x=i-(1<<lg);
            if(good[x]){
                bool b=true;
                for(int j=0;j<m;j++){
                    if((1<<j)&x)
                        if(j!=lg) b&=mp[{v[j], v[lg]}];
                }
                good[i]=b;
            }
            else good[i]=false;
            if(good[i]){
                int cnt=0;
                for(int j=0;j<m;j++){
                    if((1<<j)&i) cnt++;
                }
                ans=max(ans, cnt+1);
            }
        }
        sz[idx]=INT_MAX;
        for(int i:adj[idx]) sz[i]--;
    }
    cout<<ans;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:57:16: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         sz[idx]=INT_MAX;
                ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 44 ms 3456 KB Output is correct
4 Correct 47 ms 3456 KB Output is correct
5 Correct 44 ms 3580 KB Output is correct
6 Correct 45 ms 3576 KB Output is correct
7 Correct 43 ms 3456 KB Output is correct
8 Correct 38 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 38 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 44 ms 3456 KB Output is correct
4 Correct 47 ms 3456 KB Output is correct
5 Correct 44 ms 3580 KB Output is correct
6 Correct 45 ms 3576 KB Output is correct
7 Correct 43 ms 3456 KB Output is correct
8 Correct 38 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 38 ms 2688 KB Output is correct
11 Correct 45 ms 3584 KB Output is correct
12 Correct 45 ms 3584 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 46 ms 3584 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 45 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 46 ms 3584 KB Output is correct
19 Correct 39 ms 2688 KB Output is correct
20 Correct 43 ms 3200 KB Output is correct
21 Correct 42 ms 3200 KB Output is correct
22 Correct 37 ms 2688 KB Output is correct
23 Correct 47 ms 3832 KB Output is correct
24 Correct 37 ms 2688 KB Output is correct
25 Correct 48 ms 3840 KB Output is correct
26 Correct 49 ms 3704 KB Output is correct
27 Correct 46 ms 3584 KB Output is correct
28 Correct 48 ms 3704 KB Output is correct
29 Correct 47 ms 3576 KB Output is correct
30 Correct 48 ms 3840 KB Output is correct
31 Correct 53 ms 3840 KB Output is correct
32 Correct 46 ms 3960 KB Output is correct
33 Correct 49 ms 3840 KB Output is correct
34 Correct 51 ms 3840 KB Output is correct
35 Correct 18 ms 3328 KB Output is correct
36 Correct 18 ms 3192 KB Output is correct
37 Correct 19 ms 3328 KB Output is correct
38 Correct 13 ms 3072 KB Output is correct
39 Correct 11 ms 3072 KB Output is correct
40 Correct 51 ms 4600 KB Output is correct
41 Correct 12 ms 3200 KB Output is correct
42 Correct 69 ms 4472 KB Output is correct
43 Correct 60 ms 4600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 7 ms 2816 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 8 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Execution timed out 3100 ms 64264 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 44 ms 3456 KB Output is correct
4 Correct 47 ms 3456 KB Output is correct
5 Correct 44 ms 3580 KB Output is correct
6 Correct 45 ms 3576 KB Output is correct
7 Correct 43 ms 3456 KB Output is correct
8 Correct 38 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 38 ms 2688 KB Output is correct
11 Correct 45 ms 3584 KB Output is correct
12 Correct 45 ms 3584 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 46 ms 3584 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 45 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 46 ms 3584 KB Output is correct
19 Correct 39 ms 2688 KB Output is correct
20 Correct 43 ms 3200 KB Output is correct
21 Correct 42 ms 3200 KB Output is correct
22 Correct 37 ms 2688 KB Output is correct
23 Correct 47 ms 3832 KB Output is correct
24 Correct 37 ms 2688 KB Output is correct
25 Correct 48 ms 3840 KB Output is correct
26 Correct 49 ms 3704 KB Output is correct
27 Correct 46 ms 3584 KB Output is correct
28 Correct 48 ms 3704 KB Output is correct
29 Correct 47 ms 3576 KB Output is correct
30 Correct 48 ms 3840 KB Output is correct
31 Correct 53 ms 3840 KB Output is correct
32 Correct 46 ms 3960 KB Output is correct
33 Correct 49 ms 3840 KB Output is correct
34 Correct 51 ms 3840 KB Output is correct
35 Correct 18 ms 3328 KB Output is correct
36 Correct 18 ms 3192 KB Output is correct
37 Correct 19 ms 3328 KB Output is correct
38 Correct 13 ms 3072 KB Output is correct
39 Correct 11 ms 3072 KB Output is correct
40 Correct 51 ms 4600 KB Output is correct
41 Correct 12 ms 3200 KB Output is correct
42 Correct 69 ms 4472 KB Output is correct
43 Correct 60 ms 4600 KB Output is correct
44 Correct 124 ms 5632 KB Output is correct
45 Correct 7 ms 2688 KB Output is correct
46 Correct 56 ms 4600 KB Output is correct
47 Correct 78 ms 7544 KB Output is correct
48 Correct 51 ms 4600 KB Output is correct
49 Correct 79 ms 7544 KB Output is correct
50 Correct 76 ms 7544 KB Output is correct
51 Correct 259 ms 17016 KB Output is correct
52 Correct 43 ms 3584 KB Output is correct
53 Correct 174 ms 9336 KB Output is correct
54 Correct 258 ms 20088 KB Output is correct
55 Correct 43 ms 3584 KB Output is correct
56 Correct 44 ms 3584 KB Output is correct
57 Correct 40 ms 2688 KB Output is correct
58 Correct 174 ms 9336 KB Output is correct
59 Correct 57 ms 4224 KB Output is correct
60 Correct 42 ms 3584 KB Output is correct
61 Correct 55 ms 4224 KB Output is correct
62 Correct 54 ms 4224 KB Output is correct
63 Correct 128 ms 5624 KB Output is correct
64 Correct 93 ms 5496 KB Output is correct
65 Correct 50 ms 4216 KB Output is correct
66 Correct 52 ms 4352 KB Output is correct
67 Correct 106 ms 8824 KB Output is correct
68 Correct 90 ms 5248 KB Output is correct
69 Correct 50 ms 4344 KB Output is correct
70 Correct 71 ms 6776 KB Output is correct
71 Correct 104 ms 8696 KB Output is correct
72 Correct 94 ms 8696 KB Output is correct
73 Correct 42 ms 3712 KB Output is correct
74 Correct 74 ms 7032 KB Output is correct
75 Correct 95 ms 8584 KB Output is correct
76 Correct 59 ms 5368 KB Output is correct
77 Correct 121 ms 11640 KB Output is correct
78 Correct 44 ms 3584 KB Output is correct
79 Correct 50 ms 7160 KB Output is correct
80 Correct 58 ms 5368 KB Output is correct
81 Correct 116 ms 11640 KB Output is correct
82 Correct 11 ms 3072 KB Output is correct
83 Correct 50 ms 7160 KB Output is correct
84 Correct 88 ms 8952 KB Output is correct
85 Correct 13 ms 3200 KB Output is correct
86 Correct 91 ms 8872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 44 ms 3456 KB Output is correct
4 Correct 47 ms 3456 KB Output is correct
5 Correct 44 ms 3580 KB Output is correct
6 Correct 45 ms 3576 KB Output is correct
7 Correct 43 ms 3456 KB Output is correct
8 Correct 38 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 38 ms 2688 KB Output is correct
11 Correct 45 ms 3584 KB Output is correct
12 Correct 45 ms 3584 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 46 ms 3584 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 45 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 46 ms 3584 KB Output is correct
19 Correct 39 ms 2688 KB Output is correct
20 Correct 43 ms 3200 KB Output is correct
21 Correct 42 ms 3200 KB Output is correct
22 Correct 37 ms 2688 KB Output is correct
23 Correct 47 ms 3832 KB Output is correct
24 Correct 37 ms 2688 KB Output is correct
25 Correct 48 ms 3840 KB Output is correct
26 Correct 49 ms 3704 KB Output is correct
27 Correct 46 ms 3584 KB Output is correct
28 Correct 48 ms 3704 KB Output is correct
29 Correct 47 ms 3576 KB Output is correct
30 Correct 48 ms 3840 KB Output is correct
31 Correct 53 ms 3840 KB Output is correct
32 Correct 46 ms 3960 KB Output is correct
33 Correct 49 ms 3840 KB Output is correct
34 Correct 51 ms 3840 KB Output is correct
35 Correct 18 ms 3328 KB Output is correct
36 Correct 18 ms 3192 KB Output is correct
37 Correct 19 ms 3328 KB Output is correct
38 Correct 13 ms 3072 KB Output is correct
39 Correct 11 ms 3072 KB Output is correct
40 Correct 51 ms 4600 KB Output is correct
41 Correct 12 ms 3200 KB Output is correct
42 Correct 69 ms 4472 KB Output is correct
43 Correct 60 ms 4600 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Execution timed out 3074 ms 34300 KB Time limit exceeded
46 Halted 0 ms 0 KB -