//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ve vector
typedef long long ll;
int n, k, r;
ve<set<int>> G;
ve<int> S;
void f(int i, int s) {
bool valid;
if (i < k) {
for (int j = s; j < n; j++) {
valid = true;
for (int l : S) {
if (G[l].find(j) == G[l].end() || G[j].find(l) == G[j].end()) {
valid = false;
break;
}
}
if (valid) {
S.push_back(i);
r = max(r, i + 1);
f(i + 1, j + 1);
S.pop_back();
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int d, a;
cin >> n >> k;
G = ve<set<int>>(n);
for (int i = 0; i < n; i++) {
cin >> d;
for (int j = 0; j < d; j++) {
cin >> a;
G[i].insert(a);
}
}
r = 0;
f(0, 0);
cout << r << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
41 ms |
1152 KB |
Output is correct |
4 |
Correct |
39 ms |
1024 KB |
Output is correct |
5 |
Correct |
39 ms |
1152 KB |
Output is correct |
6 |
Correct |
37 ms |
1152 KB |
Output is correct |
7 |
Correct |
38 ms |
1152 KB |
Output is correct |
8 |
Correct |
27 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
432 KB |
Output is correct |
10 |
Incorrect |
26 ms |
640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
41 ms |
1152 KB |
Output is correct |
4 |
Correct |
39 ms |
1024 KB |
Output is correct |
5 |
Correct |
39 ms |
1152 KB |
Output is correct |
6 |
Correct |
37 ms |
1152 KB |
Output is correct |
7 |
Correct |
38 ms |
1152 KB |
Output is correct |
8 |
Correct |
27 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
432 KB |
Output is correct |
10 |
Incorrect |
26 ms |
640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
768 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
41 ms |
1152 KB |
Output is correct |
4 |
Correct |
39 ms |
1024 KB |
Output is correct |
5 |
Correct |
39 ms |
1152 KB |
Output is correct |
6 |
Correct |
37 ms |
1152 KB |
Output is correct |
7 |
Correct |
38 ms |
1152 KB |
Output is correct |
8 |
Correct |
27 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
432 KB |
Output is correct |
10 |
Incorrect |
26 ms |
640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
41 ms |
1152 KB |
Output is correct |
4 |
Correct |
39 ms |
1024 KB |
Output is correct |
5 |
Correct |
39 ms |
1152 KB |
Output is correct |
6 |
Correct |
37 ms |
1152 KB |
Output is correct |
7 |
Correct |
38 ms |
1152 KB |
Output is correct |
8 |
Correct |
27 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
432 KB |
Output is correct |
10 |
Incorrect |
26 ms |
640 KB |
Output isn't correct |