# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218626 | MKopchev | Political Development (BOI17_politicaldevelopment) | C++14 | 545 ms | 28932 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;
const int nmax=5e4+42,kmax=20;
int n,k;
set<int> adj[nmax];
priority_queue< pair<int/*size*/,int/*node*/> > pq;
int output;
int active[kmax],pointer=0;
int bitmasks[nmax];
void solve(int node)
{
active[0]=node;
pointer=1;
for(auto k:adj[node])
{
active[pointer]=k;
pointer++;
}
for(int i=0;i<pointer;i++)
bitmasks[i]=0;
for(int i=0;i<pointer;i++)
for(int j=0;j<pointer;j++)
{
if(i==j||adj[active[i]].count(active[j]))
bitmasks[i]+=(1<<j);
}
/*
cout<<"active: ";for(int i=0;i<pointer;i++)cout<<active[i]<<" ";cout<<endl;
cout<<"masks: ";for(int i=0;i<pointer;i++)cout<<bitmasks[i]<<" ";cout<<endl;
*/
for(int to_test=0;to_test<(1<<pointer);to_test++)
{
int in=0;
for(int j=0;j<pointer;j++)
if((to_test&(1<<j)))
{
if((bitmasks[j]&to_test)!=to_test)in=-1e9;
else in++;
}
output=max(output,in);
}
}
int main()
{
scanf("%i%i",&n,&k);
for(int i=0;i<n;i++)
{
int sz,node;
scanf("%i",&sz);
for(int j=1;j<=sz;j++)
{
scanf("%i",&node);
adj[i].insert(node);
adj[node].insert(i);
}
}
for(int i=0;i<n;i++)
pq.push({-adj[i].size(),i});
for(int turn=0;turn<n;turn++)
{
while(adj[pq.top().second].size()!=-pq.top().first)pq.pop();//incorrect size
int current=pq.top().second;
pq.pop();
//cout<<"current= "<<current<<endl;
solve(current);
for(auto k:adj[current])
{
adj[k].erase(current);
pq.push({-adj[k].size(),k});
}
adj[current]={};
}
printf("%i\n",output);
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... |