Submission #246355

# Submission time Handle Problem Language Result Execution time Memory
246355 2020-07-08T19:42:06 Z kimbj0709 Political Development (BOI17_politicaldevelopment) C++14
100 / 100
722 ms 44600 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 50050
#define f first
#define s second
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_vertex,k;
  vector<vector<int> > adj(maxn);
  set<pair<int,int> > edges;
  cin >> no_of_vertex >> k;
  int no_of_input,input;
  int ans = 1;
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q1;
  vector<int> degree(maxn,0);
  for(int i=0;i<no_of_vertex;i++){
    cin >> no_of_input;
    for(int j=0;j<no_of_input;j++){
      cin >> input;
      adj[i].push_back(input);
      edges.insert({i,input});
    }
    degree[i] = no_of_input;
    q1.push({degree[i],i});
  }
  vector<int> visited(maxn,0);
  while(q1.size()!=0){
    pair<int,int> a = q1.top();
    q1.pop();
    if(visited[a.s]==1){
      continue;
    }
    visited[a.s] = 1;
    vector<int> rn = {a.s};
    for(auto j:adj[a.s]){
      if(visited[j]==0){
        degree[j]--;
        q1.push({degree[j],j});
        rn.push_back(j);
      }
    }
    int arr[10][10];
    for(int a=0;a<rn.size();a++){
      arr[a][a] = 1;
      for(int b=0;b<rn.size();b++){
        if(a==b){
          continue;
        }
        if(edges.find({rn[a],rn[b]})!=edges.end()){
          arr[a][b] = 1;
        }
        else{
          arr[a][b] = 0;
        }
      }
    }
    for(int j=1;j<(1<<rn.size());j+=2){
      for(int a=0;a<rn.size();a++){
        if(j&(1<<a)){
          for(int b=0;b<rn.size();b++){
            if(j&(1<<b)){
              if(arr[a][b]==0){
                goto cont;
              }
            }
          }
        }
      }
      ans = max(ans,(int)__builtin_popcount(j));
      cont : ;
    }
  }
  cout << ans;
}

Compilation message

politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:45:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int a=0;a<rn.size();a++){
                 ~^~~~~~~~~~
politicaldevelopment.cpp:47:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int b=0;b<rn.size();b++){
                   ~^~~~~~~~~~
politicaldevelopment.cpp:60:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int a=0;a<rn.size();a++){
                   ~^~~~~~~~~~
politicaldevelopment.cpp:62:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           for(int b=0;b<rn.size();b++){
                       ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 12 ms 3200 KB Output is correct
4 Correct 12 ms 3200 KB Output is correct
5 Correct 11 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 12 ms 3320 KB Output is correct
8 Correct 6 ms 2560 KB Output is correct
9 Correct 6 ms 2304 KB Output is correct
10 Correct 7 ms 2560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 12 ms 3200 KB Output is correct
4 Correct 12 ms 3200 KB Output is correct
5 Correct 11 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 12 ms 3320 KB Output is correct
8 Correct 6 ms 2560 KB Output is correct
9 Correct 6 ms 2304 KB Output is correct
10 Correct 7 ms 2560 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 5 ms 2304 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2304 KB Output is correct
16 Correct 12 ms 3328 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 9 ms 2944 KB Output is correct
21 Correct 9 ms 2944 KB Output is correct
22 Correct 7 ms 2560 KB Output is correct
23 Correct 14 ms 3456 KB Output is correct
24 Correct 7 ms 2560 KB Output is correct
25 Correct 14 ms 3456 KB Output is correct
26 Correct 14 ms 3328 KB Output is correct
27 Correct 12 ms 3200 KB Output is correct
28 Correct 13 ms 3328 KB Output is correct
29 Correct 12 ms 3192 KB Output is correct
30 Correct 15 ms 3584 KB Output is correct
31 Correct 15 ms 3584 KB Output is correct
32 Correct 15 ms 3456 KB Output is correct
33 Correct 15 ms 3456 KB Output is correct
34 Correct 15 ms 3456 KB Output is correct
35 Correct 14 ms 2944 KB Output is correct
36 Correct 14 ms 2944 KB Output is correct
37 Correct 12 ms 2944 KB Output is correct
38 Correct 9 ms 2816 KB Output is correct
39 Correct 9 ms 2816 KB Output is correct
40 Correct 22 ms 4224 KB Output is correct
41 Correct 8 ms 2816 KB Output is correct
42 Correct 21 ms 4224 KB Output is correct
43 Correct 23 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2560 KB Output is correct
2 Correct 6 ms 2304 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
4 Correct 6 ms 2304 KB Output is correct
5 Correct 6 ms 2304 KB Output is correct
6 Correct 6 ms 2304 KB Output is correct
7 Correct 6 ms 2304 KB Output is correct
8 Correct 6 ms 2304 KB Output is correct
9 Correct 6 ms 2304 KB Output is correct
10 Correct 7 ms 2304 KB Output is correct
11 Correct 714 ms 44264 KB Output is correct
12 Correct 6 ms 2304 KB Output is correct
13 Correct 711 ms 44264 KB Output is correct
14 Correct 6 ms 2304 KB Output is correct
15 Correct 722 ms 44264 KB Output is correct
16 Correct 683 ms 44264 KB Output is correct
17 Correct 698 ms 44340 KB Output is correct
18 Correct 694 ms 44600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 12 ms 3200 KB Output is correct
4 Correct 12 ms 3200 KB Output is correct
5 Correct 11 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 12 ms 3320 KB Output is correct
8 Correct 6 ms 2560 KB Output is correct
9 Correct 6 ms 2304 KB Output is correct
10 Correct 7 ms 2560 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 5 ms 2304 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2304 KB Output is correct
16 Correct 12 ms 3328 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 9 ms 2944 KB Output is correct
21 Correct 9 ms 2944 KB Output is correct
22 Correct 7 ms 2560 KB Output is correct
23 Correct 14 ms 3456 KB Output is correct
24 Correct 7 ms 2560 KB Output is correct
25 Correct 14 ms 3456 KB Output is correct
26 Correct 14 ms 3328 KB Output is correct
27 Correct 12 ms 3200 KB Output is correct
28 Correct 13 ms 3328 KB Output is correct
29 Correct 12 ms 3192 KB Output is correct
30 Correct 15 ms 3584 KB Output is correct
31 Correct 15 ms 3584 KB Output is correct
32 Correct 15 ms 3456 KB Output is correct
33 Correct 15 ms 3456 KB Output is correct
34 Correct 15 ms 3456 KB Output is correct
35 Correct 14 ms 2944 KB Output is correct
36 Correct 14 ms 2944 KB Output is correct
37 Correct 12 ms 2944 KB Output is correct
38 Correct 9 ms 2816 KB Output is correct
39 Correct 9 ms 2816 KB Output is correct
40 Correct 22 ms 4224 KB Output is correct
41 Correct 8 ms 2816 KB Output is correct
42 Correct 21 ms 4224 KB Output is correct
43 Correct 23 ms 4224 KB Output is correct
44 Correct 81 ms 5504 KB Output is correct
45 Correct 6 ms 2304 KB Output is correct
46 Correct 21 ms 4224 KB Output is correct
47 Correct 44 ms 6140 KB Output is correct
48 Correct 21 ms 4224 KB Output is correct
49 Correct 41 ms 6004 KB Output is correct
50 Correct 41 ms 6004 KB Output is correct
51 Correct 140 ms 9712 KB Output is correct
52 Correct 11 ms 3328 KB Output is correct
53 Correct 210 ms 10480 KB Output is correct
54 Correct 223 ms 10480 KB Output is correct
55 Correct 12 ms 3328 KB Output is correct
56 Correct 11 ms 3200 KB Output is correct
57 Correct 7 ms 2560 KB Output is correct
58 Correct 210 ms 10504 KB Output is correct
59 Correct 21 ms 3968 KB Output is correct
60 Correct 11 ms 3328 KB Output is correct
61 Correct 20 ms 3968 KB Output is correct
62 Correct 29 ms 3968 KB Output is correct
63 Correct 82 ms 5624 KB Output is correct
64 Correct 50 ms 5120 KB Output is correct
65 Correct 18 ms 3968 KB Output is correct
66 Correct 20 ms 3968 KB Output is correct
67 Correct 70 ms 6644 KB Output is correct
68 Correct 51 ms 5120 KB Output is correct
69 Correct 22 ms 3968 KB Output is correct
70 Correct 38 ms 5504 KB Output is correct
71 Correct 66 ms 6644 KB Output is correct
72 Correct 57 ms 6516 KB Output is correct
73 Correct 12 ms 3200 KB Output is correct
74 Correct 39 ms 5504 KB Output is correct
75 Correct 62 ms 6516 KB Output is correct
76 Correct 27 ms 4736 KB Output is correct
77 Correct 77 ms 7412 KB Output is correct
78 Correct 12 ms 3200 KB Output is correct
79 Correct 39 ms 4864 KB Output is correct
80 Correct 27 ms 4736 KB Output is correct
81 Correct 79 ms 7412 KB Output is correct
82 Correct 9 ms 2816 KB Output is correct
83 Correct 42 ms 4984 KB Output is correct
84 Correct 51 ms 6644 KB Output is correct
85 Correct 9 ms 2816 KB Output is correct
86 Correct 51 ms 6516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2304 KB Output is correct
2 Correct 5 ms 2304 KB Output is correct
3 Correct 12 ms 3200 KB Output is correct
4 Correct 12 ms 3200 KB Output is correct
5 Correct 11 ms 3328 KB Output is correct
6 Correct 13 ms 3328 KB Output is correct
7 Correct 12 ms 3320 KB Output is correct
8 Correct 6 ms 2560 KB Output is correct
9 Correct 6 ms 2304 KB Output is correct
10 Correct 7 ms 2560 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 5 ms 2304 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2304 KB Output is correct
16 Correct 12 ms 3328 KB Output is correct
17 Correct 6 ms 2304 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 9 ms 2944 KB Output is correct
21 Correct 9 ms 2944 KB Output is correct
22 Correct 7 ms 2560 KB Output is correct
23 Correct 14 ms 3456 KB Output is correct
24 Correct 7 ms 2560 KB Output is correct
25 Correct 14 ms 3456 KB Output is correct
26 Correct 14 ms 3328 KB Output is correct
27 Correct 12 ms 3200 KB Output is correct
28 Correct 13 ms 3328 KB Output is correct
29 Correct 12 ms 3192 KB Output is correct
30 Correct 15 ms 3584 KB Output is correct
31 Correct 15 ms 3584 KB Output is correct
32 Correct 15 ms 3456 KB Output is correct
33 Correct 15 ms 3456 KB Output is correct
34 Correct 15 ms 3456 KB Output is correct
35 Correct 14 ms 2944 KB Output is correct
36 Correct 14 ms 2944 KB Output is correct
37 Correct 12 ms 2944 KB Output is correct
38 Correct 9 ms 2816 KB Output is correct
39 Correct 9 ms 2816 KB Output is correct
40 Correct 22 ms 4224 KB Output is correct
41 Correct 8 ms 2816 KB Output is correct
42 Correct 21 ms 4224 KB Output is correct
43 Correct 23 ms 4224 KB Output is correct
44 Correct 6 ms 2304 KB Output is correct
45 Correct 391 ms 31080 KB Output is correct
46 Correct 158 ms 15724 KB Output is correct
47 Correct 406 ms 30952 KB Output is correct
48 Correct 398 ms 30952 KB Output is correct
49 Correct 82 ms 12012 KB Output is correct
50 Correct 402 ms 37732 KB Output is correct
51 Correct 399 ms 30952 KB Output is correct
52 Correct 122 ms 12036 KB Output is correct
53 Correct 91 ms 12096 KB Output is correct
54 Correct 16 ms 3196 KB Output is correct
55 Correct 396 ms 37732 KB Output is correct
56 Correct 59 ms 8172 KB Output is correct
57 Correct 96 ms 12268 KB Output is correct
58 Correct 143 ms 15856 KB Output is correct
59 Correct 55 ms 8180 KB Output is correct
60 Correct 64 ms 8244 KB Output is correct
61 Correct 165 ms 15728 KB Output is correct
62 Correct 101 ms 11628 KB Output is correct
63 Correct 206 ms 18924 KB Output is correct
64 Correct 56 ms 8180 KB Output is correct
65 Correct 276 ms 22892 KB Output is correct
66 Correct 105 ms 11628 KB Output is correct
67 Correct 218 ms 18924 KB Output is correct
68 Correct 274 ms 21868 KB Output is correct
69 Correct 304 ms 22892 KB Output is correct
70 Correct 102 ms 11540 KB Output is correct
71 Correct 256 ms 21972 KB Output is correct
72 Correct 197 ms 18284 KB Output is correct
73 Correct 315 ms 25324 KB Output is correct
74 Correct 117 ms 11628 KB Output is correct
75 Correct 101 ms 11376 KB Output is correct
76 Correct 193 ms 18284 KB Output is correct
77 Correct 321 ms 25452 KB Output is correct
78 Correct 141 ms 13808 KB Output is correct
79 Correct 100 ms 11380 KB Output is correct
80 Correct 43 ms 6780 KB Output is correct
81 Correct 150 ms 13808 KB Output is correct
82 Correct 224 ms 20460 KB Output is correct
83 Correct 43 ms 6780 KB Output is correct
84 Correct 229 ms 20460 KB Output is correct