답안 #246588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246588 2020-07-09T16:31:05 Z m3r8 Political Development (BOI17_politicaldevelopment) C++14
100 / 100
256 ms 34552 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];
std::set<int> tst[N];
int k;
std::queue<int> que;
int used[N];
int dg[N];

int clq(std::vector<int> akt, int depth, int idx){
  if(!akt.size() ||depth == k)return depth;
  else{
    int mx = 0;
    for(int i = 0;i<akt.size();i++){
      std::vector<int> nxt;  
      for(int j = i+1;j<akt.size();j++){
        if(tst[akt[i]].count(akt[j])){
          nxt.push_back(akt[j]);  
        };
      };
      mx = std::max(mx,clq(nxt,depth+1,idx));
    };
    return mx;
  };
};

int main(void){
  int n;  
  scanf("%d %d",&n,&k);
  int d;
  int x;
  int mx = 0;
  for(int i = 0;i<n;i++){
    mx = 1;
    tst[i].insert(i);
    scanf("%d",&d);
    for(int j = 0;j<d;j++){
      mx = 2;
      scanf("%d",&x);
      tst[i].insert(x);
      adj[i].push_back(x);
    };
  };
  for(int i = 0;i<n;i++){
    dg[i] = adj[i].size();
    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();  
    std::vector<int> akt;
    used[ak] = 2;
    for(auto i: adj[ak]){
      if(used[i] != 2){
        akt.push_back(i);
      };  
    };
    mx = std::max(mx,clq(akt,1,ak));
    for(auto i: adj[ak]){
      if(!used[i]){
        dg[i]--;
        if(dg[i] < k){
          used[i] = 1;
          que.push(i);  
        };
      };  
    };
  };
  printf("%d\n",mx);
  return 0;
};

Compilation message

politicaldevelopment.cpp: In function 'int clq(std::vector<int>, int, int)':
politicaldevelopment.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<akt.size();i++){
                   ~^~~~~~~~~~~
politicaldevelopment.cpp:26:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j = i+1;j<akt.size();j++){
                       ~^~~~~~~~~~~
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:39: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:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&d);
     ~~~~~^~~~~~~~~
politicaldevelopment.cpp:49:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&x);
       ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 11 ms 4864 KB Output is correct
