#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
using namespace std;
typedef long long ll;
vector<vector<int>> v;
int ans = 0;
int n,k;
const int maxn = 1e5;
bitset<12> way[12];
int num[maxn];
map<pair<int,int>,bool> is_good;
bool check(int mask,int cnt){
int res = (1<<22)-1;
for(int i(0); i < cnt+1;i++){
if(mask&(1<<i)){
int to = way[i].to_ullong();
res&=to;
}
}
for(int i(0); i < cnt+1;i++){
if(mask&(1<<i)){
int bit = res&(1<<i);
if(!bit)return 0;
}
}
return 1;
}
void solve(int u){
int pnt = 0;
vector<int> qwe;
qwe.push_back(u);
for(int i(0); i < 12;i++)way[i] = 0;
for(int i(0); i < v[u].size();i++){
way[pnt][pnt] = 1;
num[v[u][i]] = pnt++;
qwe.push_back(v[u][i]);
}
num[u] = pnt;
way[pnt][pnt] = 1;
for(int i(0); i < qwe.size();i++){
for(int j(0); j < qwe.size();j++){
bool f = (is_good[{qwe[i],qwe[j]}] && is_good[{qwe[j],qwe[i]}]);
if(!f){
continue;
}
way[num[qwe[i]]][num[qwe[j]]] = 1;
}
}
int lim = (1<<(v[u].size()+1));
for(int i(0); i < lim;i++){
bool f = check(i,v[u].size());
if(!f)continue;
int x = i;
int now = 0;
while(x){
now+=(x%2);
x/=2;
}
//if(u == 0)cout << i << ' ' << now << endl;
ans = max(now,ans);
}
}
main()
{
ios_base::sync_with_stdio(0);
cin >> n >> k;
v.resize(n+2);
for(int i(0); i < n;i++){
int sz; cin >> sz;
for(int j(0); j < sz;j++){
int x; cin >> x;
v[i].push_back(x);
is_good[{i,x}] = 1;
}
}
for(int i(0); i < n;i++){
if(v[i].size() <=k)solve(i);
}
cout << ans;
return 0;
}
/*
3 10
0
0
0
*/
Compilation message
politicaldevelopment.cpp: In function 'void solve(int)':
politicaldevelopment.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i(0); i < v[u].size();i++){
~~^~~~~~~~~~~~~
politicaldevelopment.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i(0); i < qwe.size();i++){
~~^~~~~~~~~~~~
politicaldevelopment.cpp:49:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j(0); j < qwe.size();j++){
~~^~~~~~~~~~~~
politicaldevelopment.cpp: At global scope:
politicaldevelopment.cpp:72:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:86:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(v[i].size() <=k)solve(i);
~~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
16 ms |
1784 KB |
Output is correct |
4 |
Correct |
10 ms |
1660 KB |
Output is correct |
5 |
Correct |
11 ms |
1656 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
12 ms |
1656 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
16 ms |
1784 KB |
Output is correct |
4 |
Correct |
10 ms |
1660 KB |
Output is correct |
5 |
Correct |
11 ms |
1656 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
12 ms |
1656 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
10 ms |
1656 KB |
Output is correct |
12 |
Correct |
11 ms |
1660 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
11 ms |
1656 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
1628 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
23 ms |
1700 KB |
Output is correct |
19 |
Correct |
5 ms |
760 KB |
Output is correct |
20 |
Correct |
11 ms |
1272 KB |
Output is correct |
21 |
Correct |
10 ms |
1272 KB |
Output is correct |
22 |
Correct |
5 ms |
764 KB |
Output is correct |
23 |
Correct |
22 ms |
2424 KB |
Output is correct |
24 |
Correct |
4 ms |
760 KB |
Output is correct |
25 |
Correct |
21 ms |
2424 KB |
Output is correct |
26 |
Correct |
25 ms |
2296 KB |
Output is correct |
27 |
Correct |
24 ms |
2296 KB |
Output is correct |
28 |
Correct |
19 ms |
2296 KB |
Output is correct |
29 |
Correct |
19 ms |
2296 KB |
Output is correct |
30 |
Correct |
20 ms |
2424 KB |
Output is correct |
31 |
Correct |
23 ms |
2680 KB |
Output is correct |
32 |
Correct |
20 ms |
2424 KB |
Output is correct |
33 |
Correct |
23 ms |
2680 KB |
Output is correct |
34 |
Correct |
24 ms |
2808 KB |
Output is correct |
35 |
Correct |
12 ms |
1528 KB |
Output is correct |
36 |
Correct |
12 ms |
1504 KB |
Output is correct |
37 |
Correct |
12 ms |
1544 KB |
Output is correct |
38 |
Correct |
7 ms |
1016 KB |
Output is correct |
39 |
Correct |
7 ms |
1016 KB |
Output is correct |
40 |
Correct |
22 ms |
2936 KB |
Output is correct |
41 |
Correct |
7 ms |
888 KB |
Output is correct |
42 |
Correct |
26 ms |
2936 KB |
Output is correct |
43 |
Correct |
22 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
3033 ms |
151420 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
16 ms |
1784 KB |
Output is correct |
4 |
Correct |
10 ms |
1660 KB |
Output is correct |
5 |
Correct |
11 ms |
1656 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
12 ms |
1656 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
10 ms |
1656 KB |
Output is correct |
12 |
Correct |
11 ms |
1660 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
11 ms |
1656 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
1628 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
23 ms |
1700 KB |
Output is correct |
19 |
Correct |
5 ms |
760 KB |
Output is correct |
20 |
Correct |
11 ms |
1272 KB |
Output is correct |
21 |
Correct |
10 ms |
1272 KB |
Output is correct |
22 |
Correct |
5 ms |
764 KB |
Output is correct |
23 |
Correct |
22 ms |
2424 KB |
Output is correct |
24 |
Correct |
4 ms |
760 KB |
Output is correct |
25 |
Correct |
21 ms |
2424 KB |
Output is correct |
26 |
Correct |
25 ms |
2296 KB |
Output is correct |
27 |
Correct |
24 ms |
2296 KB |
Output is correct |
28 |
Correct |
19 ms |
2296 KB |
Output is correct |
29 |
Correct |
19 ms |
2296 KB |
Output is correct |
30 |
Correct |
20 ms |
2424 KB |
Output is correct |
31 |
Correct |
23 ms |
2680 KB |
Output is correct |
32 |
Correct |
20 ms |
2424 KB |
Output is correct |
33 |
Correct |
23 ms |
2680 KB |
Output is correct |
34 |
Correct |
24 ms |
2808 KB |
Output is correct |
35 |
Correct |
12 ms |
1528 KB |
Output is correct |
36 |
Correct |
12 ms |
1504 KB |
Output is correct |
37 |
Correct |
12 ms |
1544 KB |
Output is correct |
38 |
Correct |
7 ms |
1016 KB |
Output is correct |
39 |
Correct |
7 ms |
1016 KB |
Output is correct |
40 |
Correct |
22 ms |
2936 KB |
Output is correct |
41 |
Correct |
7 ms |
888 KB |
Output is correct |
42 |
Correct |
26 ms |
2936 KB |
Output is correct |
43 |
Correct |
22 ms |
2808 KB |
Output is correct |
44 |
Correct |
409 ms |
3912 KB |
Output is correct |
45 |
Correct |
2 ms |
376 KB |
Output is correct |
46 |
Incorrect |
29 ms |
3548 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
16 ms |
1784 KB |
Output is correct |
4 |
Correct |
10 ms |
1660 KB |
Output is correct |
5 |
Correct |
11 ms |
1656 KB |
Output is correct |
6 |
Correct |
12 ms |
1656 KB |
Output is correct |
7 |
Correct |
12 ms |
1656 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
10 ms |
1656 KB |
Output is correct |
12 |
Correct |
11 ms |
1660 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
11 ms |
1656 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
1628 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
23 ms |
1700 KB |
Output is correct |
19 |
Correct |
5 ms |
760 KB |
Output is correct |
20 |
Correct |
11 ms |
1272 KB |
Output is correct |
21 |
Correct |
10 ms |
1272 KB |
Output is correct |
22 |
Correct |
5 ms |
764 KB |
Output is correct |
23 |
Correct |
22 ms |
2424 KB |
Output is correct |
24 |
Correct |
4 ms |
760 KB |
Output is correct |
25 |
Correct |
21 ms |
2424 KB |
Output is correct |
26 |
Correct |
25 ms |
2296 KB |
Output is correct |
27 |
Correct |
24 ms |
2296 KB |
Output is correct |
28 |
Correct |
19 ms |
2296 KB |
Output is correct |
29 |
Correct |
19 ms |
2296 KB |
Output is correct |
30 |
Correct |
20 ms |
2424 KB |
Output is correct |
31 |
Correct |
23 ms |
2680 KB |
Output is correct |
32 |
Correct |
20 ms |
2424 KB |
Output is correct |
33 |
Correct |
23 ms |
2680 KB |
Output is correct |
34 |
Correct |
24 ms |
2808 KB |
Output is correct |
35 |
Correct |
12 ms |
1528 KB |
Output is correct |
36 |
Correct |
12 ms |
1504 KB |
Output is correct |
37 |
Correct |
12 ms |
1544 KB |
Output is correct |
38 |
Correct |
7 ms |
1016 KB |
Output is correct |
39 |
Correct |
7 ms |
1016 KB |
Output is correct |
40 |
Correct |
22 ms |
2936 KB |
Output is correct |
41 |
Correct |
7 ms |
888 KB |
Output is correct |
42 |
Correct |
26 ms |
2936 KB |
Output is correct |
43 |
Correct |
22 ms |
2808 KB |
Output is correct |
44 |
Correct |
2 ms |
380 KB |
Output is correct |
45 |
Incorrect |
389 ms |
39356 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |