#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using arr = array<int, 2>;
constexpr int maxn = 10, maxk = 11;
bool visited[maxn] = { 0 };
set<int> adj[maxn];
int k;
int output = 1;
void dfs(int pos)
{
// assert(!visited[pos]);
assert((int)adj[pos].size() <= k);
visited[pos] = true;
vector <bitset<maxk>> v(adj[pos].size());
int ii = 0; // Counts which place it is in the order of adj[pos]
int iii;
for (int i : adj[pos])
{
iii = 0;
v[ii][ii] = true;
for (int y : adj[pos])
{
if (i != y) {
v[ii][iii] = adj[i].count(y);
}
iii++;
}
ii++;
}
bitset<maxk> all;
for (int i = 1; i < (1 << (adj[pos].size())); i++){
all.set();
for (size_t y = 0; y < adj[pos].size(); y++) {
if (i & (1 << y)) all &= v[y];
}
// cout << i << " " << all << "\n";
if (__builtin_popcount(i) == all.count()) output = max(output, __builtin_popcount(i) + 1);
}
for (int i : adj[pos]) adj[i].erase(pos); // Something with the deletion is fishy, since
for (int i : adj[pos]) if (!visited[i] && (int)adj[i].size() <= k) dfs(i); // We need this !visited[i]
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n >> k;
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a;
for (int y = 0; y < a; y++)
{
cin >> b;
adj[i].insert(b);
}
}
for (int i = 0; i < n; i++) if (!visited[i] && (int)adj[i].size() <= k) dfs(i);
cout << output << "\n";
// cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |