This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define int long long
#define pb push_back
#define nl '\n'
#define fore(i, y) for(int i = 0; i < y; i++)
#define forr(i, x, y) for(int i = x;i<=y;i++)
#define forn(i, y, x) for(int i = y; i >= x; i--)
const int N = 50000;
vector<bitset<N>> adj(N , 0);
bool done[N];
int n , k;
bitset<N> cur = 0;
bitset<N> vis = 0;
int maxClique(int i)
{
vis = 0;
vis[i] = 1;
cur = adj[i];
int last = i;
int cnt = 0;
while(cnt < k)
{
cnt++;
cur&=adj[last];
if(cur == 0)
break;
int before = last;
for(int j = cur._Find_first() ; j < N ; j = cur._Find_next(i))
{
if(done[j] || vis[j])
continue;
last = j;
break;
}
if(before == last)
break;
vis[last] = 1;
}
return cnt;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
fore(i , n)
{
int d;
cin>>d;
fore(j , d)
{
int x;
cin>>x;
adj[i][x] = 1;
}
}
int best = 0;
fore(i , n)
{
best = max(best , maxClique(i));
done[i] = 1;
}
cout<<best<<nl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |