# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1103338 | alexdd | Political Development (BOI17_politicaldevelopment) | C++17 | 7 ms | 3580 KiB |
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;
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)
# | 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... |