답안 #240276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240276 2020-06-19T06:19:49 Z alishahali1382 Political Development (BOI17_politicaldevelopment) C++14
27 / 100
111 ms 4600 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=50010, K=10;

int n, m, k, u, v, x, y, t, a, b, ans;
int deg[MAXN], P[MAXN];
int adj[K], V[MAXN];
int dp[1<<K];
vector<int> G[MAXN];
stack<int> stk;

int MaxClique(int n){
	for (int i=0; i<n; i++){
		adj[i]=0;
		for (int j=0; j<n; j++) if (i!=j){
			auto it=lower_bound(all(G[V[i]]), V[j]);
			if (it==G[V[i]].end() || *it==V[j]) adj[i]|=(1<<j);
		}
	}
	for (int mask=1; mask<(1<<n); mask++){
		int v=__builtin_ctz(mask);
		dp[mask]=max(dp[mask^(1<<v)], dp[mask&adj[v]]+1);
	}
	return dp[(1<<n)-1];
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	for (int i=0; i<n; i++){
		cin>>deg[i];
		G[i].resize(deg[i]);
		for (int j=0; j<deg[i]; j++) cin>>G[i][j];
		sort(all(G[i]));
		if (deg[i]<k) stk.push(i);
	}
	for (int i=0; i<n; i++){
		int v=stk.top();
		stk.pop();
		P[v]=i;
		for (int u:G[v]) if (deg[u]--==k) stk.push(u);
	}
	for (int i=0; i<n; i++){
		int cnt=0;
		for (int v:G[i]) if (P[i]<P[v]) V[cnt++]=v;
		assert(cnt<k);
		ans=max(ans, MaxClique(cnt)+1);
	}
	cout<<ans<<'\n';
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
4 Correct 7 ms 1792 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 7 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
4 Correct 7 ms 1792 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 7 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1664 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 8 ms 1792 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
14 Correct 7 ms 1792 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Incorrect 7 ms 1792 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1664 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 5 ms 1536 KB Output is correct
4 Correct 5 ms 1536 KB Output is correct
5 Correct 5 ms 1536 KB Output is correct
6 Correct 6 ms 1536 KB Output is correct
7 Correct 6 ms 1536 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 5 ms 1536 KB Output is correct
11 Correct 106 ms 4472 KB Output is correct
12 Correct 5 ms 1536 KB Output is correct
13 Correct 110 ms 4476 KB Output is correct
14 Correct 5 ms 1536 KB Output is correct
15 Correct 109 ms 4476 KB Output is correct
16 Correct 107 ms 4472 KB Output is correct
17 Correct 111 ms 4600 KB Output is correct
18 Correct 107 ms 4512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
4 Correct 7 ms 1792 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 7 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1664 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 8 ms 1792 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
14 Correct 7 ms 1792 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Incorrect 7 ms 1792 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1536 KB Output is correct
2 Correct 5 ms 1536 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
4 Correct 7 ms 1792 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 7 ms 1792 KB Output is correct
7 Correct 7 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 6 ms 1536 KB Output is correct
10 Correct 5 ms 1664 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 8 ms 1792 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
14 Correct 7 ms 1792 KB Output is correct
15 Correct 5 ms 1536 KB Output is correct
16 Incorrect 7 ms 1792 KB Output isn't correct
17 Halted 0 ms 0 KB -