Submission #246578

# Submission time Handle Problem Language Result Execution time Memory
246578 2020-07-09T15:57:39 Z m3r8 Political Development (BOI17_politicaldevelopment) C++14
4 / 100
178 ms 308944 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
#include <utility>
#include <queue>

#define N 50100
#define ii std::pair<int,int>


std::vector<int> adj[N];
int k;
std::vector<std::bitset<N>> add(N);
std::queue<int> que;
std::vector<int> akt;
int used[N];


int clq(int idx){
  int erg = 0;
  for(int i = 0;i<(1<<akt.size());i++){
    std::bitset<N> tmp = add[idx];
    int cnt = 1;
    for(int j = 0;j<akt.size();j++){
      if(i & (1<<j)){
        cnt++;
        tmp &= add[akt[j]];
      };  
    };
    int pos = 1;
    for(int j = 0;j<akt.size();j++){
      if(!tmp[akt[j]]){
        pos = 0;
        break;
      };  
    };
    if(pos){
      erg = std::max(erg,cnt);
    };
  };
  return erg;
};

int main(void){
  int n;  
  scanf("%d %d",&n,&k);
  int d;
  int x;
  int mx = 1;
  for(int i = 0;i<n;i++){
    add[i][i] = 1;
    scanf("%d",&d);
    for(int j = 0;j<d;j++){
      mx = 2;
      scanf("%d",&x);
      add[i][x] = 1;
      adj[i].push_back(x);
    };
  };
  for(int i = 0;i<n;i++){
    if(adj[i].size() < k){
      //printf("%d %d\n",i,adj[i].size());
      used[i] = 1;
      que.push(i);
    };  
  };
  while(que.size()){
    int ak = que.front();que.pop();  
   // printf("%d\n",ak);
    akt.clear();
    used[ak] = 2;
    for(auto i: adj[ak]){
      if(used[i] != 2){
        akt.push_back(i);
      };  
    };
    mx = std::max(mx,clq(ak));
    for(auto i: adj[ak]){
      if(!used[i]){
        add[i][ak] = 0;
        if(add[i].count() < k){
          used[i] = 1;
          que.push(i);  
        };
      };  
    };
  };
  printf("%d\n",mx);
  return 0;
};

Compilation message

politicaldevelopment.cpp: In function 'int clq(int)':
politicaldevelopment.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0;j<akt.size();j++){
                   ~^~~~~~~~~~~
politicaldevelopment.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0;j<akt.size();j++){
                   ~^~~~~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(adj[i].size() < k){
        ~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:83:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(add[i].count() < k){
            ~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&k);
   ~~~~~^~~~~~~~~~~~~~~
politicaldevelopment.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&d);
     ~~~~~^~~~~~~~~
politicaldevelopment.cpp:57:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&x);
       ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 152 ms 308600 KB Output is correct
2 Correct 149 ms 308600 KB Output is correct
3 Correct 167 ms 308732 KB Output is correct
4 Correct 169 ms 308856 KB Output is correct
5 Correct 172 ms 308944 KB Output is correct
6 Correct 174 ms 308728 KB Output is correct
7 Correct 173 ms 308728 KB Output is correct
8 Correct 157 ms 308600 KB Output is correct
9 Correct 156 ms 308624 KB Output is correct
10 Correct 153 ms 308600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 308600 KB Output is correct
2 Correct 149 ms 308600 KB Output is correct
3 Correct 167 ms 308732 KB Output is correct
4 Correct 169 ms 308856 KB Output is correct
5 Correct 172 ms 308944 KB Output is correct
6 Correct 174 ms 308728 KB Output is correct
7 Correct 173 ms 308728 KB Output is correct
8 Correct 157 ms 308600 KB Output is correct
9 Correct 156 ms 308624 KB Output is correct
10 Correct 153 ms 308600 KB Output is correct
11 Correct 178 ms 308728 KB Output is correct
12 Correct 172 ms 308728 KB Output is correct
13 Correct 152 ms 308600 KB Output is correct
14 Correct 174 ms 308728 KB Output is correct
15 Correct 152 ms 308504 KB Output is correct
16 Correct 169 ms 308856 KB Output is correct
17 Correct 156 ms 308600 KB Output is correct
18 Correct 169 ms 308728 KB Output is correct
19 Correct 160 ms 308800 KB Output is correct
20 Correct 165 ms 308728 KB Output is correct
21 Correct 158 ms 308728 KB Output is correct
22 Correct 154 ms 308600 KB Output is correct
23 Incorrect 178 ms 308728 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 161 ms 308728 KB Output is correct
2 Incorrect 155 ms 308600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 308600 KB Output is correct
2 Correct 149 ms 308600 KB Output is correct
3 Correct 167 ms 308732 KB Output is correct
4 Correct 169 ms 308856 KB Output is correct
5 Correct 172 ms 308944 KB Output is correct
6 Correct 174 ms 308728 KB Output is correct
7 Correct 173 ms 308728 KB Output is correct
8 Correct 157 ms 308600 KB Output is correct
9 Correct 156 ms 308624 KB Output is correct
10 Correct 153 ms 308600 KB Output is correct
11 Correct 178 ms 308728 KB Output is correct
12 Correct 172 ms 308728 KB Output is correct
13 Correct 152 ms 308600 KB Output is correct
14 Correct 174 ms 308728 KB Output is correct
15 Correct 152 ms 308504 KB Output is correct
16 Correct 169 ms 308856 KB Output is correct
17 Correct 156 ms 308600 KB Output is correct
18 Correct 169 ms 308728 KB Output is correct
19 Correct 160 ms 308800 KB Output is correct
20 Correct 165 ms 308728 KB Output is correct
21 Correct 158 ms 308728 KB Output is correct
22 Correct 154 ms 308600 KB Output is correct
23 Incorrect 178 ms 308728 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 152 ms 308600 KB Output is correct
2 Correct 149 ms 308600 KB Output is correct
3 Correct 167 ms 308732 KB Output is correct
4 Correct 169 ms 308856 KB Output is correct
5 Correct 172 ms 308944 KB Output is correct
6 Correct 174 ms 308728 KB Output is correct
7 Correct 173 ms 308728 KB Output is correct
8 Correct 157 ms 308600 KB Output is correct
9 Correct 156 ms 308624 KB Output is correct
10 Correct 153 ms 308600 KB Output is correct
11 Correct 178 ms 308728 KB Output is correct
12 Correct 172 ms 308728 KB Output is correct
13 Correct 152 ms 308600 KB Output is correct
14 Correct 174 ms 308728 KB Output is correct
15 Correct 152 ms 308504 KB Output is correct
16 Correct 169 ms 308856 KB Output is correct
17 Correct 156 ms 308600 KB Output is correct
18 Correct 169 ms 308728 KB Output is correct
19 Correct 160 ms 308800 KB Output is correct
20 Correct 165 ms 308728 KB Output is correct
21 Correct 158 ms 308728 KB Output is correct
22 Correct 154 ms 308600 KB Output is correct
23 Incorrect 178 ms 308728 KB Output isn't correct
24 Halted 0 ms 0 KB -