题意:
100个点1000条边的图,问你有多少个s个点的团,每个节点的度不超过20
思路:
暴力。。边太少,直接纯暴都可以
2106ms
/* *********************************************** Author :devil ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <stack> #include <map> #include <string> #include <time.h> #include <cmath> #include <stdlib.h> #define LL long long #define rep(i,a,b) for(int i=a;i<=b;i++) #define dep(i,a,b) for(int i=a;i>=b;i--) #define ou(a) printf("%d ",a) #define pb push_back #define mkp make_pair template<class T>inline void rd(T &x) { char c=getchar(); x=0; while(!isdigit(c))c=getchar(); while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); } } #define IN freopen("in.txt","r",stdin); #define OUT freopen("out.txt","w",stdout); using namespace std; const int inf=0x3f3f3f3f; const int mod=1e9+7; const int N=1e2+10; vector<int>eg[N]; int t,n,m,s,x,y; int ans,num,tmp[N]; bool mp[N][N]; void dfs(int u,int v) { if(v+eg[u].size()<s) return; if(v==s) { ans++; return; } for(int i=0;i<eg[u].size();i++) { int j; for(j=0;j<num;j++) if(!mp[tmp[j]][eg[u][i]]) break; if(j==num) { tmp[num++]=eg[u][i]; dfs(eg[u][i],v+1); num--; } } } int main() { #ifndef ONLINE_JUDGE IN #endif scanf("%d",&t); while(t--) { scanf("%d%d%d",&n,&m,&s); for(int i=1;i<=n;i++) eg[i].clear(); memset(mp,0,sizeof(mp)); while(m--) { scanf("%d%d",&x,&y); if(x>y) swap(x,y); eg[x].pb(y); mp[x][y]=1; } ans=0; n=n-s+1; for(int i=1;i<=n;i++) { num=0; tmp[num++]=i; dfs(i,1); } printf("%d ",ans); } return 0; }