#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 5e4+10;
vector<int> paths[mxn];
int N,K;
inline bool check(vector<int> &tar){
sort(tar.begin(),tar.end());
for(auto &i:tar){
int pre = 0;
for(auto &j:tar){
if(j == i)continue;
auto it = lower_bound(paths[i].begin()+pre,paths[i].end(),j)-paths[i].begin();
if(it == paths[i].size()||paths[i][it] != j)return false;
pre = it;
}
}
return true;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>K;
for(int i = 0;i<N;i++){
int c;
cin>>c;
while(c--){
int tmp;
cin>>tmp;
paths[i].push_back(tmp);
}
sort(paths[i].begin(),paths[i].end());
}
int ans = 0;
for(int i = 0;i<N;i++){
for(int j =0;j<(1<<paths[i].size());j++){
vector<int> tar;
tar.push_back(i);
for(int l = 0;l<paths[i].size();l++){
if(j&(1<<l))tar.push_back(paths[i][l]);
}
if(check(tar))ans = max(ans,__builtin_popcount(j)+1);
}
}
cout<<ans;
}
Compilation message
politicaldevelopment.cpp: In function 'bool check(std::vector<int>&)':
politicaldevelopment.cpp:23:10: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | if(it == paths[i].size()||paths[i][it] != j)return false;
| ~~~^~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(int l = 0;l<paths[i].size();l++){
| ~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
11 ms |
1800 KB |
Output is correct |
4 |
Correct |
4 ms |
1628 KB |
Output is correct |
5 |
Correct |
4 ms |
1628 KB |
Output is correct |
6 |
Correct |
6 ms |
1824 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
11 ms |
1800 KB |
Output is correct |
4 |
Correct |
4 ms |
1628 KB |
Output is correct |
5 |
Correct |
4 ms |
1628 KB |
Output is correct |
6 |
Correct |
6 ms |
1824 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
4 ms |
1820 KB |
Output is correct |
12 |
Correct |
4 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
1820 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
1628 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
1628 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
2 ms |
1628 KB |
Output is correct |
21 |
Correct |
2 ms |
1624 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
8 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
1628 KB |
Output is correct |
25 |
Correct |
9 ms |
1628 KB |
Output is correct |
26 |
Correct |
8 ms |
1628 KB |
Output is correct |
27 |
Correct |
3 ms |
1788 KB |
Output is correct |
28 |
Correct |
7 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
5 ms |
1808 KB |
Output is correct |
31 |
Correct |
8 ms |
1628 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
7 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1796 KB |
Output is correct |
35 |
Correct |
4 ms |
1628 KB |
Output is correct |
36 |
Correct |
4 ms |
1628 KB |
Output is correct |
37 |
Correct |
4 ms |
1628 KB |
Output is correct |
38 |
Execution timed out |
3043 ms |
1628 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 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 |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1624 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Execution timed out |
3030 ms |
5500 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
11 ms |
1800 KB |
Output is correct |
4 |
Correct |
4 ms |
1628 KB |
Output is correct |
5 |
Correct |
4 ms |
1628 KB |
Output is correct |
6 |
Correct |
6 ms |
1824 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
4 ms |
1820 KB |
Output is correct |
12 |
Correct |
4 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
1820 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
1628 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
1628 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
2 ms |
1628 KB |
Output is correct |
21 |
Correct |
2 ms |
1624 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
8 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
1628 KB |
Output is correct |
25 |
Correct |
9 ms |
1628 KB |
Output is correct |
26 |
Correct |
8 ms |
1628 KB |
Output is correct |
27 |
Correct |
3 ms |
1788 KB |
Output is correct |
28 |
Correct |
7 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
5 ms |
1808 KB |
Output is correct |
31 |
Correct |
8 ms |
1628 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
7 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1796 KB |
Output is correct |
35 |
Correct |
4 ms |
1628 KB |
Output is correct |
36 |
Correct |
4 ms |
1628 KB |
Output is correct |
37 |
Correct |
4 ms |
1628 KB |
Output is correct |
38 |
Execution timed out |
3043 ms |
1628 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
11 ms |
1800 KB |
Output is correct |
4 |
Correct |
4 ms |
1628 KB |
Output is correct |
5 |
Correct |
4 ms |
1628 KB |
Output is correct |
6 |
Correct |
6 ms |
1824 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1372 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
4 ms |
1820 KB |
Output is correct |
12 |
Correct |
4 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
1820 KB |
Output is correct |
15 |
Correct |
1 ms |
1628 KB |
Output is correct |
16 |
Correct |
6 ms |
1628 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
6 ms |
1628 KB |
Output is correct |
19 |
Correct |
1 ms |
1628 KB |
Output is correct |
20 |
Correct |
2 ms |
1628 KB |
Output is correct |
21 |
Correct |
2 ms |
1624 KB |
Output is correct |
22 |
Correct |
1 ms |
1372 KB |
Output is correct |
23 |
Correct |
8 ms |
1628 KB |
Output is correct |
24 |
Correct |
1 ms |
1628 KB |
Output is correct |
25 |
Correct |
9 ms |
1628 KB |
Output is correct |
26 |
Correct |
8 ms |
1628 KB |
Output is correct |
27 |
Correct |
3 ms |
1788 KB |
Output is correct |
28 |
Correct |
7 ms |
1628 KB |
Output is correct |
29 |
Correct |
5 ms |
1628 KB |
Output is correct |
30 |
Correct |
5 ms |
1808 KB |
Output is correct |
31 |
Correct |
8 ms |
1628 KB |
Output is correct |
32 |
Correct |
6 ms |
1628 KB |
Output is correct |
33 |
Correct |
7 ms |
1628 KB |
Output is correct |
34 |
Correct |
7 ms |
1796 KB |
Output is correct |
35 |
Correct |
4 ms |
1628 KB |
Output is correct |
36 |
Correct |
4 ms |
1628 KB |
Output is correct |
37 |
Correct |
4 ms |
1628 KB |
Output is correct |
38 |
Execution timed out |
3043 ms |
1628 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |