#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[50001][50001];
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 k = j+2 ; k < edges[i].size(); k++)
{
int flg1=0,p3 = edges[i][k] , 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 = j+3 ; kk<edges[i].size() ; kk++)
{
int flg2=0,p5 = edges[i][kk] , p6 = edges[i][k];
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 k = j+2 ; k < edges[i].size(); k++)
| ~~^~~~~~~~~~~~~~~~~
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 = j+3 ; 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][k];
| ^~~~
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status