| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1306210 | Robert_junior | Political Development (BOI17_politicaldevelopment) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define F first
#define S second
#define bt bitset<50010>
const int N = 50010, K = 1610;
const int mod = 998244353;
vector<int>g[N], gg[N];
bt b[N];
int ans = 1;
void solve(){
int n, k;
cin>>n>>k;
for(int i = 1; i <= n; i++){
int m;
cin>>m;
for(int j = 1; j <= m; j++){
int x;
cin>>x;
x++;
gg[i].pb(x);
}
}
for(int i = 1; i <= n; i++){
for(auto to : gg[i]){
for(auto it : gg[to]){
if(it == i){
g[i].pb(to);
b[i][to] = 1;
}
}
}
}
for(int i = 1; i <= n; i++){
int m = g[i].size();
if(m > k) continue;
for(int msk = 0; msk < (1<<m); msk++){
vector<int>v;
for(int j = 0; j < m; j++){
if((msk>>j) & 1){
v.pb(g[i][j]);
}
}
bool ok = 1;
for(auto it : v){
for(auto it1 : v){
if(it == it1) continue;
if(b[it][it1] != 0)
}
}
if(ok) ans = max(ans, (int)(__builtin_popcount(msk)) + 1);
}
}
cout<<ans;
}
main(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin>>t;
while(t--){
solve();
}
}
