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>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(v) begin(v), end(v)
int main() {
int n, k; cin >> n >> k;
vector<unordered_set<int>> g(n);
rep (i, n) {
int d; cin >> d;
rep (j, d) {
int a; cin >> a;
g[i].insert(a);
}
}
vector<int> deg(n);
vector<bool> used(n, false);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
rep (i, n) {
deg[i] = g[i].size();
que.emplace(deg[i], i);
}
int ans = 0;
while (!que.empty()) {
auto [d, v] = que.top(); que.pop();
if (deg[v] != d) continue;
vector<int> a;
for (auto i : g[v]) {
if (used[i]) continue;
a.push_back(i);
}
int m = a.size();
rep (bt, 1 << m) {
vector<int> b;
rep (i, m) if (bt >> i & 1) b.push_back(a[i]);
rep (i, b.size()) rep (j, i) {
if (g[b[i]].count(b[j]) == 0) goto END;
}
ans = max(ans, __builtin_popcount(bt) + 1);
END:;
}
used[v] = true;
for (auto i : g[v]) {
if (used[i]) continue;
--deg[i];
que.emplace(deg[i], i);
}
}
cout << ans << endl;
}
# | 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... |