# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1128423 | KasymK | Political Development (BOI17_politicaldevelopment) | C++20 | 1193 ms | 306584 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 = 5e4+5;
bitset<N> adj[N];
int answer, n;
void dfs(bitset<N> vis, int mal){
umax(answer, 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.reset(id);
// 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(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].set(i);
while(x--)
scanf("%d", &ad), adj[i].set(ad);
}
bitset<N> vis;
for(int i = 0; i < n; ++i)
vis.set(i);
dfs(vis, 0);
printf("%d\n", answer);
return 0;
}
컴파일 시 표준 에러 (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... |