#include <bits/stdc++.h>
#define ZAZO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
using namespace std;
vector<int>edges[50001];
int vis[50001]={0};
int ed[5005][5005];
int mx=1,n,k;
int32_t main() {
ZAZO
cin >> n >> k ;
memset(ed,0,sizeof ed);
for(int i = 0 ; i < n ; i ++)
{
int d;
cin>>d;
for(int j = 0 ; j < d ; j ++)
{
mx=2;
int x; cin>>x;
edges[i].push_back(x);
edges[x].push_back(i);
ed[i][x]=1;
ed[x][i]=1;
}
}
for(int i = 0 ; i < n ; i ++)
{
for(int j = 0 ; j < edges[i].size() ; j ++)
{
for(int p = j+1 ; p < edges[i].size(); p++)
{
int flg=0;
int p1 = edges[i][j] , p2 = edges[i][p];
if(ed[p1][p2])
{
mx=max(mx,3ll);
flg=1;
}
if(!flg||mx>=k) continue;
for(int o = p+1 ; o < edges[i].size(); o++)
{
int flg1=0,p3 = edges[i][o] , p4 = edges[i][p];
if(ed[p3][p4]&&ed[p3][p1])
{
mx=max(mx,4ll);
flg1=1;
}
if(!flg1||mx>=k) continue;
for(int kk = o+1 ; kk<edges[i].size() ; kk++)
{
int flg2=0,p5 = edges[i][kk] , p6 = edges[i][o];
if(ed[p5][p6]&&ed[p5][p4]&&ed[p5][p1])
{
mx=max(mx,5ll);
cout<<"5"<<endl;
return 0;
}
}
}
}
}
}
cout<<mx<<endl;
}
Compilation message
politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int j = 0 ; j < edges[i].size() ; j ++)
| ~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:31:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int p = j+1 ; p < edges[i].size(); p++)
| ~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:41:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int o = p+1 ; o < edges[i].size(); o++)
| ~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:50:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int kk = o+1 ; kk<edges[i].size() ; kk++)
| ~~^~~~~~~~~~~~~~~~
politicaldevelopment.cpp:52:17: warning: unused variable 'flg2' [-Wunused-variable]
52 | int flg2=0,p5 = edges[i][kk] , p6 = edges[i][o];
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
197572 KB |
Output is correct |
2 |
Correct |
83 ms |
197512 KB |
Output is correct |
3 |
Correct |
89 ms |
197764 KB |
Output is correct |
4 |
Correct |
220 ms |
197828 KB |
Output is correct |
5 |
Correct |
217 ms |
197772 KB |
Output is correct |
6 |
Correct |
96 ms |
197828 KB |
Output is correct |
7 |
Correct |
93 ms |
197888 KB |
Output is correct |
8 |
Correct |
82 ms |
197516 KB |
Output is correct |
9 |
Correct |
83 ms |
197596 KB |
Output is correct |
10 |
Correct |
82 ms |
197568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
197572 KB |
Output is correct |
2 |
Correct |
83 ms |
197512 KB |
Output is correct |
3 |
Correct |
89 ms |
197764 KB |
Output is correct |
4 |
Correct |
220 ms |
197828 KB |
Output is correct |
5 |
Correct |
217 ms |
197772 KB |
Output is correct |
6 |
Correct |
96 ms |
197828 KB |
Output is correct |
7 |
Correct |
93 ms |
197888 KB |
Output is correct |
8 |
Correct |
82 ms |
197516 KB |
Output is correct |
9 |
Correct |
83 ms |
197596 KB |
Output is correct |
10 |
Correct |
82 ms |
197568 KB |
Output is correct |
11 |
Correct |
214 ms |
197760 KB |
Output is correct |
12 |
Correct |
215 ms |
197876 KB |
Output is correct |
13 |
Correct |
83 ms |
197444 KB |
Output is correct |
14 |
Correct |
228 ms |
197792 KB |
Output is correct |
15 |
Correct |
82 ms |
197448 KB |
Output is correct |
16 |
Correct |
93 ms |
197800 KB |
Output is correct |
17 |
Correct |
83 ms |
197444 KB |
Output is correct |
18 |
Correct |
94 ms |
198080 KB |
Output is correct |
19 |
Correct |
82 ms |
197548 KB |
Output is correct |
20 |
Correct |
84 ms |
197712 KB |
Output is correct |
21 |
Correct |
84 ms |
197672 KB |
Output is correct |
22 |
Correct |
83 ms |
197520 KB |
Output is correct |
23 |
Correct |
92 ms |
197956 KB |
Output is correct |
24 |
Correct |
83 ms |
197444 KB |
Output is correct |
25 |
Correct |
89 ms |
197856 KB |
Output is correct |
26 |
Correct |
89 ms |
197848 KB |
Output is correct |
27 |
Correct |
87 ms |
197828 KB |
Output is correct |
28 |
Correct |
88 ms |
197828 KB |
Output is correct |
29 |
Correct |
88 ms |
197960 KB |
Output is correct |
30 |
Correct |
147 ms |
197916 KB |
Output is correct |
31 |
Correct |
90 ms |
197912 KB |
Output is correct |
32 |
Correct |
143 ms |
197840 KB |
Output is correct |
33 |
Correct |
90 ms |
197860 KB |
Output is correct |
34 |
Correct |
90 ms |
197872 KB |
Output is correct |
35 |
Correct |
87 ms |
197696 KB |
Output is correct |
36 |
Correct |
87 ms |
197700 KB |
Output is correct |
37 |
Correct |
86 ms |
197704 KB |
Output is correct |
38 |
Correct |
87 ms |
197644 KB |
Output is correct |
39 |
Correct |
86 ms |
197700 KB |
Output is correct |
40 |
Correct |
93 ms |
198024 KB |
Output is correct |
41 |
Correct |
93 ms |
197700 KB |
Output is correct |
42 |
Correct |
94 ms |
198080 KB |
Output is correct |
43 |
Correct |
93 ms |
198044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
197524 KB |
Output is correct |
2 |
Correct |
87 ms |
197444 KB |
Output is correct |
3 |
Correct |
84 ms |
197480 KB |
Output is correct |
4 |
Correct |
84 ms |
197536 KB |
Output is correct |
5 |
Correct |
84 ms |
197452 KB |
Output is correct |
6 |
Correct |
83 ms |
197500 KB |
Output is correct |
7 |
Correct |
83 ms |
197524 KB |
Output is correct |
8 |
Correct |
84 ms |
197440 KB |
Output is correct |
9 |
Correct |
84 ms |
197572 KB |
Output is correct |
10 |
Correct |
86 ms |
197568 KB |
Output is correct |
11 |
Runtime error |
282 ms |
400316 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
197572 KB |
Output is correct |
2 |
Correct |
83 ms |
197512 KB |
Output is correct |
3 |
Correct |
89 ms |
197764 KB |
Output is correct |
4 |
Correct |
220 ms |
197828 KB |
Output is correct |
5 |
Correct |
217 ms |
197772 KB |
Output is correct |
6 |
Correct |
96 ms |
197828 KB |
Output is correct |
7 |
Correct |
93 ms |
197888 KB |
Output is correct |
8 |
Correct |
82 ms |
197516 KB |
Output is correct |
9 |
Correct |
83 ms |
197596 KB |
Output is correct |
10 |
Correct |
82 ms |
197568 KB |
Output is correct |
11 |
Correct |
214 ms |
197760 KB |
Output is correct |
12 |
Correct |
215 ms |
197876 KB |
Output is correct |
13 |
Correct |
83 ms |
197444 KB |
Output is correct |
14 |
Correct |
228 ms |
197792 KB |
Output is correct |
15 |
Correct |
82 ms |
197448 KB |
Output is correct |
16 |
Correct |
93 ms |
197800 KB |
Output is correct |
17 |
Correct |
83 ms |
197444 KB |
Output is correct |
18 |
Correct |
94 ms |
198080 KB |
Output is correct |
19 |
Correct |
82 ms |
197548 KB |
Output is correct |
20 |
Correct |
84 ms |
197712 KB |
Output is correct |
21 |
Correct |
84 ms |
197672 KB |
Output is correct |
22 |
Correct |
83 ms |
197520 KB |
Output is correct |
23 |
Correct |
92 ms |
197956 KB |
Output is correct |
24 |
Correct |
83 ms |
197444 KB |
Output is correct |
25 |
Correct |
89 ms |
197856 KB |
Output is correct |
26 |
Correct |
89 ms |
197848 KB |
Output is correct |
27 |
Correct |
87 ms |
197828 KB |
Output is correct |
28 |
Correct |
88 ms |
197828 KB |
Output is correct |
29 |
Correct |
88 ms |
197960 KB |
Output is correct |
30 |
Correct |
147 ms |
197916 KB |
Output is correct |
31 |
Correct |
90 ms |
197912 KB |
Output is correct |
32 |
Correct |
143 ms |
197840 KB |
Output is correct |
33 |
Correct |
90 ms |
197860 KB |
Output is correct |
34 |
Correct |
90 ms |
197872 KB |
Output is correct |
35 |
Correct |
87 ms |
197696 KB |
Output is correct |
36 |
Correct |
87 ms |
197700 KB |
Output is correct |
37 |
Correct |
86 ms |
197704 KB |
Output is correct |
38 |
Correct |
87 ms |
197644 KB |
Output is correct |
39 |
Correct |
86 ms |
197700 KB |
Output is correct |
40 |
Correct |
93 ms |
198024 KB |
Output is correct |
41 |
Correct |
93 ms |
197700 KB |
Output is correct |
42 |
Correct |
94 ms |
198080 KB |
Output is correct |
43 |
Correct |
93 ms |
198044 KB |
Output is correct |
44 |
Incorrect |
93 ms |
198316 KB |
Output isn't correct |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
197572 KB |
Output is correct |
2 |
Correct |
83 ms |
197512 KB |
Output is correct |
3 |
Correct |
89 ms |
197764 KB |
Output is correct |
4 |
Correct |
220 ms |
197828 KB |
Output is correct |
5 |
Correct |
217 ms |
197772 KB |
Output is correct |
6 |
Correct |
96 ms |
197828 KB |
Output is correct |
7 |
Correct |
93 ms |
197888 KB |
Output is correct |
8 |
Correct |
82 ms |
197516 KB |
Output is correct |
9 |
Correct |
83 ms |
197596 KB |
Output is correct |
10 |
Correct |
82 ms |
197568 KB |
Output is correct |
11 |
Correct |
214 ms |
197760 KB |
Output is correct |
12 |
Correct |
215 ms |
197876 KB |
Output is correct |
13 |
Correct |
83 ms |
197444 KB |
Output is correct |
14 |
Correct |
228 ms |
197792 KB |
Output is correct |
15 |
Correct |
82 ms |
197448 KB |
Output is correct |
16 |
Correct |
93 ms |
197800 KB |
Output is correct |
17 |
Correct |
83 ms |
197444 KB |
Output is correct |
18 |
Correct |
94 ms |
198080 KB |
Output is correct |
19 |
Correct |
82 ms |
197548 KB |
Output is correct |
20 |
Correct |
84 ms |
197712 KB |
Output is correct |
21 |
Correct |
84 ms |
197672 KB |
Output is correct |
22 |
Correct |
83 ms |
197520 KB |
Output is correct |
23 |
Correct |
92 ms |
197956 KB |
Output is correct |
24 |
Correct |
83 ms |
197444 KB |
Output is correct |
25 |
Correct |
89 ms |
197856 KB |
Output is correct |
26 |
Correct |
89 ms |
197848 KB |
Output is correct |
27 |
Correct |
87 ms |
197828 KB |
Output is correct |
28 |
Correct |
88 ms |
197828 KB |
Output is correct |
29 |
Correct |
88 ms |
197960 KB |
Output is correct |
30 |
Correct |
147 ms |
197916 KB |
Output is correct |
31 |
Correct |
90 ms |
197912 KB |
Output is correct |
32 |
Correct |
143 ms |
197840 KB |
Output is correct |
33 |
Correct |
90 ms |
197860 KB |
Output is correct |
34 |
Correct |
90 ms |
197872 KB |
Output is correct |
35 |
Correct |
87 ms |
197696 KB |
Output is correct |
36 |
Correct |
87 ms |
197700 KB |
Output is correct |
37 |
Correct |
86 ms |
197704 KB |
Output is correct |
38 |
Correct |
87 ms |
197644 KB |
Output is correct |
39 |
Correct |
86 ms |
197700 KB |
Output is correct |
40 |
Correct |
93 ms |
198024 KB |
Output is correct |
41 |
Correct |
93 ms |
197700 KB |
Output is correct |
42 |
Correct |
94 ms |
198080 KB |
Output is correct |
43 |
Correct |
93 ms |
198044 KB |
Output is correct |
44 |
Correct |
83 ms |
197484 KB |
Output is correct |
45 |
Runtime error |
280 ms |
400344 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |