/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
map<pair<int,int>,bool> edge;
int n,k,used[50004],c[(1<<11)+5],ind[50004],s[50004],f[(1<<11)+5],ans=1;
vector<int> g[50004];
queue<int> q;
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++)
{
int d,x;
cin>>d;
for(int j=0;j<d;j++)
{
scanf("%d",&x);
g[i].PB(x);
edge[MP(i,x)]=1;
}
s[i]=g[i].size();
}
for(int i=1;i<(1<<k);i++)
for(int j=0;j<k;j++)
if(((1<<j)&i))
{
c[i]++;
f[i]=j;
}
for(int i=0;i<n;i++)
if(s[i]<k)
q.push(i);
while(!q.empty())
{
int v=q.front();
q.pop();
if(used[v])
continue;
used[v]=1;
vector<int> a,mask;
for(int i=0;i<g[v].size();i++)
{
int to=g[v][i];
if(!used[to])
a.PB(to);
s[to]--;
if(s[to]<k)
q.push(to);
}
mask.resize(a.size(),0);
for(int i=0;i<a.size();i++)
ind[a[i]]=i;
for(int i=0;i<a.size();i++)
for(int j=0;j<a.size();j++)
{
if(i==j || edge.find(MP(a[i],a[j]))==edge.end())
continue;
mask[i]+=(1<<j);
}
vector<bool> dp((1<<a.size())+10);
dp[0]=1;
for(int m=1;m<(1<<a.size());m++)
{
int bit=f[m];
int y=m-(1<<bit);
if( (mask[bit]&y)==y && dp[y])
{
dp[m]=1;
ans=max(ans,c[m]+1);
}
}
}
cout<<ans<<endl;
return 0;
}
/*
4 2
2 1 4
2 0 2
2
2 4 0
*/
Compilation message
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:65:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<g[v].size();i++)
~^~~~~~~~~~~~
politicaldevelopment.cpp:75:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<a.size();i++)
~^~~~~~~~~
politicaldevelopment.cpp:77:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<a.size();i++)
~^~~~~~~~~
politicaldevelopment.cpp:78:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<a.size();j++)
~^~~~~~~~~
politicaldevelopment.cpp:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1528 KB |
Output is correct |
2 |
Correct |
3 ms |
1528 KB |
Output is correct |
3 |
Correct |
9 ms |
2424 KB |
Output is correct |
4 |
Correct |
9 ms |
2424 KB |
Output is correct |
5 |
Correct |
9 ms |
2424 KB |
Output is correct |
6 |
Correct |
9 ms |
2424 KB |
Output is correct |
7 |
Correct |
9 ms |
2552 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1528 KB |
Output is correct |
2 |
Correct |
3 ms |
1528 KB |
Output is correct |
3 |
Correct |
9 ms |
2424 KB |
Output is correct |
4 |
Correct |
9 ms |
2424 KB |
Output is correct |
5 |
Correct |
9 ms |
2424 KB |
Output is correct |
6 |
Correct |
9 ms |
2424 KB |
Output is correct |
7 |
Correct |
9 ms |
2552 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1656 KB |
Output is correct |
11 |
Correct |
9 ms |
2424 KB |
Output is correct |
12 |
Correct |
10 ms |
2424 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
9 ms |
2424 KB |
Output is correct |
15 |
Correct |
3 ms |
1528 KB |
Output is correct |
16 |
Correct |
9 ms |
2424 KB |
Output is correct |
17 |
Correct |
3 ms |
1528 KB |
Output is correct |
18 |
Correct |
9 ms |
2424 KB |
Output is correct |
19 |
Correct |
4 ms |
1528 KB |
Output is correct |
20 |
Correct |
7 ms |
2168 KB |
Output is correct |
21 |
Correct |
7 ms |
2040 KB |
Output is correct |
22 |
Correct |
5 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
2552 KB |
Output is correct |
24 |
Correct |
5 ms |
1656 KB |
Output is correct |
25 |
Correct |
11 ms |
2552 KB |
Output is correct |
26 |
Correct |
11 ms |
2552 KB |
Output is correct |
27 |
Correct |
10 ms |
2424 KB |
Output is correct |
28 |
Correct |
11 ms |
2552 KB |
Output is correct |
29 |
Correct |
10 ms |
2424 KB |
Output is correct |
30 |
Correct |
12 ms |
2680 KB |
Output is correct |
31 |
Correct |
12 ms |
2680 KB |
Output is correct |
32 |
Correct |
12 ms |
2680 KB |
Output is correct |
33 |
Correct |
12 ms |
2684 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
7 ms |
2040 KB |
Output is correct |
36 |
Correct |
7 ms |
2040 KB |
Output is correct |
37 |
Correct |
7 ms |
2040 KB |
Output is correct |
38 |
Correct |
6 ms |
1912 KB |
Output is correct |
39 |
Correct |
6 ms |
1912 KB |
Output is correct |
40 |
Correct |
16 ms |
3064 KB |
Output is correct |
41 |
Correct |
6 ms |
1912 KB |
Output is correct |
42 |
Correct |
17 ms |
3064 KB |
Output is correct |
43 |
Correct |
17 ms |
3192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1528 KB |
Output is correct |
2 |
Correct |
3 ms |
1448 KB |
Output is correct |
3 |
Correct |
3 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1532 KB |
Output is correct |
5 |
Correct |
3 ms |
1500 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1532 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1528 KB |
Output is correct |
11 |
Correct |
537 ms |
36448 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
640 ms |
36472 KB |
Output is correct |
14 |
Correct |
3 ms |
1528 KB |
Output is correct |
15 |
Correct |
619 ms |
36452 KB |
Output is correct |
16 |
Correct |
545 ms |
36728 KB |
Output is correct |
17 |
Correct |
536 ms |
36444 KB |
Output is correct |
18 |
Correct |
556 ms |
36540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1528 KB |
Output is correct |
2 |
Correct |
3 ms |
1528 KB |
Output is correct |
3 |
Correct |
9 ms |
2424 KB |
Output is correct |
4 |
Correct |
9 ms |
2424 KB |
Output is correct |
5 |
Correct |
9 ms |
2424 KB |
Output is correct |
6 |
Correct |
9 ms |
2424 KB |
Output is correct |
7 |
Correct |
9 ms |
2552 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1656 KB |
Output is correct |
11 |
Correct |
9 ms |
2424 KB |
Output is correct |
12 |
Correct |
10 ms |
2424 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
9 ms |
2424 KB |
Output is correct |
15 |
Correct |
3 ms |
1528 KB |
Output is correct |
16 |
Correct |
9 ms |
2424 KB |
Output is correct |
17 |
Correct |
3 ms |
1528 KB |
Output is correct |
18 |
Correct |
9 ms |
2424 KB |
Output is correct |
19 |
Correct |
4 ms |
1528 KB |
Output is correct |
20 |
Correct |
7 ms |
2168 KB |
Output is correct |
21 |
Correct |
7 ms |
2040 KB |
Output is correct |
22 |
Correct |
5 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
2552 KB |
Output is correct |
24 |
Correct |
5 ms |
1656 KB |
Output is correct |
25 |
Correct |
11 ms |
2552 KB |
Output is correct |
26 |
Correct |
11 ms |
2552 KB |
Output is correct |
27 |
Correct |
10 ms |
2424 KB |
Output is correct |
28 |
Correct |
11 ms |
2552 KB |
Output is correct |
29 |
Correct |
10 ms |
2424 KB |
Output is correct |
30 |
Correct |
12 ms |
2680 KB |
Output is correct |
31 |
Correct |
12 ms |
2680 KB |
Output is correct |
32 |
Correct |
12 ms |
2680 KB |
Output is correct |
33 |
Correct |
12 ms |
2684 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
7 ms |
2040 KB |
Output is correct |
36 |
Correct |
7 ms |
2040 KB |
Output is correct |
37 |
Correct |
7 ms |
2040 KB |
Output is correct |
38 |
Correct |
6 ms |
1912 KB |
Output is correct |
39 |
Correct |
6 ms |
1912 KB |
Output is correct |
40 |
Correct |
16 ms |
3064 KB |
Output is correct |
41 |
Correct |
6 ms |
1912 KB |
Output is correct |
42 |
Correct |
17 ms |
3064 KB |
Output is correct |
43 |
Correct |
17 ms |
3192 KB |
Output is correct |
44 |
Correct |
42 ms |
4600 KB |
Output is correct |
45 |
Correct |
3 ms |
1528 KB |
Output is correct |
46 |
Correct |
17 ms |
3164 KB |
Output is correct |
47 |
Correct |
35 ms |
4600 KB |
Output is correct |
48 |
Correct |
17 ms |
3064 KB |
Output is correct |
49 |
Correct |
36 ms |
4604 KB |
Output is correct |
50 |
Correct |
37 ms |
4600 KB |
Output is correct |
51 |
Correct |
91 ms |
7416 KB |
Output is correct |
52 |
Correct |
9 ms |
2424 KB |
Output is correct |
53 |
Correct |
82 ms |
8312 KB |
Output is correct |
54 |
Correct |
107 ms |
8256 KB |
Output is correct |
55 |
Correct |
9 ms |
2424 KB |
Output is correct |
56 |
Correct |
10 ms |
2424 KB |
Output is correct |
57 |
Correct |
4 ms |
1656 KB |
Output is correct |
58 |
Correct |
81 ms |
8440 KB |
Output is correct |
59 |
Correct |
17 ms |
3192 KB |
Output is correct |
60 |
Correct |
9 ms |
2424 KB |
Output is correct |
61 |
Correct |
20 ms |
3192 KB |
Output is correct |
62 |
Correct |
18 ms |
3192 KB |
Output is correct |
63 |
Correct |
39 ms |
4728 KB |
Output is correct |
64 |
Correct |
35 ms |
4364 KB |
Output is correct |
65 |
Correct |
16 ms |
2936 KB |
Output is correct |
66 |
Correct |
17 ms |
3192 KB |
Output is correct |
67 |
Correct |
46 ms |
5240 KB |
Output is correct |
68 |
Correct |
31 ms |
4356 KB |
Output is correct |
69 |
Correct |
15 ms |
2908 KB |
Output is correct |
70 |
Correct |
33 ms |
4444 KB |
Output is correct |
71 |
Correct |
46 ms |
5112 KB |
Output is correct |
72 |
Correct |
44 ms |
5112 KB |
Output is correct |
73 |
Correct |
10 ms |
2424 KB |
Output is correct |
74 |
Correct |
33 ms |
4344 KB |
Output is correct |
75 |
Correct |
44 ms |
5112 KB |
Output is correct |
76 |
Correct |
23 ms |
3704 KB |
Output is correct |
77 |
Correct |
57 ms |
6008 KB |
Output is correct |
78 |
Correct |
11 ms |
2428 KB |
Output is correct |
79 |
Correct |
29 ms |
3704 KB |
Output is correct |
80 |
Correct |
23 ms |
3704 KB |
Output is correct |
81 |
Correct |
58 ms |
5880 KB |
Output is correct |
82 |
Correct |
6 ms |
1912 KB |
Output is correct |
83 |
Correct |
29 ms |
3704 KB |
Output is correct |
84 |
Correct |
42 ms |
5160 KB |
Output is correct |
85 |
Correct |
6 ms |
1912 KB |
Output is correct |
86 |
Correct |
42 ms |
5240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1528 KB |
Output is correct |
2 |
Correct |
3 ms |
1528 KB |
Output is correct |
3 |
Correct |
9 ms |
2424 KB |
Output is correct |
4 |
Correct |
9 ms |
2424 KB |
Output is correct |
5 |
Correct |
9 ms |
2424 KB |
Output is correct |
6 |
Correct |
9 ms |
2424 KB |
Output is correct |
7 |
Correct |
9 ms |
2552 KB |
Output is correct |
8 |
Correct |
4 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
4 ms |
1656 KB |
Output is correct |
11 |
Correct |
9 ms |
2424 KB |
Output is correct |
12 |
Correct |
10 ms |
2424 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
9 ms |
2424 KB |
Output is correct |
15 |
Correct |
3 ms |
1528 KB |
Output is correct |
16 |
Correct |
9 ms |
2424 KB |
Output is correct |
17 |
Correct |
3 ms |
1528 KB |
Output is correct |
18 |
Correct |
9 ms |
2424 KB |
Output is correct |
19 |
Correct |
4 ms |
1528 KB |
Output is correct |
20 |
Correct |
7 ms |
2168 KB |
Output is correct |
21 |
Correct |
7 ms |
2040 KB |
Output is correct |
22 |
Correct |
5 ms |
1628 KB |
Output is correct |
23 |
Correct |
11 ms |
2552 KB |
Output is correct |
24 |
Correct |
5 ms |
1656 KB |
Output is correct |
25 |
Correct |
11 ms |
2552 KB |
Output is correct |
26 |
Correct |
11 ms |
2552 KB |
Output is correct |
27 |
Correct |
10 ms |
2424 KB |
Output is correct |
28 |
Correct |
11 ms |
2552 KB |
Output is correct |
29 |
Correct |
10 ms |
2424 KB |
Output is correct |
30 |
Correct |
12 ms |
2680 KB |
Output is correct |
31 |
Correct |
12 ms |
2680 KB |
Output is correct |
32 |
Correct |
12 ms |
2680 KB |
Output is correct |
33 |
Correct |
12 ms |
2684 KB |
Output is correct |
34 |
Correct |
12 ms |
2680 KB |
Output is correct |
35 |
Correct |
7 ms |
2040 KB |
Output is correct |
36 |
Correct |
7 ms |
2040 KB |
Output is correct |
37 |
Correct |
7 ms |
2040 KB |
Output is correct |
38 |
Correct |
6 ms |
1912 KB |
Output is correct |
39 |
Correct |
6 ms |
1912 KB |
Output is correct |
40 |
Correct |
16 ms |
3064 KB |
Output is correct |
41 |
Correct |
6 ms |
1912 KB |
Output is correct |
42 |
Correct |
17 ms |
3064 KB |
Output is correct |
43 |
Correct |
17 ms |
3192 KB |
Output is correct |
44 |
Correct |
3 ms |
1528 KB |
Output is correct |
45 |
Correct |
322 ms |
23672 KB |
Output is correct |
46 |
Correct |
134 ms |
13944 KB |
Output is correct |
47 |
Correct |
326 ms |
23800 KB |
Output is correct |
48 |
Correct |
315 ms |
23800 KB |
Output is correct |
49 |
Correct |
90 ms |
10484 KB |
Output is correct |
50 |
Correct |
339 ms |
30552 KB |
Output is correct |
51 |
Correct |
331 ms |
23836 KB |
Output is correct |
52 |
Correct |
68 ms |
10744 KB |
Output is correct |
53 |
Correct |
87 ms |
10612 KB |
Output is correct |
54 |
Correct |
18 ms |
2168 KB |
Output is correct |
55 |
Correct |
347 ms |
30576 KB |
Output is correct |
56 |
Correct |
49 ms |
7416 KB |
Output is correct |
57 |
Correct |
69 ms |
10744 KB |
Output is correct |
58 |
Correct |
143 ms |
14164 KB |
Output is correct |
59 |
Correct |
50 ms |
7416 KB |
Output is correct |
60 |
Correct |
51 ms |
7416 KB |
Output is correct |
61 |
Correct |
143 ms |
14072 KB |
Output is correct |
62 |
Correct |
98 ms |
10740 KB |
Output is correct |
63 |
Correct |
179 ms |
15444 KB |
Output is correct |
64 |
Correct |
59 ms |
7416 KB |
Output is correct |
65 |
Correct |
233 ms |
18908 KB |
Output is correct |
66 |
Correct |
94 ms |
10816 KB |
Output is correct |
67 |
Correct |
176 ms |
15580 KB |
Output is correct |
68 |
Correct |
220 ms |
18168 KB |
Output is correct |
69 |
Correct |
262 ms |
18900 KB |
Output is correct |
70 |
Correct |
96 ms |
10744 KB |
Output is correct |
71 |
Correct |
222 ms |
18168 KB |
Output is correct |
72 |
Correct |
155 ms |
15028 KB |
Output is correct |
73 |
Correct |
274 ms |
21120 KB |
Output is correct |
74 |
Correct |
112 ms |
10744 KB |
Output is correct |
75 |
Correct |
92 ms |
9336 KB |
Output is correct |
76 |
Correct |
155 ms |
14968 KB |
Output is correct |
77 |
Correct |
277 ms |
21100 KB |
Output is correct |
78 |
Correct |
132 ms |
11560 KB |
Output is correct |
79 |
Correct |
91 ms |
9304 KB |
Output is correct |
80 |
Correct |
42 ms |
5624 KB |
Output is correct |
81 |
Correct |
139 ms |
11512 KB |
Output is correct |
82 |
Correct |
226 ms |
17400 KB |
Output is correct |
83 |
Correct |
39 ms |
5624 KB |
Output is correct |
84 |
Correct |
187 ms |
17428 KB |
Output is correct |