#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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
7 ms |
1792 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 |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
6 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
7 ms |
1792 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 |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
6 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 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 |
Incorrect |
5 ms |
1536 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1536 KB |
Output is correct |
2 |
Incorrect |
5 ms |
1536 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
7 ms |
1792 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 |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
6 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 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 |
Incorrect |
5 ms |
1536 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1536 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
7 ms |
1792 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 |
6 ms |
1536 KB |
Output is correct |
9 |
Correct |
6 ms |
1536 KB |
Output is correct |
10 |
Correct |
5 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 |
Incorrect |
5 ms |
1536 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |