답안 #239317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239317 2020-06-15T11:23:18 Z dsjong Political Development (BOI17_politicaldevelopment) C++14
100 / 100
2850 ms 66200 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(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    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:60:16: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         sz[idx]=INT_MAX;
                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 30 ms 3456 KB Output is correct
4 Correct 32 ms 3456 KB Output is correct
5 Correct 31 ms 3584 KB Output is correct
6 Correct 35 ms 3584 KB Output is correct
7 Correct 31 ms 3712 KB Output is correct
8 Correct 28 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 26 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 30 ms 3456 KB Output is correct
4 Correct 32 ms 3456 KB Output is correct
5 Correct 31 ms 3584 KB Output is correct
6 Correct 35 ms 3584 KB Output is correct
7 Correct 31 ms 3712 KB Output is correct
8 Correct 28 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 26 ms 2688 KB Output is correct
11 Correct 31 ms 3456 KB Output is correct
12 Correct 31 ms 3456 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 34 ms 3456 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 32 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 32 ms 3712 KB Output is correct
19 Correct 28 ms 2688 KB Output is correct
20 Correct 29 ms 3200 KB Output is correct
21 Correct 28 ms 3200 KB Output is correct
22 Correct 42 ms 2688 KB Output is correct
23 Correct 33 ms 3712 KB Output is correct
24 Correct 27 ms 2688 KB Output is correct
25 Correct 31 ms 3712 KB Output is correct
26 Correct 31 ms 3584 KB Output is correct
27 Correct 31 ms 3584 KB Output is correct
28 Correct 32 ms 3712 KB Output is correct
29 Correct 29 ms 3456 KB Output is correct
30 Correct 33 ms 3840 KB Output is correct
31 Correct 35 ms 3840 KB Output is correct
32 Correct 47 ms 3840 KB Output is correct
33 Correct 38 ms 3840 KB Output is correct
34 Correct 41 ms 3840 KB Output is correct
35 Correct 14 ms 3200 KB Output is correct
36 Correct 14 ms 3328 KB Output is correct
37 Correct 14 ms 3328 KB Output is correct
38 Correct 11 ms 3200 KB Output is correct
39 Correct 11 ms 3200 KB Output is correct
40 Correct 41 ms 4600 KB Output is correct
41 Correct 10 ms 3200 KB Output is correct
42 Correct 48 ms 4576 KB Output is correct
43 Correct 38 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 7 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2736 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 2794 ms 63520 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 2831 ms 66020 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 2778 ms 66056 KB Output is correct
16 Correct 2850 ms 66196 KB Output is correct
17 Correct 2598 ms 66200 KB Output is correct
18 Correct 2583 ms 66040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 30 ms 3456 KB Output is correct
4 Correct 32 ms 3456 KB Output is correct
5 Correct 31 ms 3584 KB Output is correct
6 Correct 35 ms 3584 KB Output is correct
7 Correct 31 ms 3712 KB Output is correct
8 Correct 28 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 26 ms 2688 KB Output is correct
11 Correct 31 ms 3456 KB Output is correct
12 Correct 31 ms 3456 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 34 ms 3456 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 32 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 32 ms 3712 KB Output is correct
19 Correct 28 ms 2688 KB Output is correct
20 Correct 29 ms 3200 KB Output is correct
21 Correct 28 ms 3200 KB Output is correct
22 Correct 42 ms 2688 KB Output is correct
23 Correct 33 ms 3712 KB Output is correct
24 Correct 27 ms 2688 KB Output is correct
25 Correct 31 ms 3712 KB Output is correct
26 Correct 31 ms 3584 KB Output is correct
27 Correct 31 ms 3584 KB Output is correct
28 Correct 32 ms 3712 KB Output is correct
29 Correct 29 ms 3456 KB Output is correct
30 Correct 33 ms 3840 KB Output is correct
31 Correct 35 ms 3840 KB Output is correct
32 Correct 47 ms 3840 KB Output is correct
33 Correct 38 ms 3840 KB Output is correct
34 Correct 41 ms 3840 KB Output is correct
35 Correct 14 ms 3200 KB Output is correct
36 Correct 14 ms 3328 KB Output is correct
37 Correct 14 ms 3328 KB Output is correct
38 Correct 11 ms 3200 KB Output is correct
39 Correct 11 ms 3200 KB Output is correct
40 Correct 41 ms 4600 KB Output is correct
41 Correct 10 ms 3200 KB Output is correct
42 Correct 48 ms 4576 KB Output is correct
43 Correct 38 ms 4580 KB Output is correct
44 Correct 100 ms 5632 KB Output is correct
45 Correct 6 ms 2944 KB Output is correct
46 Correct 36 ms 4608 KB Output is correct
47 Correct 53 ms 7544 KB Output is correct
48 Correct 36 ms 4608 KB Output is correct
49 Correct 57 ms 7652 KB Output is correct
50 Correct 61 ms 7544 KB Output is correct
51 Correct 169 ms 17016 KB Output is correct
52 Correct 30 ms 3584 KB Output is correct
53 Correct 157 ms 9336 KB Output is correct
54 Correct 227 ms 19960 KB Output is correct
55 Correct 30 ms 3584 KB Output is correct
56 Correct 29 ms 3584 KB Output is correct
57 Correct 26 ms 2688 KB Output is correct
58 Correct 132 ms 9208 KB Output is correct
59 Correct 36 ms 4224 KB Output is correct
60 Correct 31 ms 3584 KB Output is correct
61 Correct 41 ms 4224 KB Output is correct
62 Correct 37 ms 4224 KB Output is correct
63 Correct 101 ms 5632 KB Output is correct
64 Correct 77 ms 5376 KB Output is correct
65 Correct 38 ms 4344 KB Output is correct
66 Correct 37 ms 4224 KB Output is correct
67 Correct 84 ms 8952 KB Output is correct
68 Correct 73 ms 5496 KB Output is correct
69 Correct 35 ms 4344 KB Output is correct
70 Correct 62 ms 6776 KB Output is correct
71 Correct 87 ms 8696 KB Output is correct
72 Correct 79 ms 8696 KB Output is correct
73 Correct 29 ms 3584 KB Output is correct
74 Correct 61 ms 6904 KB Output is correct
75 Correct 118 ms 8824 KB Output is correct
76 Correct 40 ms 5376 KB Output is correct
77 Correct 94 ms 11640 KB Output is correct
78 Correct 34 ms 3584 KB Output is correct
79 Correct 58 ms 7160 KB Output is correct
80 Correct 43 ms 5372 KB Output is correct
81 Correct 110 ms 11640 KB Output is correct
82 Correct 10 ms 3200 KB Output is correct
83 Correct 39 ms 7160 KB Output is correct
84 Correct 82 ms 8952 KB Output is correct
85 Correct 10 ms 3072 KB Output is correct
86 Correct 68 ms 8952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 30 ms 3456 KB Output is correct
4 Correct 32 ms 3456 KB Output is correct
5 Correct 31 ms 3584 KB Output is correct
6 Correct 35 ms 3584 KB Output is correct
7 Correct 31 ms 3712 KB Output is correct
8 Correct 28 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 26 ms 2688 KB Output is correct
11 Correct 31 ms 3456 KB Output is correct
12 Correct 31 ms 3456 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 34 ms 3456 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 32 ms 3584 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 32 ms 3712 KB Output is correct
19 Correct 28 ms 2688 KB Output is correct
20 Correct 29 ms 3200 KB Output is correct
21 Correct 28 ms 3200 KB Output is correct
22 Correct 42 ms 2688 KB Output is correct
23 Correct 33 ms 3712 KB Output is correct
24 Correct 27 ms 2688 KB Output is correct
25 Correct 31 ms 3712 KB Output is correct
26 Correct 31 ms 3584 KB Output is correct
27 Correct 31 ms 3584 KB Output is correct
28 Correct 32 ms 3712 KB Output is correct
29 Correct 29 ms 3456 KB Output is correct
30 Correct 33 ms 3840 KB Output is correct
31 Correct 35 ms 3840 KB Output is correct
32 Correct 47 ms 3840 KB Output is correct
33 Correct 38 ms 3840 KB Output is correct
34 Correct 41 ms 3840 KB Output is correct
35 Correct 14 ms 3200 KB Output is correct
36 Correct 14 ms 3328 KB Output is correct
37 Correct 14 ms 3328 KB Output is correct
38 Correct 11 ms 3200 KB Output is correct
39 Correct 11 ms 3200 KB Output is correct
40 Correct 41 ms 4600 KB Output is correct
41 Correct 10 ms 3200 KB Output is correct
42 Correct 48 ms 4576 KB Output is correct
43 Correct 38 ms 4580 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 2487 ms 33624 KB Output is correct
46 Correct 2206 ms 15940 KB Output is correct
47 Correct 2419 ms 35704 KB Output is correct
48 Correct 2416 ms 35192 KB Output is correct
49 Correct 2070 ms 11636 KB Output is correct
50 Correct 2308 ms 32852 KB Output is correct
51 Correct 2741 ms 35576 KB Output is correct
52 Correct 2160 ms 11692 KB Output is correct
53 Correct 2154 ms 11636 KB Output is correct
54 Correct 2088 ms 3044 KB Output is correct
55 Correct 2319 ms 32756 KB Output is correct
56 Correct 2128 ms 8040 KB Output is correct
57 Correct 2041 ms 11768 KB Output is correct
58 Correct 2111 ms 14856 KB Output is correct
59 Correct 2080 ms 8056 KB Output is correct
60 Correct 2179 ms 8028 KB Output is correct
61 Correct 2185 ms 14864 KB Output is correct
62 Correct 2086 ms 11452 KB Output is correct
63 Correct 2191 ms 19064 KB Output is correct
64 Correct 2076 ms 8032 KB Output is correct
65 Correct 2281 ms 24892 KB Output is correct
66 Correct 2053 ms 11456 KB Output is correct
67 Correct 2186 ms 18948 KB Output is correct
68 Correct 2209 ms 23416 KB Output is correct
69 Correct 2212 ms 24756 KB Output is correct
70 Correct 2125 ms 11512 KB Output is correct
71 Correct 2198 ms 23588 KB Output is correct
72 Correct 2156 ms 18396 KB Output is correct
73 Correct 2352 ms 29488 KB Output is correct
74 Correct 2000 ms 11448 KB Output is correct
75 Correct 569 ms 12152 KB Output is correct
76 Correct 2085 ms 18236 KB Output is correct
77 Correct 2267 ms 29756 KB Output is correct
78 Correct 626 ms 16124 KB Output is correct
79 Correct 600 ms 11896 KB Output is correct
80 Correct 162 ms 7416 KB Output is correct
81 Correct 650 ms 16120 KB Output is correct
82 Correct 2188 ms 22160 KB Output is correct
83 Correct 159 ms 7392 KB Output is correct
84 Correct 2207 ms 21960 KB Output is correct