You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
const int N = 110 ;
int n , m , ans , st [ N ] ;
int a [ N ] [ N ] ;
bool check ( int u ) {
for ( int i = 1 ; i < u ; i + + )
if ( st [ i ] & & a [ u ] [ i ] ) return false ;
return true ;
}
void dfs ( int u , int sum ) { // 第u号钻石, 之前一共选了sum个钻石
if ( u = = n + 1 ) { // 如果所有钻石都找完了
ans = max ( ans , sum ) ; // 取最大值
return ;
}
// 如果剩下的钻石都选也没有已有的最好情况多,返回,剪枝
// if (ans > sum + (n - u + 1)) return;
if ( check ( u ) ) { // 当前钻石与已选钻石没有冲突
st [ u ] = 1 ; // 选之
dfs ( u + 1 , sum + 1 ) ; // 继续下一个钻石
st [ u ] = 0 ; // 不选
}
dfs ( u + 1 , sum ) ; // 继续下一个钻石
}
int main ( ) {
cin > > n > > m ;
while ( m - - ) {
int x , y ;
cin > > x > > y ;
a [ x ] [ y ] = a [ y ] [ x ] = 1 ; // x<->y互相冲突
}
dfs ( 1 , 0 ) ; // 从第一个钻石开始选, 目前已选0个
cout < < ans < < endl ;
return 0 ;
}