【HDU】5952
来源:互联网 发布:同花顺软件开发怎么样 编辑:程序博客网 时间:2024/06/10 11:51
题目链接:点击打开题目
数据不是很大,直接爆搜就行了。
代码如下:
#include<queue>#include<cmath>#include<stack>#include<cstdio>#include<vector>#include<cstring>#include<iostream>#include<algorithm>using namespace std;typedef long long LL;#define INF 0x3f3f3f3f#define CLR(a,b) memset(a,b,sizeof(a))#define PI acos(-1.0)int n,m,c;bool Edge[105][105];vector<int> E[105];vector<int> Vertex;int ans;bool check(int k){ for (int i = 0 ; i < Vertex.size() ; i++) { if (!Edge[Vertex[i]][k]) return false; } return true;}void dfs(int pos){ if (Vertex.size() == c) { ans++; return; } for (int i = 0 ; i < E[pos].size() ; i++) { if (check(E[pos][i])) { Vertex.push_back(E[pos][i]); dfs(E[pos][i]); Vertex.pop_back(); } }}int main(){ int T; scanf ("%d",&T); while (T--) { scanf ("%d %d %d",&n,&m,&c); ans = 0; Vertex.clear(); for (int i = 1 ; i <= n ; i++) { E[i].clear(); for (int j = 1 ; j <= n ; j++) { Edge[i][j] = false; } } for (int i = 1 ; i <= m ; i++) { int x,y; scanf ("%d %d",&x,&y); if (x > y) swap(x,y); E[x].push_back(y); Edge[x][y] = Edge[y][x] = true; } for (int i = 1 ; i <= n-c+1 ; i++) { Vertex.push_back(i); dfs(i); Vertex.clear(); } printf ("%d\n",ans); } return 0;}
阅读全文
0 0
- HDU 5952
- HDU 5952
- 【HDU】5952
- hdu 5952
- HDU 5952 搜索
- HDU 5952 - Counting Cliques
- hdu 5952 Counting Cliques
- HDU 5952 搜索
- hdu 5952 Counting Cliques
- hdu 5952 暴力搜索
- hdu 5952 Counting Cliques
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- 蓝桥杯——剪邮票
- maven私有库的安装、配置和使用
- 作业(10/1-10/3)
- linux系统很卡的基本排查方法
- 栈操作
- 【HDU】5952
- Struts2入门
- java基础增强--泛型
- 洛谷P2015 二叉苹果树
- 项目第三天
- html不容易记标签记录
- yum在cnetos下安装mysql
- 软件安装
- 第五周 项目1-建立顺序栈算法库