随一个序列然后贪心即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<bits/stdc++.h>
using namespace std;
int n,a[55],v[55][55],cnt[55],b[55];
vector<int> ans;
mt19937 rd((unsigned long long)new char);
int main(){
cin>>n;
for(int i=1;i<=n;++i)b[i]=i;
int x,y;
while(cin>>x>>y)v[x][y]=v[y][x]=1,++cnt[x],++cnt[y];
while(1.0*clock()/CLOCKS_PER_SEC<=0.985){
vector<int> g;g.push_back(b[1]);
for(int i=2;i<=n;++i){
if(cnt[b[i]]<g.size())continue;
int c=0;
for(int j:g)c+=v[b[i]][j];
if(c==g.size())g.push_back(b[i]);
}
if(ans.size()<g.size())ans=g;
if(ans.size()==n)break;
shuffle(b+1,b+n+1,rd);
}
cout<<ans.size()<<'\n';
return 0;
}