답안 #240280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240280 2020-06-19T06:25:01 Z alishahali1382 Political Development (BOI17_politicaldevelopment) C++14
100 / 100
127 ms 6776 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[K];
int dp[1<<K];
vector<int> G[MAXN];
queue<int> Q;

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) Q.push(i);
	}
	for (int i=0; i<n; i++){
		int v=Q.front();
		Q.pop();
		P[v]=i;
		for (int u:G[v]) if ((--deg[u])==k-1) Q.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 8 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 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 8 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 7 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 Correct 7 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 8 ms 1792 KB Output is correct
19 Correct 6 ms 1664 KB Output is correct
20 Correct 7 ms 1792 KB Output is correct
21 Correct 7 ms 1792 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1792 KB Output is correct
24 Correct 6 ms 1536 KB Output is correct
25 Correct 8 ms 1792 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 8 ms 1792 KB Output is correct
28 Correct 8 ms 1792 KB Output is correct
29 Correct 8 ms 1792 KB Output is correct
30 Correct 8 ms 1792 KB Output is correct
31 Correct 8 ms 1792 KB Output is correct
32 Correct 8 ms 1792 KB Output is correct
33 Correct 8 ms 1792 KB Output is correct
34 Correct 8 ms 1792 KB Output is correct
35 Correct 7 ms 1664 KB Output is correct
36 Correct 7 ms 1664 KB Output is correct
37 Correct 7 ms 1664 KB Output is correct
38 Correct 6 ms 1536 KB Output is correct
39 Correct 7 ms 1664 KB Output is correct
40 Correct 10 ms 1792 KB Output is correct
41 Correct 6 ms 1536 KB Output is correct
42 Correct 9 ms 1792 KB Output is correct
43 Correct 9 ms 1792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1536 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 6 ms 1536 KB Output is correct
6 Correct 5 ms 1536 KB Output is correct
7 Correct 5 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 110 ms 4512 KB Output is correct
12 Correct 5 ms 1536 KB Output is correct
13 Correct 118 ms 4600 KB Output is correct
14 Correct 5 ms 1536 KB Output is correct
15 Correct 115 ms 4472 KB Output is correct
16 Correct 127 ms 4472 KB Output is correct
17 Correct 114 ms 4572 KB Output is correct
18 Correct 113 ms 4600 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 8 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 7 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 Correct 7 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 8 ms 1792 KB Output is correct
19 Correct 6 ms 1664 KB Output is correct
20 Correct 7 ms 1792 KB Output is correct
21 Correct 7 ms 1792 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1792 KB Output is correct
24 Correct 6 ms 1536 KB Output is correct
25 Correct 8 ms 1792 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 8 ms 1792 KB Output is correct
28 Correct 8 ms 1792 KB Output is correct
29 Correct 8 ms 1792 KB Output is correct
30 Correct 8 ms 1792 KB Output is correct
31 Correct 8 ms 1792 KB Output is correct
32 Correct 8 ms 1792 KB Output is correct
33 Correct 8 ms 1792 KB Output is correct
34 Correct 8 ms 1792 KB Output is correct
35 Correct 7 ms 1664 KB Output is correct
36 Correct 7 ms 1664 KB Output is correct
37 Correct 7 ms 1664 KB Output is correct
38 Correct 6 ms 1536 KB Output is correct
39 Correct 7 ms 1664 KB Output is correct
40 Correct 10 ms 1792 KB Output is correct
41 Correct 6 ms 1536 KB Output is correct
42 Correct 9 ms 1792 KB Output is correct
43 Correct 9 ms 1792 KB Output is correct
44 Correct 12 ms 2048 KB Output is correct
45 Correct 5 ms 1536 KB Output is correct
46 Correct 10 ms 1920 KB Output is correct
47 Correct 14 ms 1920 KB Output is correct
48 Correct 9 ms 1920 KB Output is correct
49 Correct 13 ms 2048 KB Output is correct
50 Correct 14 ms 2048 KB Output is correct
51 Correct 28 ms 2304 KB Output is correct
52 Correct 7 ms 1792 KB Output is correct
53 Correct 30 ms 2432 KB Output is correct
54 Correct 36 ms 2432 KB Output is correct
55 Correct 7 ms 1792 KB Output is correct
56 Correct 7 ms 1792 KB Output is correct
57 Correct 6 ms 1536 KB Output is correct
58 Correct 31 ms 2432 KB Output is correct
59 Correct 9 ms 1792 KB Output is correct
60 Correct 8 ms 1792 KB Output is correct
61 Correct 8 ms 1792 KB Output is correct
62 Correct 9 ms 1792 KB Output is correct
63 Correct 12 ms 2048 KB Output is correct
64 Correct 11 ms 2048 KB Output is correct
65 Correct 9 ms 1792 KB Output is correct
66 Correct 9 ms 1792 KB Output is correct
67 Correct 17 ms 2048 KB Output is correct
68 Correct 11 ms 2048 KB Output is correct
69 Correct 9 ms 1792 KB Output is correct
70 Correct 15 ms 2048 KB Output is correct
71 Correct 17 ms 2048 KB Output is correct
72 Correct 16 ms 2048 KB Output is correct
73 Correct 7 ms 1792 KB Output is correct
74 Correct 13 ms 1920 KB Output is correct
75 Correct 16 ms 2048 KB Output is correct
76 Correct 11 ms 1916 KB Output is correct
77 Correct 19 ms 2176 KB Output is correct
78 Correct 8 ms 1792 KB Output is correct
79 Correct 12 ms 1836 KB Output is correct
80 Correct 11 ms 1920 KB Output is correct
81 Correct 19 ms 2176 KB Output is correct
82 Correct 6 ms 1664 KB Output is correct
83 Correct 13 ms 1920 KB Output is correct
84 Correct 15 ms 2048 KB Output is correct
85 Correct 6 ms 1664 KB Output is correct
86 Correct 14 ms 2048 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 8 ms 1792 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 7 ms 1792 KB Output is correct
12 Correct 7 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 Correct 7 ms 1792 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 8 ms 1792 KB Output is correct
19 Correct 6 ms 1664 KB Output is correct
20 Correct 7 ms 1792 KB Output is correct
21 Correct 7 ms 1792 KB Output is correct
22 Correct 5 ms 1536 KB Output is correct
23 Correct 8 ms 1792 KB Output is correct
24 Correct 6 ms 1536 KB Output is correct
25 Correct 8 ms 1792 KB Output is correct
26 Correct 8 ms 1920 KB Output is correct
27 Correct 8 ms 1792 KB Output is correct
28 Correct 8 ms 1792 KB Output is correct
29 Correct 8 ms 1792 KB Output is correct
30 Correct 8 ms 1792 KB Output is correct
31 Correct 8 ms 1792 KB Output is correct
32 Correct 8 ms 1792 KB Output is correct
33 Correct 8 ms 1792 KB Output is correct
34 Correct 8 ms 1792 KB Output is correct
35 Correct 7 ms 1664 KB Output is correct
36 Correct 7 ms 1664 KB Output is correct
37 Correct 7 ms 1664 KB Output is correct
38 Correct 6 ms 1536 KB Output is correct
39 Correct 7 ms 1664 KB Output is correct
40 Correct 10 ms 1792 KB Output is correct
41 Correct 6 ms 1536 KB Output is correct
42 Correct 9 ms 1792 KB Output is correct
43 Correct 9 ms 1792 KB Output is correct
44 Correct 5 ms 1536 KB Output is correct
45 Correct 71 ms 5752 KB Output is correct
46 Correct 39 ms 4728 KB Output is correct
47 Correct 79 ms 5880 KB Output is correct
48 Correct 77 ms 5752 KB Output is correct
49 Correct 29 ms 4600 KB Output is correct
50 Correct 97 ms 6776 KB Output is correct
51 Correct 71 ms 5752 KB Output is correct
52 Correct 27 ms 4608 KB Output is correct
53 Correct 30 ms 4600 KB Output is correct
54 Correct 9 ms 2176 KB Output is correct
55 Correct 95 ms 6776 KB Output is correct
56 Correct 20 ms 4096 KB Output is correct
57 Correct 28 ms 4472 KB Output is correct
58 Correct 34 ms 4604 KB Output is correct
59 Correct 20 ms 4096 KB Output is correct
60 Correct 20 ms 4096 KB Output is correct
61 Correct 34 ms 4608 KB Output is correct
62 Correct 29 ms 4352 KB Output is correct
63 Correct 48 ms 4728 KB Output is correct
64 Correct 21 ms 4096 KB Output is correct
65 Correct 56 ms 5120 KB Output is correct
66 Correct 28 ms 4352 KB Output is correct
67 Correct 44 ms 4856 KB Output is correct
68 Correct 52 ms 4992 KB Output is correct
69 Correct 57 ms 5112 KB Output is correct
70 Correct 29 ms 4352 KB Output is correct
71 Correct 52 ms 4984 KB Output is correct
72 Correct 45 ms 4864 KB Output is correct
73 Correct 61 ms 5240 KB Output is correct
74 Correct 29 ms 4344 KB Output is correct
75 Correct 27 ms 3196 KB Output is correct
76 Correct 45 ms 4856 KB Output is correct
77 Correct 61 ms 5240 KB Output is correct
78 Correct 32 ms 3328 KB Output is correct
79 Correct 25 ms 3072 KB Output is correct
80 Correct 15 ms 2432 KB Output is correct
81 Correct 32 ms 3328 KB Output is correct
82 Correct 48 ms 4856 KB Output is correct
83 Correct 15 ms 2432 KB Output is correct
84 Correct 46 ms 4860 KB Output is correct