#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 |
Runtime error |
7 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 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 |
Runtime error |
7 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |