답안 #129184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129184 2019-07-11T19:35:00 Z Vardanyan Political Development (BOI17_politicaldevelopment) C++14
100 / 100
292 ms 24344 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 50*1000+5;
set<int> g[N];
int dp[(1<<11)];
int hv[11][11];
int cl[N];
int main(){
    ios_base::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int x;
    for(int i = 0;i<n;i++){

        int q;
        cin>>q;
        while(q--){
            int x;
            cin>>x;
            g[i].insert(x);
        }
    }
    int anss = 1;
    queue<int> q;
    for(int i = 0;i<n;i++){
        if(g[i].size()<k && g[i].size()){
            q.push(i);
            cl[i] = 1;
        }
    }
    while(1){
            memset(dp,0,sizeof(dp));
        int id = -1;
        /*for(int i = 0;i<n;i++){
            if(g[i].size()<k && g[i].size()){
                id = i;
                break;
            }
        }*/
        if(!q.size()) break;
        id = q.front();
        q.pop();
        if(!g[id].size()) continue;

        if(id == -1) break;
        if(id == -1) break;
        /*if(sz == 1){
            anss = max(anss,sz+1);
            break;
        }*/
        vector<int> v;
        set<int>::iterator it;
        int ans = 1;
        for(it = g[id].begin();it!=g[id].end();++it){
            int to = *it;
            v.push_back(to);
            dp[(1<<(v.size()-1))] = 1;
            anss = max(anss,2);
        }
        memset(hv,0,sizeof(hv));
        for(int i = 0;i<v.size();i++){
            for(int j = i+1;j<v.size();j++){
                if(g[v[i]].find(v[j])!=g[v[i]].end()){
                    hv[i][j] = hv[j][i] = 1;
                }
            }
        }
        for(int i = 1;i<(1<<v.size());i++){
            if(!dp[i]) continue;
            for(int j = 0;j<v.size();j++){
                if((i>>j)&1 ) continue;
                bool f = true;
                for(int ii = 0;ii<v.size();ii++){
                    if((i>>ii)&1){
                        if(!hv[ii][j]){
                            f = false;
                            break;
                        }
                    }
                }
                if(f){
                    dp[i|(1<<j)] = max(dp[i|(1<<j)],dp[i]+1);
                    ans = max(ans,dp[i]+1);
                }
            }
        }
        anss = max(ans+1,anss);
      //  cout<<ans<<endl;
        for(int i = 0;i<v.size();i++){
            g[v[i]].erase(g[v[i]].find(id));
            g[id].erase(g[id].find(v[i]));

        }
        for(int i = 0;i<v.size();i++){
            if(g[v[i]].size()<k && !cl[v[i]] && g[v[i]].size()){
                cl[v[i]] = 1;
                q.push(v[i]);
            }
        }
        //if(ans == 1) break;
    }
    cout<<anss<<endl;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:26:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(g[i].size()<k && g[i].size()){
            ~~~~~~~~~~~^~
politicaldevelopment.cpp:61:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i<v.size();i++){
                       ~^~~~~~~~~
politicaldevelopment.cpp:62:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = i+1;j<v.size();j++){
                             ~^~~~~~~~~
politicaldevelopment.cpp:70:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0;j<v.size();j++){
                           ~^~~~~~~~~
politicaldevelopment.cpp:73:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int ii = 0;ii<v.size();ii++){
                                ~~^~~~~~~~~
politicaldevelopment.cpp:89:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i<v.size();i++){
                       ~^~~~~~~~~
politicaldevelopment.cpp:94:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i<v.size();i++){
                       ~^~~~~~~~~
politicaldevelopment.cpp:95:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(g[v[i]].size()<k && !cl[v[i]] && g[v[i]].size()){
                ~~~~~~~~~~~~~~^~
politicaldevelopment.cpp:12:9: warning: unused variable 'x' [-Wunused-variable]
     int x;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 8 ms 3192 KB Output is correct
4 Correct 8 ms 3192 KB Output is correct
5 Correct 8 ms 3192 KB Output is correct
6 Correct 8 ms 3192 KB Output is correct
7 Correct 8 ms 3192 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 8 ms 3192 KB Output is correct
4 Correct 8 ms 3192 KB Output is correct
5 Correct 8 ms 3192 KB Output is correct
6 Correct 8 ms 3192 KB Output is correct
7 Correct 8 ms 3192 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 8 ms 3192 KB Output is correct
12 Correct 8 ms 3192 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 9 ms 3256 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 8 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 8 ms 3192 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 7 ms 2936 KB Output is correct
21 Correct 6 ms 2936 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 9 ms 3320 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 9 ms 3320 KB Output is correct
26 Correct 9 ms 3320 KB Output is correct
27 Correct 8 ms 3192 KB Output is correct
28 Correct 9 ms 3288 KB Output is correct
29 Correct 8 ms 3192 KB Output is correct
30 Correct 10 ms 3320 KB Output is correct
31 Correct 10 ms 3320 KB Output is correct
32 Correct 10 ms 3320 KB Output is correct
33 Correct 9 ms 3320 KB Output is correct
34 Correct 9 ms 3320 KB Output is correct
35 Correct 6 ms 3064 KB Output is correct
36 Correct 7 ms 3140 KB Output is correct
37 Correct 6 ms 3036 KB Output is correct
38 Correct 6 ms 2936 KB Output is correct
39 Correct 6 ms 2936 KB Output is correct
40 Correct 12 ms 3704 KB Output is correct
41 Correct 6 ms 2936 KB Output is correct
42 Correct 13 ms 3612 KB Output is correct
43 Correct 13 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 292 ms 24260 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 290 ms 24344 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 282 ms 24184 KB Output is correct
16 Correct 284 ms 24184 KB Output is correct
17 Correct 280 ms 24312 KB Output is correct
18 Correct 289 ms 24184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 8 ms 3192 KB Output is correct
4 Correct 8 ms 3192 KB Output is correct
5 Correct 8 ms 3192 KB Output is correct
6 Correct 8 ms 3192 KB Output is correct
7 Correct 8 ms 3192 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 8 ms 3192 KB Output is correct
12 Correct 8 ms 3192 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 9 ms 3256 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 8 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 8 ms 3192 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 7 ms 2936 KB Output is correct
21 Correct 6 ms 2936 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 9 ms 3320 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 9 ms 3320 KB Output is correct
26 Correct 9 ms 3320 KB Output is correct
27 Correct 8 ms 3192 KB Output is correct
28 Correct 9 ms 3288 KB Output is correct
29 Correct 8 ms 3192 KB Output is correct
30 Correct 10 ms 3320 KB Output is correct
31 Correct 10 ms 3320 KB Output is correct
32 Correct 10 ms 3320 KB Output is correct
33 Correct 9 ms 3320 KB Output is correct
34 Correct 9 ms 3320 KB Output is correct
35 Correct 6 ms 3064 KB Output is correct
36 Correct 7 ms 3140 KB Output is correct
37 Correct 6 ms 3036 KB Output is correct
38 Correct 6 ms 2936 KB Output is correct
39 Correct 6 ms 2936 KB Output is correct
40 Correct 12 ms 3704 KB Output is correct
41 Correct 6 ms 2936 KB Output is correct
42 Correct 13 ms 3612 KB Output is correct
43 Correct 13 ms 3676 KB Output is correct
44 Correct 57 ms 4664 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 13 ms 3704 KB Output is correct
47 Correct 22 ms 4600 KB Output is correct
48 Correct 12 ms 3704 KB Output is correct
49 Correct 22 ms 4600 KB Output is correct
50 Correct 22 ms 4604 KB Output is correct
51 Correct 45 ms 6524 KB Output is correct
52 Correct 9 ms 3192 KB Output is correct
53 Correct 61 ms 7032 KB Output is correct
54 Correct 58 ms 7036 KB Output is correct
55 Correct 8 ms 3192 KB Output is correct
56 Correct 9 ms 3192 KB Output is correct
57 Correct 4 ms 2680 KB Output is correct
58 Correct 52 ms 6904 KB Output is correct
59 Correct 12 ms 3704 KB Output is correct
60 Correct 8 ms 3196 KB Output is correct
61 Correct 12 ms 3708 KB Output is correct
62 Correct 12 ms 3676 KB Output is correct
63 Correct 55 ms 4600 KB Output is correct
64 Correct 28 ms 4344 KB Output is correct
65 Correct 11 ms 3576 KB Output is correct
66 Correct 12 ms 3832 KB Output is correct
67 Correct 39 ms 4988 KB Output is correct
68 Correct 29 ms 4344 KB Output is correct
69 Correct 11 ms 3576 KB Output is correct
70 Correct 21 ms 4472 KB Output is correct
71 Correct 39 ms 4984 KB Output is correct
72 Correct 30 ms 4856 KB Output is correct
73 Correct 8 ms 3192 KB Output is correct
74 Correct 22 ms 4472 KB Output is correct
75 Correct 30 ms 4984 KB Output is correct
76 Correct 14 ms 3960 KB Output is correct
77 Correct 31 ms 5496 KB Output is correct
78 Correct 7 ms 3192 KB Output is correct
79 Correct 18 ms 4088 KB Output is correct
80 Correct 15 ms 3960 KB Output is correct
81 Correct 31 ms 5368 KB Output is correct
82 Correct 6 ms 2936 KB Output is correct
83 Correct 18 ms 4216 KB Output is correct
84 Correct 25 ms 4932 KB Output is correct
85 Correct 6 ms 2936 KB Output is correct
86 Correct 25 ms 4828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 8 ms 3192 KB Output is correct
4 Correct 8 ms 3192 KB Output is correct
5 Correct 8 ms 3192 KB Output is correct
6 Correct 8 ms 3192 KB Output is correct
7 Correct 8 ms 3192 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 8 ms 3192 KB Output is correct
12 Correct 8 ms 3192 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 9 ms 3256 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 8 ms 3192 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 8 ms 3192 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 7 ms 2936 KB Output is correct
21 Correct 6 ms 2936 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 9 ms 3320 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 9 ms 3320 KB Output is correct
26 Correct 9 ms 3320 KB Output is correct
27 Correct 8 ms 3192 KB Output is correct
28 Correct 9 ms 3288 KB Output is correct
29 Correct 8 ms 3192 KB Output is correct
30 Correct 10 ms 3320 KB Output is correct
31 Correct 10 ms 3320 KB Output is correct
32 Correct 10 ms 3320 KB Output is correct
33 Correct 9 ms 3320 KB Output is correct
34 Correct 9 ms 3320 KB Output is correct
35 Correct 6 ms 3064 KB Output is correct
36 Correct 7 ms 3140 KB Output is correct
37 Correct 6 ms 3036 KB Output is correct
38 Correct 6 ms 2936 KB Output is correct
39 Correct 6 ms 2936 KB Output is correct
40 Correct 12 ms 3704 KB Output is correct
41 Correct 6 ms 2936 KB Output is correct
42 Correct 13 ms 3612 KB Output is correct
43 Correct 13 ms 3676 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 189 ms 17076 KB Output is correct
46 Correct 89 ms 11024 KB Output is correct
47 Correct 182 ms 18928 KB Output is correct
48 Correct 239 ms 18936 KB Output is correct
49 Correct 63 ms 8512 KB Output is correct
50 Correct 254 ms 24268 KB Output is correct
51 Correct 183 ms 18936 KB Output is correct
52 Correct 64 ms 8440 KB Output is correct
53 Correct 68 ms 8440 KB Output is correct
54 Correct 9 ms 2808 KB Output is correct
55 Correct 281 ms 24312 KB Output is correct
56 Correct 32 ms 5880 KB Output is correct
57 Correct 57 ms 8440 KB Output is correct
58 Correct 74 ms 11132 KB Output is correct
59 Correct 36 ms 5852 KB Output is correct
60 Correct 37 ms 5752 KB Output is correct
61 Correct 92 ms 11128 KB Output is correct
62 Correct 51 ms 8448 KB Output is correct
63 Correct 96 ms 12280 KB Output is correct
64 Correct 36 ms 5868 KB Output is correct
65 Correct 173 ms 14968 KB Output is correct
66 Correct 52 ms 8440 KB Output is correct
67 Correct 102 ms 12408 KB Output is correct
68 Correct 146 ms 14428 KB Output is correct
69 Correct 134 ms 15120 KB Output is correct
70 Correct 53 ms 8568 KB Output is correct
71 Correct 116 ms 14328 KB Output is correct
72 Correct 103 ms 11996 KB Output is correct
73 Correct 170 ms 16732 KB Output is correct
74 Correct 54 ms 8508 KB Output is correct
75 Correct 49 ms 7928 KB Output is correct
76 Correct 118 ms 12024 KB Output is correct
77 Correct 154 ms 16632 KB Output is correct
78 Correct 71 ms 9592 KB Output is correct
79 Correct 51 ms 8184 KB Output is correct
80 Correct 27 ms 5496 KB Output is correct
81 Correct 86 ms 9592 KB Output is correct
82 Correct 105 ms 13772 KB Output is correct
83 Correct 26 ms 5496 KB Output is correct
84 Correct 101 ms 13708 KB Output is correct