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 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 (stderr)
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++){
| ~^~~~~~~~~~~~~~~~
# | 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... |