Submission #246572

# Submission time Handle Problem Language Result Execution time Memory
246572 2020-07-09T15:51:49 Z m3r8 Political Development (BOI17_politicaldevelopment) C++14
4 / 100
3000 ms 315512 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 = 0;
    for(int j = 0;j<akt.size();j++){
      if(i & (1<<j)){
        cnt++;
        tmp &= add[akt[j]];
      };  
    };
    if(tmp.count() >= cnt+1){
      erg = std::max(erg,cnt+1);
    };
  };
  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:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(tmp.count() >= cnt+1){
        ~~~~~~~~~~~~^~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:56:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(adj[i].size() < k){
        ~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:76:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(add[i].count() < k){
            ~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:41: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:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&d);
     ~~~~~^~~~~~~~~
politicaldevelopment.cpp:50: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 158 ms 308600 KB Output is correct
2 Correct 149 ms 308848 KB Output is correct
3 Correct 175 ms 308856 KB Output is correct
4 Correct 196 ms 308856 KB Output is correct
5 Correct 192 ms 308856 KB Output is correct
6 Correct 193 ms 308860 KB Output is correct
7 Correct 199 ms 308856 KB Output is correct
8 Correct 162 ms 308728 KB Output is correct
9 Correct 151 ms 308600 KB Output is correct
10 Correct 164 ms 308600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 158 ms 308600 KB Output is correct
2 Correct 149 ms 308848 KB Output is correct
3 Correct 175 ms 308856 KB Output is correct
4 Correct 196 ms 308856 KB Output is correct
5 Correct 192 ms 308856 KB Output is correct
6 Correct 193 ms 308860 KB Output is correct
7 Correct 199 ms 308856 KB Output is correct
8 Correct 162 ms 308728 KB Output is correct
9 Correct 151 ms 308600 KB Output is correct
10 Correct 164 ms 308600 KB Output is correct
11 Correct 202 ms 308908 KB Output is correct
12 Correct 192 ms 308912 KB Output is correct
13 Correct 150 ms 308604 KB Output is correct
14 Correct 199 ms 308856 KB Output is correct
15 Correct 155 ms 308700 KB Output is correct
16 Correct 200 ms 308856 KB Output is correct
17 Correct 155 ms 308568 KB Output is correct
18 Correct 256 ms 308920 KB Output is correct
19 Correct 166 ms 308600 KB Output is correct
20 Correct 173 ms 308728 KB Output is correct
21 Correct 183 ms 308856 KB Output is correct
22 Correct 175 ms 308600 KB Output is correct
23 Incorrect 193 ms 308828 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 308648 KB Output is correct
2 Correct 152 ms 308600 KB Output is correct
3 Correct 157 ms 308592 KB Output is correct
4 Correct 150 ms 308600 KB Output is correct
5 Correct 152 ms 308728 KB Output is correct
6 Correct 153 ms 308600 KB Output is correct
7 Correct 151 ms 308600 KB Output is correct
8 Correct 156 ms 308600 KB Output is correct
9 Correct 156 ms 308600 KB Output is correct
10 Correct 155 ms 308600 KB Output is correct
11 Execution timed out 3083 ms 315512 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 158 ms 308600 KB Output is correct
2 Correct 149 ms 308848 KB Output is correct
3 Correct 175 ms 308856 KB Output is correct
4 Correct 196 ms 308856 KB Output is correct
5 Correct 192 ms 308856 KB Output is correct
6 Correct 193 ms 308860 KB Output is correct
7 Correct 199 ms 308856 KB Output is correct
8 Correct 162 ms 308728 KB Output is correct
9 Correct 151 ms 308600 KB Output is correct
10 Correct 164 ms 308600 KB Output is correct
11 Correct 202 ms 308908 KB Output is correct
12 Correct 192 ms 308912 KB Output is correct
13 Correct 150 ms 308604 KB Output is correct
14 Correct 199 ms 308856 KB Output is correct
15 Correct 155 ms 308700 KB Output is correct
16 Correct 200 ms 308856 KB Output is correct
17 Correct 155 ms 308568 KB Output is correct
18 Correct 256 ms 308920 KB Output is correct
19 Correct 166 ms 308600 KB Output is correct
20 Correct 173 ms 308728 KB Output is correct
21 Correct 183 ms 308856 KB Output is correct
22 Correct 175 ms 308600 KB Output is correct
23 Incorrect 193 ms 308828 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 158 ms 308600 KB Output is correct
2 Correct 149 ms 308848 KB Output is correct
3 Correct 175 ms 308856 KB Output is correct
4 Correct 196 ms 308856 KB Output is correct
5 Correct 192 ms 308856 KB Output is correct
6 Correct 193 ms 308860 KB Output is correct
7 Correct 199 ms 308856 KB Output is correct
8 Correct 162 ms 308728 KB Output is correct
9 Correct 151 ms 308600 KB Output is correct
10 Correct 164 ms 308600 KB Output is correct
11 Correct 202 ms 308908 KB Output is correct
12 Correct 192 ms 308912 KB Output is correct
13 Correct 150 ms 308604 KB Output is correct
14 Correct 199 ms 308856 KB Output is correct
15 Correct 155 ms 308700 KB Output is correct
16 Correct 200 ms 308856 KB Output is correct
17 Correct 155 ms 308568 KB Output is correct
18 Correct 256 ms 308920 KB Output is correct
19 Correct 166 ms 308600 KB Output is correct
20 Correct 173 ms 308728 KB Output is correct
21 Correct 183 ms 308856 KB Output is correct
22 Correct 175 ms 308600 KB Output is correct
23 Incorrect 193 ms 308828 KB Output isn't correct
24 Halted 0 ms 0 KB -