4 Correct 11 ms 4864 KB Output is correct
5 Correct 11 ms 4864 KB Output is correct
6 Correct 11 ms 4864 KB Output is correct
7 Correct 11 ms 4864 KB Output is correct
8 Correct 8 ms 4224 KB Output is correct
9 Correct 6 ms 3840 KB Output is correct
10 Correct 7 ms 4096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 11 ms 4864 KB Output is correct
4 Correct 11 ms 4864 KB Output is correct
5 Correct 11 ms 4864 KB Output is correct
6 Correct 11 ms 4864 KB Output is correct
7 Correct 11 ms 4864 KB Output is correct
8 Correct 8 ms 4224 KB Output is correct
9 Correct 6 ms 3840 KB Output is correct
10 Correct 7 ms 4096 KB Output is correct
11 Correct 11 ms 4736 KB Output is correct
12 Correct 11 ms 4736 KB Output is correct
13 Correct 7 ms 3840 KB Output is correct
14 Correct 12 ms 4736 KB Output is correct
15 Correct 6 ms 3840 KB Output is correct
16 Correct 11 ms 4736 KB Output is correct
17 Correct 6 ms 3840 KB Output is correct
18 Correct 15 ms 4864 KB Output is correct
19 Correct 7 ms 4096 KB Output is correct
20 Correct 10 ms 4608 KB Output is correct
21 Correct 9 ms 4480 KB Output is correct
22 Correct 7 ms 4096 KB Output is correct
23 Correct 12 ms 4864 KB Output is correct
24 Correct 7 ms 4096 KB Output is correct
25 Correct 12 ms 4992 KB Output is correct
26 Correct 13 ms 4864 KB Output is correct
27 Correct 11 ms 4864 KB Output is correct
28 Correct 11 ms 4916 KB Output is correct
29 Correct 11 ms 4864 KB Output is correct
30 Correct 12 ms 4992 KB Output is correct
31 Correct 12 ms 4992 KB Output is correct
32 Correct 12 ms 4992 KB Output is correct
33 Correct 12 ms 4992 KB Output is correct
34 Correct 13 ms 4992 KB Output is correct
35 Correct 10 ms 4352 KB Output is correct
36 Correct 9 ms 4352 KB Output is correct
37 Correct 10 ms 4352 KB Output is correct
38 Correct 8 ms 4224 KB Output is correct
39 Correct 8 ms 4224 KB Output is correct
40 Correct 15 ms 5376 KB Output is correct
41 Correct 8 ms 4224 KB Output is correct
42 Correct 15 ms 5376 KB Output is correct
43 Correct 14 ms 5376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4096 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 6 ms 3840 KB Output is correct
4 Correct 6 ms 3840 KB Output is correct
5 Correct 7 ms 3840 KB Output is correct
6 Correct 6 ms 3840 KB Output is correct
7 Correct 6 ms 3840 KB Output is correct
8 Correct 6 ms 3840 KB Output is correct
9 Correct 6 ms 3840 KB Output is correct
10 Correct 6 ms 3840 KB Output is correct
11 Correct 241 ms 31824 KB Output is correct
12 Correct 7 ms 3840 KB Output is correct
13 Correct 236 ms 34512 KB Output is correct
14 Correct 6 ms 3840 KB Output is correct
15 Correct 239 ms 34484 KB Output is correct
16 Correct 238 ms 34552 KB Output is correct
17 Correct 256 ms 34400 KB Output is correct
18 Correct 247 ms 34512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 11 ms 4864 KB Output is correct
4 Correct 11 ms 4864 KB Output is correct
5 Correct 11 ms 4864 KB Output is correct
6 Correct 11 ms 4864 KB Output is correct
7 Correct 11 ms 4864 KB Output is correct
8 Correct 8 ms 4224 KB Output is correct
9 Correct 6 ms 3840 KB Output is correct
10 Correct 7 ms 4096 KB Output is correct
11 Correct 11 ms 4736 KB Output is correct
12 Correct 11 ms 4736 KB Output is correct
13 Correct 7 ms 3840 KB Output is correct
14 Correct 12 ms 4736 KB Output is correct
15 Correct 6 ms 3840 KB Output is correct
16 Correct 11 ms 4736 KB Output is correct
17 Correct 6 ms 3840 KB Output is correct
18 Correct 15 ms 4864 KB Output is correct
19 Correct 7 ms 4096 KB Output is correct
20 Correct 10 ms 4608 KB Output is correct
21 Correct 9 ms 4480 KB Output is correct
22 Correct 7 ms 4096 KB Output is correct
23 Correct 12 ms 4864 KB Output is correct
24 Correct 7 ms 4096 KB Output is correct
25 Correct 12 ms 4992 KB Output is correct
26 Correct 13 ms 4864 KB Output is correct
27 Correct 11 ms 4864 KB Output is correct
28 Correct 11 ms 4916 KB Output is correct
29 Correct 11 ms 4864 KB Output is correct
30 Correct 12 ms 4992 KB Output is correct
31 Correct 12 ms 4992 KB Output is correct
32 Correct 12 ms 4992 KB Output is correct
33 Correct 12 ms 4992 KB Output is correct
34 Correct 13 ms 4992 KB Output is correct
35 Correct 10 ms 4352 KB Output is correct
36 Correct 9 ms 4352 KB Output is correct
37 Correct 10 ms 4352 KB Output is correct
38 Correct 8 ms 4224 KB Output is correct
39 Correct 8 ms 4224 KB Output is correct
40 Correct 15 ms 5376 KB Output is correct
41 Correct 8 ms 4224 KB Output is correct
42 Correct 15 ms 5376 KB Output is correct
43 Correct 14 ms 5376 KB Output is correct
44 Correct 41 ms 6400 KB Output is correct
45 Correct 7 ms 3840 KB Output is correct
46 Correct 15 ms 5376 KB Output is correct
47 Correct 23 ms 6400 KB Output is correct
48 Correct 16 ms 5376 KB Output is correct
49 Correct 24 ms 6400 KB Output is correct
50 Correct 32 ms 6400 KB Output is correct
51 Correct 44 ms 8576 KB Output is correct
52 Correct 11 ms 4864 KB Output is correct
53 Correct 47 ms 9464 KB Output is correct
54 Correct 58 ms 9336 KB Output is correct
55 Correct 11 ms 4864 KB Output is correct
56 Correct 11 ms 4864 KB Output is correct
57 Correct 8 ms 4224 KB Output is correct
58 Correct 69 ms 9336 KB Output is correct
59 Correct 16 ms 5376 KB Output is correct
60 Correct 11 ms 4864 KB Output is correct
61 Correct 22 ms 5376 KB Output is correct
62 Correct 23 ms 5376 KB Output is correct
63 Correct 41 ms 6400 KB Output is correct
64 Correct 30 ms 6272 KB Output is correct
65 Correct 14 ms 5248 KB Output is correct
66 Correct 15 ms 5376 KB Output is correct
67 Correct 32 ms 6912 KB Output is correct
68 Correct 32 ms 6272 KB Output is correct
69 Correct 14 ms 5248 KB Output is correct
70 Correct 22 ms 6272 KB Output is correct
71 Correct 31 ms 6960 KB Output is correct
72 Correct 28 ms 6780 KB Output is correct
73 Correct 11 ms 4864 KB Output is correct
74 Correct 22 ms 6272 KB Output is correct
75 Correct 29 ms 6912 KB Output is correct
76 Correct 18 ms 5760 KB Output is correct
77 Correct 30 ms 7552 KB Output is correct
78 Correct 11 ms 4864 KB Output is correct
79 Correct 18 ms 5632 KB Output is correct
80 Correct 18 ms 5760 KB Output is correct
81 Correct 31 ms 7424 KB Output is correct
82 Correct 8 ms 4224 KB Output is correct
83 Correct 20 ms 5684 KB Output is correct
84 Correct 25 ms 6912 KB Output is correct
85 Correct 8 ms 4224 KB Output is correct
86 Correct 25 ms 6912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 11 ms 4864 KB Output is correct
4 Correct 11 ms 4864 KB Output is correct
5 Correct 11 ms 4864 KB Output is correct
6 Correct 11 ms 4864 KB Output is correct
7 Correct 11 ms 4864 KB Output is correct
8 Correct 8 ms 4224 KB Output is correct
9 Correct 6 ms 3840 KB Output is correct
10 Correct 7 ms 4096 KB Output is correct
11 Correct 11 ms 4736 KB Output is correct
12 Correct 11 ms 4736 KB Output is correct
13 Correct 7 ms 3840 KB Output is correct
14 Correct 12 ms 4736 KB Output is correct
15 Correct 6 ms 3840 KB Output is correct
16 Correct 11 ms 4736 KB Output is correct
17 Correct 6 ms 3840 KB Output is correct
18 Correct 15 ms 4864 KB Output is correct
19 Correct 7 ms 4096 KB Output is correct
20 Correct 10 ms 4608 KB Output is correct
21 Correct 9 ms 4480 KB Output is correct
22 Correct 7 ms 4096 KB Output is correct
23 Correct 12 ms 4864 KB Output is correct
24 Correct 7 ms 4096 KB Output is correct
25 Correct 12 ms 4992 KB Output is correct
26 Correct 13 ms 4864 KB Output is correct
27 Correct 11 ms 4864 KB Output is correct
28 Correct 11 ms 4916 KB Output is correct
29 Correct 11 ms 4864 KB Output is correct
30 Correct 12 ms 4992 KB Output is correct
31 Correct 12 ms 4992 KB Output is correct
32 Correct 12 ms 4992 KB Output is correct
33 Correct 12 ms 4992 KB Output is correct
34 Correct 13 ms 4992 KB Output is correct
35 Correct 10 ms 4352 KB Output is correct
36 Correct 9 ms 4352 KB Output is correct
37 Correct 10 ms 4352 KB Output is correct
38 Correct 8 ms 4224 KB Output is correct
39 Correct 8 ms 4224 KB Output is correct
40 Correct 15 ms 5376 KB Output is correct
41 Correct 8 ms 4224 KB Output is correct
42 Correct 15 ms 5376 KB Output is correct
43 Correct 14 ms 5376 KB Output is correct
44 Correct 7 ms 3840 KB Output is correct
45 Correct 154 ms 23160 KB Output is correct
46 Correct 87 ms 15636 KB Output is correct
47 Correct 166 ms 23284 KB Output is correct
48 Correct 156 ms 23160 KB Output is correct
49 Correct 59 ms 13428 KB Output is correct
50 Correct 198 ms 28196 KB Output is correct
51 Correct 160 ms 23288 KB Output is correct
52 Correct 53 ms 13304 KB Output is correct
53 Correct 57 ms 13300 KB Output is correct
54 Correct 16 ms 6912 KB Output is correct
55 Correct 199 ms 28148 KB Output is correct
56 Correct 34 ms 10752 KB Output is correct
57 Correct 53 ms 13304 KB Output is correct
58 Correct 81 ms 15480 KB Output is correct
59 Correct 34 ms 10752 KB Output is correct
60 Correct 35 ms 10744 KB Output is correct
61 Correct 84 ms 15480 KB Output is correct
62 Correct 57 ms 13176 KB Output is correct
63 Correct 101 ms 16836 KB Output is correct
64 Correct 35 ms 10752 KB Output is correct
65 Correct 126 ms 19320 KB Output is correct
66 Correct 57 ms 13176 KB Output is correct
67 Correct 105 ms 16888 KB Output is correct
68 Correct 116 ms 18556 KB Output is correct
69 Correct 122 ms 19192 KB Output is correct
70 Correct 55 ms 13048 KB Output is correct
71 Correct 115 ms 18680 KB Output is correct
72 Correct 96 ms 16376 KB Output is correct
73 Correct 135 ms 20716 KB Output is correct
74 Correct 55 ms 13048 KB Output is correct
75 Correct 54 ms 10872 KB Output is correct
76 Correct 97 ms 16376 KB Output is correct
77 Correct 142 ms 20728 KB Output is correct
78 Correct 66 ms 12280 KB Output is correct
79 Correct 52 ms 10744 KB Output is correct
80 Correct 30 ms 7424 KB Output is correct
81 Correct 67 ms 12280 KB Output is correct
82 Correct 98 ms 17660 KB Output is correct
83 Correct 28 ms 7424 KB Output is correct
84 Correct 96 ms 17784 KB Output is correct