#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
const int N = 50005;
vector<int> vec[N];
bitset<N> dsag[N];
void sub1(int n){
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
if (dsag[i][j] == 1){
cout<<2<<endl;
exit(0);
}
cout<<1<<endl;
exit(0);
}
void sub2(int n){
for (int i=1;i<=n;i++){
for (int j=i+1;j<=n;j++){
if ((dsag[i][j] == 1) and (dsag[i] & dsag[j]) != dsag[0]){
cout<<3<<endl;
exit(0);
}
}
}
sub1(n);
}
void sub3(int n){
int mx = 1;
for (int i=1;i<=n;i++)
dsag[i][i] = 1;
for (int i=1;i<=n;i++){
int k = vec[i].size();
for (int mask = 1;mask < (1<<k);mask++){
int cnt = 0;
dsag[0][i] = 1;
for (int j = 0;j < k;j++)
if ((1<<j) & mask)
dsag[0][vec[i][j]] = 1,cnt++;
bool t = true;
for (int j = 0;j < k;j++)
if ((1<<j) & mask and (dsag[vec[i][j]] & dsag[0]) != dsag[0]){
t = false;
break;
}
if (t)
mx = max(mx,cnt + 1);
dsag[0] >>= N;
}
}
cout<<mx<<endl;
exit(0);
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
for (int i=1;i<=n;i++){
int k;
cin>>k;
while (k--){
int a;
cin>>a;
dsag[i][a + 1] = 1;
vec[i].push_back(a+1);
}
}
if (k == 1){
cout<<1<<endl;
return 0;
}
// if (k == 2)
// sub1(n);
// if (k == 3)
// sub2(n);
sub3(n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
51 ms |
32604 KB |
Output is correct |
4 |
Correct |
10 ms |
32600 KB |
Output is correct |
5 |
Correct |
11 ms |
32724 KB |
Output is correct |
6 |
Correct |
19 ms |
32604 KB |
Output is correct |
7 |
Correct |
23 ms |
32600 KB |
Output is correct |
8 |
Correct |
4 ms |
32348 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
51 ms |
32604 KB |
Output is correct |
4 |
Correct |
10 ms |
32600 KB |
Output is correct |
5 |
Correct |
11 ms |
32724 KB |
Output is correct |
6 |
Correct |
19 ms |
32604 KB |
Output is correct |
7 |
Correct |
23 ms |
32600 KB |
Output is correct |
8 |
Correct |
4 ms |
32348 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32348 KB |
Output is correct |
11 |
Correct |
11 ms |
32856 KB |
Output is correct |
12 |
Correct |
11 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1624 KB |
Output is correct |
14 |
Correct |
11 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
25 ms |
32628 KB |
Output is correct |
17 |
Correct |
1 ms |
1624 KB |
Output is correct |
18 |
Correct |
19 ms |
32604 KB |
Output is correct |
19 |
Correct |
5 ms |
32408 KB |
Output is correct |
20 |
Correct |
12 ms |
32600 KB |
Output is correct |
21 |
Correct |
11 ms |
32604 KB |
Output is correct |
22 |
Correct |
5 ms |
32348 KB |
Output is correct |
23 |
Correct |
39 ms |
32692 KB |
Output is correct |
24 |
Correct |
4 ms |
32344 KB |
Output is correct |
25 |
Correct |
40 ms |
32604 KB |
Output is correct |
26 |
Correct |
41 ms |
32604 KB |
Output is correct |
27 |
Correct |
21 ms |
32604 KB |
Output is correct |
28 |
Correct |
33 ms |
32616 KB |
Output is correct |
29 |
Correct |
21 ms |
32604 KB |
Output is correct |
30 |
Correct |
23 ms |
32604 KB |
Output is correct |
31 |
Correct |
38 ms |
32604 KB |
Output is correct |
32 |
Correct |
24 ms |
32716 KB |
Output is correct |
33 |
Correct |
37 ms |
32604 KB |
Output is correct |
34 |
Correct |
35 ms |
32716 KB |
Output is correct |
35 |
Correct |
18 ms |
18012 KB |
Output is correct |
36 |
Correct |
19 ms |
18264 KB |
Output is correct |
37 |
Correct |
18 ms |
18008 KB |
Output is correct |
38 |
Execution timed out |
3026 ms |
9816 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
32344 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1624 KB |
Output is correct |
4 |
Correct |
1 ms |
1628 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
2 ms |
1624 KB |
Output is correct |
9 |
Correct |
2 ms |
1628 KB |
Output is correct |
10 |
Correct |
2 ms |
1628 KB |
Output is correct |
11 |
Execution timed out |
3031 ms |
311376 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
51 ms |
32604 KB |
Output is correct |
4 |
Correct |
10 ms |
32600 KB |
Output is correct |
5 |
Correct |
11 ms |
32724 KB |
Output is correct |
6 |
Correct |
19 ms |
32604 KB |
Output is correct |
7 |
Correct |
23 ms |
32600 KB |
Output is correct |
8 |
Correct |
4 ms |
32348 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32348 KB |
Output is correct |
11 |
Correct |
11 ms |
32856 KB |
Output is correct |
12 |
Correct |
11 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1624 KB |
Output is correct |
14 |
Correct |
11 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
25 ms |
32628 KB |
Output is correct |
17 |
Correct |
1 ms |
1624 KB |
Output is correct |
18 |
Correct |
19 ms |
32604 KB |
Output is correct |
19 |
Correct |
5 ms |
32408 KB |
Output is correct |
20 |
Correct |
12 ms |
32600 KB |
Output is correct |
21 |
Correct |
11 ms |
32604 KB |
Output is correct |
22 |
Correct |
5 ms |
32348 KB |
Output is correct |
23 |
Correct |
39 ms |
32692 KB |
Output is correct |
24 |
Correct |
4 ms |
32344 KB |
Output is correct |
25 |
Correct |
40 ms |
32604 KB |
Output is correct |
26 |
Correct |
41 ms |
32604 KB |
Output is correct |
27 |
Correct |
21 ms |
32604 KB |
Output is correct |
28 |
Correct |
33 ms |
32616 KB |
Output is correct |
29 |
Correct |
21 ms |
32604 KB |
Output is correct |
30 |
Correct |
23 ms |
32604 KB |
Output is correct |
31 |
Correct |
38 ms |
32604 KB |
Output is correct |
32 |
Correct |
24 ms |
32716 KB |
Output is correct |
33 |
Correct |
37 ms |
32604 KB |
Output is correct |
34 |
Correct |
35 ms |
32716 KB |
Output is correct |
35 |
Correct |
18 ms |
18012 KB |
Output is correct |
36 |
Correct |
19 ms |
18264 KB |
Output is correct |
37 |
Correct |
18 ms |
18008 KB |
Output is correct |
38 |
Execution timed out |
3026 ms |
9816 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
51 ms |
32604 KB |
Output is correct |
4 |
Correct |
10 ms |
32600 KB |
Output is correct |
5 |
Correct |
11 ms |
32724 KB |
Output is correct |
6 |
Correct |
19 ms |
32604 KB |
Output is correct |
7 |
Correct |
23 ms |
32600 KB |
Output is correct |
8 |
Correct |
4 ms |
32348 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
4 ms |
32348 KB |
Output is correct |
11 |
Correct |
11 ms |
32856 KB |
Output is correct |
12 |
Correct |
11 ms |
32600 KB |
Output is correct |
13 |
Correct |
1 ms |
1624 KB |
Output is correct |
14 |
Correct |
11 ms |
32604 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
25 ms |
32628 KB |
Output is correct |
17 |
Correct |
1 ms |
1624 KB |
Output is correct |
18 |
Correct |
19 ms |
32604 KB |
Output is correct |
19 |
Correct |
5 ms |
32408 KB |
Output is correct |
20 |
Correct |
12 ms |
32600 KB |
Output is correct |
21 |
Correct |
11 ms |
32604 KB |
Output is correct |
22 |
Correct |
5 ms |
32348 KB |
Output is correct |
23 |
Correct |
39 ms |
32692 KB |
Output is correct |
24 |
Correct |
4 ms |
32344 KB |
Output is correct |
25 |
Correct |
40 ms |
32604 KB |
Output is correct |
26 |
Correct |
41 ms |
32604 KB |
Output is correct |
27 |
Correct |
21 ms |
32604 KB |
Output is correct |
28 |
Correct |
33 ms |
32616 KB |
Output is correct |
29 |
Correct |
21 ms |
32604 KB |
Output is correct |
30 |
Correct |
23 ms |
32604 KB |
Output is correct |
31 |
Correct |
38 ms |
32604 KB |
Output is correct |
32 |
Correct |
24 ms |
32716 KB |
Output is correct |
33 |
Correct |
37 ms |
32604 KB |
Output is correct |
34 |
Correct |
35 ms |
32716 KB |
Output is correct |
35 |
Correct |
18 ms |
18012 KB |
Output is correct |
36 |
Correct |
19 ms |
18264 KB |
Output is correct |
37 |
Correct |
18 ms |
18008 KB |
Output is correct |
38 |
Execution timed out |
3026 ms |
9816 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |