# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128401 | KasymK | Political Development (BOI17_politicaldevelopment) | C++20 | 3095 ms | 25020 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 5e3+5;
bool adj[N][N];
int answer, n;
void dfs(vector<bool> &vis, int mal){
umax(answer, mal);
while(1){
bool did=0;
for(auto i : vis)
did|=i;
if(!did)
break;
int id=n;
for(int i = n-1; i >= 0; --i)
if(vis[i]){
vis[i]=0;
id=i;
break;
}
vector<bool> is(n, false);
for(int i = 0; i < n; ++i)
if(vis[i] and adj[id][i])
is[i]=1;
int cnt=0;
for(int i = 0; i < n; ++i)
cnt+=is[i];
if(cnt+mal+1>answer)
dfs(is, mal+1);
}
}
int main(){
int k;
scanf("%d%d", &n, &k);
for(int i = 0; i < n; ++i){
int x, ad;
scanf("%d", &x);
adj[i][i]=1;
while(x--)
scanf("%d", &ad), adj[i][ad]=1;
}
vector<bool> vis(n, true);
dfs(vis, 0);
printf("%d\n", answer);
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... |