# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246585 | 2020-07-09T16:15:54 Z | m3r8 | Political Development (BOI17_politicaldevelopment) | C++14 | 3000 ms | 313848 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(i & (1<<j) && !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 = 0; for(int i = 0;i<n;i++){ mx = 1; 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(); 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 308600 KB | Output is correct |
2 | Correct | 160 ms | 308612 KB | Output is correct |
3 | Correct | 188 ms | 308856 KB | Output is correct |
4 | Correct | 175 ms | 308856 KB | Output is correct |
5 | Correct | 176 ms | 308856 KB | Output is correct |
6 | Correct | 176 ms | 308856 KB | Output is correct |
7 | Correct | 177 ms | 308856 KB | Output is correct |
8 | Correct | 155 ms | 308472 KB | Output is correct |
9 | Correct | 156 ms | 308600 KB | Output is correct |
10 | Correct | 159 ms | 308728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 308600 KB | Output is correct |
2 | Correct | 160 ms | 308612 KB | Output is correct |
3 | Correct | 188 ms | 308856 KB | Output is correct |
4 | Correct | 175 ms | 308856 KB | Output is correct |
5 | Correct | 176 ms | 308856 KB | Output is correct |
6 | Correct | 176 ms | 308856 KB | Output is correct |
7 | Correct | 177 ms | 308856 KB | Output is correct |
8 | Correct | 155 ms | 308472 KB | Output is correct |
9 | Correct | 156 ms | 308600 KB | Output is correct |
10 | Correct | 159 ms | 308728 KB | Output is correct |
11 | Correct | 171 ms | 308728 KB | Output is correct |
12 | Correct | 179 ms | 308856 KB | Output is correct |
13 | Correct | 161 ms | 308600 KB | Output is correct |
14 | Correct | 172 ms | 308856 KB | Output is correct |
15 | Correct | 155 ms | 308600 KB | Output is correct |
16 | Correct | 173 ms | 308728 KB | Output is correct |
17 | Correct | 155 ms | 308600 KB | Output is correct |
18 | Correct | 184 ms | 308752 KB | Output is correct |
19 | Correct | 155 ms | 308476 KB | Output is correct |
20 | Correct | 164 ms | 308728 KB | Output is correct |
21 | Correct | 161 ms | 308728 KB | Output is correct |
22 | Correct | 160 ms | 308600 KB | Output is correct |
23 | Correct | 187 ms | 308728 KB | Output is correct |
24 | Correct | 156 ms | 308600 KB | Output is correct |
25 | Correct | 177 ms | 308856 KB | Output is correct |
26 | Correct | 178 ms | 308856 KB | Output is correct |
27 | Correct | 166 ms | 308788 KB | Output is correct |
28 | Correct | 179 ms | 308856 KB | Output is correct |
29 | Correct | 163 ms | 308856 KB | Output is correct |
30 | Correct | 183 ms | 308832 KB | Output is correct |
31 | Correct | 201 ms | 308860 KB | Output is correct |
32 | Correct | 174 ms | 308856 KB | Output is correct |
33 | Correct | 184 ms | 308984 KB | Output is correct |
34 | Correct | 189 ms | 308864 KB | Output is correct |
35 | Correct | 171 ms | 308728 KB | Output is correct |
36 | Correct | 162 ms | 308728 KB | Output is correct |
37 | Correct | 166 ms | 308728 KB | Output is correct |
38 | Correct | 172 ms | 308600 KB | Output is correct |
39 | Correct | 169 ms | 308728 KB | Output is correct |
40 | Correct | 210 ms | 308856 KB | Output is correct |
41 | Correct | 174 ms | 308732 KB | Output is correct |
42 | Correct | 205 ms | 308856 KB | Output is correct |
43 | Correct | 203 ms | 308856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 308600 KB | Output is correct |
2 | Correct | 161 ms | 308600 KB | Output is correct |
3 | Correct | 159 ms | 308600 KB | Output is correct |
4 | Correct | 158 ms | 308776 KB | Output is correct |
5 | Correct | 151 ms | 308600 KB | Output is correct |
6 | Correct | 157 ms | 308600 KB | Output is correct |
7 | Correct | 150 ms | 308600 KB | Output is correct |
8 | Correct | 158 ms | 308728 KB | Output is correct |
9 | Correct | 152 ms | 308600 KB | Output is correct |
10 | Correct | 151 ms | 308600 KB | Output is correct |
11 | Execution timed out | 3108 ms | 312952 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 308600 KB | Output is correct |
2 | Correct | 160 ms | 308612 KB | Output is correct |
3 | Correct | 188 ms | 308856 KB | Output is correct |
4 | Correct | 175 ms | 308856 KB | Output is correct |
5 | Correct | 176 ms | 308856 KB | Output is correct |
6 | Correct | 176 ms | 308856 KB | Output is correct |
7 | Correct | 177 ms | 308856 KB | Output is correct |
8 | Correct | 155 ms | 308472 KB | Output is correct |
9 | Correct | 156 ms | 308600 KB | Output is correct |
10 | Correct | 159 ms | 308728 KB | Output is correct |
11 | Correct | 171 ms | 308728 KB | Output is correct |
12 | Correct | 179 ms | 308856 KB | Output is correct |
13 | Correct | 161 ms | 308600 KB | Output is correct |
14 | Correct | 172 ms | 308856 KB | Output is correct |
15 | Correct | 155 ms | 308600 KB | Output is correct |
16 | Correct | 173 ms | 308728 KB | Output is correct |
17 | Correct | 155 ms | 308600 KB | Output is correct |
18 | Correct | 184 ms | 308752 KB | Output is correct |
19 | Correct | 155 ms | 308476 KB | Output is correct |
20 | Correct | 164 ms | 308728 KB | Output is correct |
21 | Correct | 161 ms | 308728 KB | Output is correct |
22 | Correct | 160 ms | 308600 KB | Output is correct |
23 | Correct | 187 ms | 308728 KB | Output is correct |
24 | Correct | 156 ms | 308600 KB | Output is correct |
25 | Correct | 177 ms | 308856 KB | Output is correct |
26 | Correct | 178 ms | 308856 KB | Output is correct |
27 | Correct | 166 ms | 308788 KB | Output is correct |
28 | Correct | 179 ms | 308856 KB | Output is correct |
29 | Correct | 163 ms | 308856 KB | Output is correct |
30 | Correct | 183 ms | 308832 KB | Output is correct |
31 | Correct | 201 ms | 308860 KB | Output is correct |
32 | Correct | 174 ms | 308856 KB | Output is correct |
33 | Correct | 184 ms | 308984 KB | Output is correct |
34 | Correct | 189 ms | 308864 KB | Output is correct |
35 | Correct | 171 ms | 308728 KB | Output is correct |
36 | Correct | 162 ms | 308728 KB | Output is correct |
37 | Correct | 166 ms | 308728 KB | Output is correct |
38 | Correct | 172 ms | 308600 KB | Output is correct |
39 | Correct | 169 ms | 308728 KB | Output is correct |
40 | Correct | 210 ms | 308856 KB | Output is correct |
41 | Correct | 174 ms | 308732 KB | Output is correct |
42 | Correct | 205 ms | 308856 KB | Output is correct |
43 | Correct | 203 ms | 308856 KB | Output is correct |
44 | Correct | 745 ms | 308984 KB | Output is correct |
45 | Correct | 163 ms | 308600 KB | Output is correct |
46 | Correct | 202 ms | 308856 KB | Output is correct |
47 | Correct | 329 ms | 309112 KB | Output is correct |
48 | Correct | 201 ms | 308984 KB | Output is correct |
49 | Correct | 338 ms | 309112 KB | Output is correct |
50 | Correct | 413 ms | 309112 KB | Output is correct |
51 | Execution timed out | 3057 ms | 309624 KB | Time limit exceeded |
52 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 154 ms | 308600 KB | Output is correct |
2 | Correct | 160 ms | 308612 KB | Output is correct |
3 | Correct | 188 ms | 308856 KB | Output is correct |
4 | Correct | 175 ms | 308856 KB | Output is correct |
5 | Correct | 176 ms | 308856 KB | Output is correct |
6 | Correct | 176 ms | 308856 KB | Output is correct |
7 | Correct | 177 ms | 308856 KB | Output is correct |
8 | Correct | 155 ms | 308472 KB | Output is correct |
9 | Correct | 156 ms | 308600 KB | Output is correct |
10 | Correct | 159 ms | 308728 KB | Output is correct |
11 | Correct | 171 ms | 308728 KB | Output is correct |
12 | Correct | 179 ms | 308856 KB | Output is correct |
13 | Correct | 161 ms | 308600 KB | Output is correct |
14 | Correct | 172 ms | 308856 KB | Output is correct |
15 | Correct | 155 ms | 308600 KB | Output is correct |
16 | Correct | 173 ms | 308728 KB | Output is correct |
17 | Correct | 155 ms | 308600 KB | Output is correct |
18 | Correct | 184 ms | 308752 KB | Output is correct |
19 | Correct | 155 ms | 308476 KB | Output is correct |
20 | Correct | 164 ms | 308728 KB | Output is correct |
21 | Correct | 161 ms | 308728 KB | Output is correct |
22 | Correct | 160 ms | 308600 KB | Output is correct |
23 | Correct | 187 ms | 308728 KB | Output is correct |
24 | Correct | 156 ms | 308600 KB | Output is correct |
25 | Correct | 177 ms | 308856 KB | Output is correct |
26 | Correct | 178 ms | 308856 KB | Output is correct |
27 | Correct | 166 ms | 308788 KB | Output is correct |
28 | Correct | 179 ms | 308856 KB | Output is correct |
29 | Correct | 163 ms | 308856 KB | Output is correct |
30 | Correct | 183 ms | 308832 KB | Output is correct |
31 | Correct | 201 ms | 308860 KB | Output is correct |
32 | Correct | 174 ms | 308856 KB | Output is correct |
33 | Correct | 184 ms | 308984 KB | Output is correct |
34 | Correct | 189 ms | 308864 KB | Output is correct |
35 | Correct | 171 ms | 308728 KB | Output is correct |
36 | Correct | 162 ms | 308728 KB | Output is correct |
37 | Correct | 166 ms | 308728 KB | Output is correct |
38 | Correct | 172 ms | 308600 KB | Output is correct |
39 | Correct | 169 ms | 308728 KB | Output is correct |
40 | Correct | 210 ms | 308856 KB | Output is correct |
41 | Correct | 174 ms | 308732 KB | Output is correct |
42 | Correct | 205 ms | 308856 KB | Output is correct |
43 | Correct | 203 ms | 308856 KB | Output is correct |
44 | Correct | 159 ms | 308600 KB | Output is correct |
45 | Correct | 1103 ms | 312952 KB | Output is correct |
46 | Correct | 424 ms | 311708 KB | Output is correct |
47 | Correct | 1077 ms | 313208 KB | Output is correct |
48 | Correct | 1056 ms | 312952 KB | Output is correct |
49 | Correct | 353 ms | 311488 KB | Output is correct |
50 | Correct | 1665 ms | 313848 KB | Output is correct |
51 | Correct | 1083 ms | 313168 KB | Output is correct |
52 | Correct | 367 ms | 311368 KB | Output is correct |
53 | Correct | 339 ms | 311412 KB | Output is correct |
54 | Correct | 184 ms | 309116 KB | Output is correct |
55 | Correct | 1663 ms | 313716 KB | Output is correct |
56 | Correct | 225 ms | 310856 KB | Output is correct |
57 | Correct | 361 ms | 311416 KB | Output is correct |
58 | Correct | 456 ms | 311672 KB | Output is correct |
59 | Correct | 229 ms | 310904 KB | Output is correct |
60 | Correct | 233 ms | 310952 KB | Output is correct |
61 | Correct | 396 ms | 311544 KB | Output is correct |
62 | Correct | 293 ms | 311160 KB | Output is correct |
63 | Correct | 528 ms | 311672 KB | Output is correct |
64 | Correct | 232 ms | 310904 KB | Output is correct |
65 | Correct | 728 ms | 312356 KB | Output is correct |
66 | Correct | 290 ms | 311160 KB | Output is correct |
67 | Correct | 524 ms | 311672 KB | Output is correct |
68 | Correct | 659 ms | 312056 KB | Output is correct |
69 | Correct | 732 ms | 312440 KB | Output is correct |
70 | Correct | 301 ms | 311368 KB | Output is correct |
71 | Correct | 676 ms | 312220 KB | Output is correct |
72 | Correct | 488 ms | 311816 KB | Output is correct |
73 | Correct | 892 ms | 312568 KB | Output is correct |
74 | Correct | 323 ms | 311160 KB | Output is correct |
75 | Correct | 369 ms | 310136 KB | Output is correct |
76 | Correct | 497 ms | 311800 KB | Output is correct |
77 | Correct | 871 ms | 312440 KB | Output is correct |
78 | Correct | 521 ms | 310520 KB | Output is correct |
79 | Correct | 375 ms | 310136 KB | Output is correct |
80 | Correct | 259 ms | 309368 KB | Output is correct |
81 | Correct | 520 ms | 310520 KB | Output is correct |
82 | Correct | 585 ms | 311800 KB | Output is correct |
83 | Correct | 262 ms | 309608 KB | Output is correct |
84 | Correct | 599 ms | 312008 KB | Output is correct |