Submission #185463

#TimeUsernameProblemLanguageResultExecution timeMemory
185463nicolaalexandraPolitical Development (BOI17_politicaldevelopment)C++14
39 / 100
423 ms28016 KiB
#include <bits/stdc++.h> #define DIM 50010 using namespace std; priority_queue <pair<int,int>, vector <pair<int,int> >, greater<pair<int,int> > > H; set <int> L[DIM]; int n,k,i,j,sol,el,nod; int v[DIM],x[DIM],viz[DIM],f[DIM],g[DIM]; int verif (int pas, int nod){ for (int i=1;i<pas;i++){ int vecin = x[i]; if (L[nod].find(vecin) == L[nod].end()) return 0; if (L[vecin].find(nod) == L[vecin].end()) return 0; } return 1; } void back (int pas){ sol = max (sol,pas-1); if (pas >= k || pas > el) return; for (int i=1;i<=el;i++){ if (!f[i] && v[i] > x[pas-1] && verif(pas,v[i])){ x[pas] = v[i]; f[i] = 1; back(pas+1); f[i] = 0; } } } void get_max_clique (int nod){ el = 0; for (auto vecin:L[nod]) v[++el] = vecin; sort (v+1,v+el+1); back (1); } int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>k; for (i=1;i<=n;i++){ cin>>g[i]; for (j=1;j<=g[i];j++){ cin>>nod; L[i].insert(nod+1); } H.push (make_pair(g[i],i)); } while (!H.empty()){ int nod = H.top().second; int grad = H.top().first; H.pop(); if (grad != g[nod]) /// inseamna ca nu e ala cu gradul minim continue; /// vreau sa gasesc clica maxima din care poate face parte nod get_max_clique (nod); viz[nod] = 1; /// acum il elimin pe nod si toate muchiile for (auto vecin:L[nod]){ g[vecin]--; L[vecin].erase(L[vecin].find(nod)); if (!viz[vecin]){ /// nu am incercat sa obtin clica de aici deloc viz[vecin] = 1; H.push(make_pair(g[vecin],vecin)); } } } cout<<sol+1; return 0; }
#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...