# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1079477 | andrei_iorgulescu | Political Development (BOI17_politicaldevelopment) | C++14 | 11 ms | 26716 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;
bitset<50005> bs[50005];
vector<int> g[50005];
int deg[50005];
bool luat[50005];
int cn;
vector<int> o;
bool iau[15];
int ans = 1;
void afis()
{
for (int i = 0; i < o.size(); i++)
for (int j = i + 1; j < o.size(); j++)
if (iau[i] and iau[j] and !bs[o[i]][o[j]])
return;
ans = max(ans, 1 + (int)o.size());
}
void bkt(int pos)
{
if (pos == o.size())
afis();
else
{
iau[pos] = false;
bkt(pos + 1);
iau[pos] = true;
bkt(pos + 1);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
for (int i = 0; i < n; i++)
{
int cati;
cin >> cati;
while (cati--)
{
int x;
cin >> x;
g[i].push_back(x);
bs[i][x] = 1;
}
}
set<pair<int,int>> cmn;
for (int i = 0; i < n; i++)
{
deg[i] = g[i].size();
cmn.insert({deg[i], i});
}
while (!cmn.empty())
{
pair<int,int> pr = *cmn.begin();
cmn.erase(pr);
luat[pr.second] = true;
for (auto vec : g[pr.second])
{
if (!luat[vec])
{
cmn.erase({deg[vec], vec});
deg[vec]--;
cmn.insert({deg[vec], vec});
}
}
vector<int> oameni;
for (auto it : g[pr.second])
if (!luat[it])
oameni.push_back(it);
o = oameni;
cn = pr.second;
bkt(0);
}
cout << ans;
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... |