# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128412 | KasymK | Political Development (BOI17_politicaldevelopment) | C++20 | 4 ms | 3396 KiB |
// I want to go high as fuck tonight...
// Music name => (Gyzyl Ysyk)
// Authors: A$OK, SazYelme, Swizzy347 and Ma.Gallery
// Hash your favorite words.
#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;
bitset<N> adj[N];
int answer, n;
void dfs(bitset<N> vis, int mal){
while(1){
// bool did=0;
// for(auto i : vis)
// did|=i;
// if(!did)
// break;
if(!vis.any())
break;
// int id=n;
// for(int i = n-1; i >= 0; --i)
// if(vis[i]){
// vis[i]=0;
// id=i;
// break;
// }
int id=vis._Find_first();
vis[id]=0;
// vector<bool> is(n, false);
bitset<N> is=vis&adj[id];
int cnt=is.count();
// 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(umax(answer, cnt+mal+1))
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;
}
bitset<N> vis;
vis.set();
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... |