// `Be name khoda` //
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn5 = 2e5 + 10;
set <int> adjset[maxn5];
vector <int> adj[maxn5], ver;
priority_queue <pair<int, int>> av;
bool ed[20][20], mark[maxn5], dp[1 << 20];
int cnt[maxn5];
inline int max_indep(){
int n = ver.size();
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++)
if(adjset[ver[i]].find(ver[j]) != adjset[ver[i]].end())
ed[i][j] = true;
dp[0] = true;
int ans = 0;
for(int mask = 1; mask < (1 << n); mask++){
int v = -1;
dp[mask] = true;
for(int i = 0; i < n; i++) if((mask >> i)&1){
if(v == -1){
v = i;
dp[mask] = dp[mask ^ (1 << i)];
}
else
dp[mask] &= ed[v][i];
}
if(dp[mask])
ans = max(ans, __builtin_popcount(mask));
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, k; cin >> n >> k;
for(int i = 0; i < n; i++){
int l; cin >> l;
cnt[i] = l;
while(l--){
int a; cin >> a;
adj[i].pb(a);
adjset[i].insert(a);
}
av.push({-cnt[i], i});
}
for(int i = 0; i < n; i++) for(auto u : adj[i])
assert(adjset[u].find(i) != adjset[u].end());
int ans = 0;
for(int i = 0; i < n; i++){
while(mark[av.top().se])
av.pop();
int v = av.top().se;
av.pop();
mark[v] = true;
ver.clear();
for(auto u : adj[v]) if(!mark[u]){
cnt[u]--;
av.push({-cnt[u], u});
ver.pb(u);
}
ans = max(ans, max_indep() + 1);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14420 KB |
Output is correct |
2 |
Correct |
7 ms |
14316 KB |
Output is correct |
3 |
Correct |
11 ms |
15060 KB |
Output is correct |
4 |
Correct |
11 ms |
15116 KB |
Output is correct |
5 |
Correct |
11 ms |
15060 KB |
Output is correct |
6 |
Correct |
11 ms |
15060 KB |
Output is correct |
7 |
Correct |
11 ms |
15060 KB |
Output is correct |
8 |
Correct |
8 ms |
14548 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14420 KB |
Output is correct |
2 |
Correct |
7 ms |
14316 KB |
Output is correct |
3 |
Correct |
11 ms |
15060 KB |
Output is correct |
4 |
Correct |
11 ms |
15116 KB |
Output is correct |
5 |
Correct |
11 ms |
15060 KB |
Output is correct |
6 |
Correct |
11 ms |
15060 KB |
Output is correct |
7 |
Correct |
11 ms |
15060 KB |
Output is correct |
8 |
Correct |
8 ms |
14548 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14548 KB |
Output is correct |
11 |
Correct |
11 ms |
15060 KB |
Output is correct |
12 |
Correct |
11 ms |
15112 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
15136 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
11 ms |
15100 KB |
Output is correct |
17 |
Correct |
7 ms |
14420 KB |
Output is correct |
18 |
Correct |
11 ms |
15060 KB |
Output is correct |
19 |
Correct |
8 ms |
14548 KB |
Output is correct |
20 |
Correct |
9 ms |
14804 KB |
Output is correct |
21 |
Correct |
9 ms |
14884 KB |
Output is correct |
22 |
Correct |
8 ms |
14536 KB |
Output is correct |
23 |
Correct |
13 ms |
15248 KB |
Output is correct |
24 |
Correct |
8 ms |
14544 KB |
Output is correct |
25 |
Correct |
13 ms |
15188 KB |
Output is correct |
26 |
Correct |
11 ms |
15164 KB |
Output is correct |
27 |
Correct |
12 ms |
15060 KB |
Output is correct |
28 |
Correct |
12 ms |
15104 KB |
Output is correct |
29 |
Correct |
10 ms |
15060 KB |
Output is correct |
30 |
Correct |
12 ms |
15256 KB |
Output is correct |
31 |
Correct |
13 ms |
15172 KB |
Output is correct |
32 |
Correct |
12 ms |
15244 KB |
Output is correct |
33 |
Correct |
12 ms |
15288 KB |
Output is correct |
34 |
Correct |
12 ms |
15188 KB |
Output is correct |
35 |
Correct |
10 ms |
14796 KB |
Output is correct |
36 |
Correct |
9 ms |
14804 KB |
Output is correct |
37 |
Correct |
9 ms |
14804 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14704 KB |
Output is correct |
40 |
Correct |
14 ms |
15648 KB |
Output is correct |
41 |
Correct |
9 ms |
14676 KB |
Output is correct |
42 |
Correct |
14 ms |
15648 KB |
Output is correct |
43 |
Correct |
14 ms |
15644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14536 KB |
Output is correct |
2 |
Incorrect |
8 ms |
14420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14420 KB |
Output is correct |
2 |
Correct |
7 ms |
14316 KB |
Output is correct |
3 |
Correct |
11 ms |
15060 KB |
Output is correct |
4 |
Correct |
11 ms |
15116 KB |
Output is correct |
5 |
Correct |
11 ms |
15060 KB |
Output is correct |
6 |
Correct |
11 ms |
15060 KB |
Output is correct |
7 |
Correct |
11 ms |
15060 KB |
Output is correct |
8 |
Correct |
8 ms |
14548 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14548 KB |
Output is correct |
11 |
Correct |
11 ms |
15060 KB |
Output is correct |
12 |
Correct |
11 ms |
15112 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
15136 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
11 ms |
15100 KB |
Output is correct |
17 |
Correct |
7 ms |
14420 KB |
Output is correct |
18 |
Correct |
11 ms |
15060 KB |
Output is correct |
19 |
Correct |
8 ms |
14548 KB |
Output is correct |
20 |
Correct |
9 ms |
14804 KB |
Output is correct |
21 |
Correct |
9 ms |
14884 KB |
Output is correct |
22 |
Correct |
8 ms |
14536 KB |
Output is correct |
23 |
Correct |
13 ms |
15248 KB |
Output is correct |
24 |
Correct |
8 ms |
14544 KB |
Output is correct |
25 |
Correct |
13 ms |
15188 KB |
Output is correct |
26 |
Correct |
11 ms |
15164 KB |
Output is correct |
27 |
Correct |
12 ms |
15060 KB |
Output is correct |
28 |
Correct |
12 ms |
15104 KB |
Output is correct |
29 |
Correct |
10 ms |
15060 KB |
Output is correct |
30 |
Correct |
12 ms |
15256 KB |
Output is correct |
31 |
Correct |
13 ms |
15172 KB |
Output is correct |
32 |
Correct |
12 ms |
15244 KB |
Output is correct |
33 |
Correct |
12 ms |
15288 KB |
Output is correct |
34 |
Correct |
12 ms |
15188 KB |
Output is correct |
35 |
Correct |
10 ms |
14796 KB |
Output is correct |
36 |
Correct |
9 ms |
14804 KB |
Output is correct |
37 |
Correct |
9 ms |
14804 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14704 KB |
Output is correct |
40 |
Correct |
14 ms |
15648 KB |
Output is correct |
41 |
Correct |
9 ms |
14676 KB |
Output is correct |
42 |
Correct |
14 ms |
15648 KB |
Output is correct |
43 |
Correct |
14 ms |
15644 KB |
Output is correct |
44 |
Correct |
27 ms |
16608 KB |
Output is correct |
45 |
Correct |
8 ms |
14420 KB |
Output is correct |
46 |
Correct |
15 ms |
15648 KB |
Output is correct |
47 |
Incorrect |
25 ms |
16892 KB |
Output isn't correct |
48 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14420 KB |
Output is correct |
2 |
Correct |
7 ms |
14316 KB |
Output is correct |
3 |
Correct |
11 ms |
15060 KB |
Output is correct |
4 |
Correct |
11 ms |
15116 KB |
Output is correct |
5 |
Correct |
11 ms |
15060 KB |
Output is correct |
6 |
Correct |
11 ms |
15060 KB |
Output is correct |
7 |
Correct |
11 ms |
15060 KB |
Output is correct |
8 |
Correct |
8 ms |
14548 KB |
Output is correct |
9 |
Correct |
7 ms |
14420 KB |
Output is correct |
10 |
Correct |
8 ms |
14548 KB |
Output is correct |
11 |
Correct |
11 ms |
15060 KB |
Output is correct |
12 |
Correct |
11 ms |
15112 KB |
Output is correct |
13 |
Correct |
7 ms |
14420 KB |
Output is correct |
14 |
Correct |
10 ms |
15136 KB |
Output is correct |
15 |
Correct |
8 ms |
14420 KB |
Output is correct |
16 |
Correct |
11 ms |
15100 KB |
Output is correct |
17 |
Correct |
7 ms |
14420 KB |
Output is correct |
18 |
Correct |
11 ms |
15060 KB |
Output is correct |
19 |
Correct |
8 ms |
14548 KB |
Output is correct |
20 |
Correct |
9 ms |
14804 KB |
Output is correct |
21 |
Correct |
9 ms |
14884 KB |
Output is correct |
22 |
Correct |
8 ms |
14536 KB |
Output is correct |
23 |
Correct |
13 ms |
15248 KB |
Output is correct |
24 |
Correct |
8 ms |
14544 KB |
Output is correct |
25 |
Correct |
13 ms |
15188 KB |
Output is correct |
26 |
Correct |
11 ms |
15164 KB |
Output is correct |
27 |
Correct |
12 ms |
15060 KB |
Output is correct |
28 |
Correct |
12 ms |
15104 KB |
Output is correct |
29 |
Correct |
10 ms |
15060 KB |
Output is correct |
30 |
Correct |
12 ms |
15256 KB |
Output is correct |
31 |
Correct |
13 ms |
15172 KB |
Output is correct |
32 |
Correct |
12 ms |
15244 KB |
Output is correct |
33 |
Correct |
12 ms |
15288 KB |
Output is correct |
34 |
Correct |
12 ms |
15188 KB |
Output is correct |
35 |
Correct |
10 ms |
14796 KB |
Output is correct |
36 |
Correct |
9 ms |
14804 KB |
Output is correct |
37 |
Correct |
9 ms |
14804 KB |
Output is correct |
38 |
Correct |
9 ms |
14676 KB |
Output is correct |
39 |
Correct |
9 ms |
14704 KB |
Output is correct |
40 |
Correct |
14 ms |
15648 KB |
Output is correct |
41 |
Correct |
9 ms |
14676 KB |
Output is correct |
42 |
Correct |
14 ms |
15648 KB |
Output is correct |
43 |
Correct |
14 ms |
15644 KB |
Output is correct |
44 |
Correct |
9 ms |
14420 KB |
Output is correct |
45 |
Correct |
160 ms |
33156 KB |
Output is correct |
46 |
Correct |
79 ms |
23860 KB |
Output is correct |
47 |
Correct |
165 ms |
33088 KB |
Output is correct |
48 |
Correct |
157 ms |
33132 KB |
Output is correct |
49 |
Correct |
47 ms |
21416 KB |
Output is correct |
50 |
Correct |
184 ms |
37800 KB |
Output is correct |
51 |
Incorrect |
176 ms |
33208 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |