# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924433 | Muhammad_Aneeq | Political Development (BOI17_politicaldevelopment) | C++17 | 3018 ms | 5972 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.
/*
بسم الله الرحمن الرحيم
Author:
(:Muhammad Aneeq:)
*/
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int const N=6e4+10;
vector<int>nei[N]={};
int res[N]={};
int ans=0;
bool valid(vector<int>f)
{
for (auto i:f)
res[i]=0;
for (auto i:f)
{
for (auto j:nei[i])
res[j]++;
}
bool w=0;
for (auto i:f)
{
if (res[i]!=f.size()-1)
{
w=1;
break;
}
}
return (!w);
}
vector<int>f;
int n,k;
void check(int j,int n)
{
if (f.size()==k-1)
{
f.push_back(n);
if (valid(f))
ans=max(ans,int(f.size()));
f.pop_back();
return;
}
if (j==nei[n].size())
{
f.push_back(n);
if (valid(f))
ans=max(ans,int(f.size()));
f.pop_back();
return;
}
check(j+1,n);
f.push_back(nei[n][j]);
check(j+1,n);
f.pop_back();
}
inline void solve()
{
cin>>n>>k;
for (int i=0;i<n;i++)
{
int d;
cin>>d;
while (d--)
{
int x;
cin>>x;
if (i!=x)
nei[i].push_back(x);
}
}
for (int i=1;i<=n;i++)
check(0,i);
cout<<min(ans,k)<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
solve();
}
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... |