Submission #1103338

#TimeUsernameProblemLanguageResultExecution timeMemory
1103338alexddPolitical Development (BOI17_politicaldevelopment)C++17
4 / 100
7 ms3580 KiB
#include <bits/stdc++.h> using namespace std; int n,k,mxm; set<int> con[50005]; set<pair<int,int>> s; int b[20]; int main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>k; mxm=1; for(int i=1;i<=n;i++) { int nr,x; cin>>nr; for(int j=0;j<nr;j++) { cin>>x; x++; con[i].insert(x); } s.insert({nr,i}); } for(int pas=1;pas<=n;pas++) { auto it = s.begin(); int nod = (*it).second; s.erase(it); vector<int> v; for(auto j:con[nod]) v.push_back(j); assert((int)v.size() < k); for(int config=1;config<(1<<((int)v.size()));config++) { int cnt=0; for(int j=0;j<v.size();j++) { if((1<<j)&config) { b[cnt++]=j; } } if(cnt+1>mxm) { bool bun=1; for(int i=0;i<cnt;i++) { for(int j=i+1;j<cnt;j++) { if(con[b[i]].find(b[j])==con[b[i]].end()) { bun=0; break; } } if(!bun) break; } if(bun) { mxm = cnt+1; if(mxm==k) { cout<<k; return 0; } } } } for(auto j:con[nod]) { s.erase({con[j].size(),j}); con[j].erase(nod); s.insert({con[j].size(),j}); } } cout<<mxm; return 0; }

Compilation message (stderr)

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for(int j=0;j<v.size();j++)
      |                         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...