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>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44
/*const int MOD = (int) 1e9 + 7;
inline int lgput(int a, int b) {
int ans = 1;
while(b > 0) {
if(b & 1) ans = (1LL * ans * a) % MOD;
b >>= 1;
a = (1LL * a * a) % MOD;
}
return ans;
}
inline void mod(int &x) {
if(x >= MOD)
x -= MOD;
}
inline void add(int &x, int y) {
x += y;
mod(x);
}
inline void sub(int &x, int y) {
x += MOD - y;
mod(x);
}
inline void mul(int &x, int y) {
x = (1LL * x * y) % MOD;
}*/
/*int fact[], invfact[];
inline void prec(int n) {
fact[0] = 1;
for(int i = 1; i <= n; i++) {
fact[i] = (1LL * fact[i - 1] * i) % MOD;
}
invfact[n] = lgput(fact[n], MOD - 2);
for(int i = n - 1; i >= 0; i--) {
invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
}
}
inline int comb(int n, int k) {
if(n < k) return 0;
return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}*/
using namespace std;
const int MAXN = 50000;
set <int> g[MAXN + 1];
bool vis[MAXN + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int i, n, k;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
for(i = 1; i <= n; i++) {
int sz;
cin >> sz;
while(sz--) {
int nod;
cin >> nod;
g[i].insert(nod + 1);
}
}
set < pair <int, int> > Q;
for(i = 1; i <= n; i++) {
Q.insert({g[i].size(), i});
}
int ans = 1;
while(Q.size()) {
int nod = Q.begin() -> second;
Q.erase(Q.begin());
vector <int> nodes;
for(auto it : g[nod]) {
nodes.push_back(it);
}
int sz = nodes.size();
for(int conf = 0; conf < (1 << sz); conf++) {
int num = __builtin_popcount(conf);
if(num >= k || num < ans) {
continue;
}
vector <int> cur;
for(i = 0; i < sz; i++) {
if(conf & (1 << i)) {
vis[nodes[i]] = 1;
cur.push_back(nodes[i]);
}
}
bool ok = 1;
for(auto it : cur) {
for(auto itr : cur) {
if(it != itr && g[it].find(itr) == g[it].end()) {
ok = 0;
break;
}
}
if(!ok) {
break;
}
}
if(ok) {
ans = max(ans, num + 1);
}
for(auto it : cur) {
vis[it] = 0;
}
}
for(auto it : g[nod]) {
Q.erase({g[it].size(), it});
g[it].erase(nod);
Q.insert({g[it].size(), it});
}
}
cout << ans;
return 0;
}
# | 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... |