平面图最大团 HDOJ 5277 YJC counts stars
来源:互联网 发布:女仆装淘宝网 编辑:程序博客网 时间:2024/05/16 11:40
CF上也有类似题。。。。注意到题目中的是平面图,给出的点是没用的。。。平面图最大团点数只有1,2,3,4四种情况,分类计算一下就行了。。。
#include <iostream>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>#include <cstdio>#include <algorithm>#include <cstring>#include <climits>#include <cstdlib>#include <cmath>#include <time.h>#define maxn 1005#define maxm 10005#define eps 1e-7#define mod 1000000007#define INF 0x3f3f3f3f#define PI (acos(-1.0))#define lowbit(x) (x&(-x))#define mp make_pair#define ls o<<1#define rs o<<1 | 1#define lson o<<1, L, mid #define rson o<<1 | 1, mid+1, R#define pii pair<int, int>#pragma comment(linker, "/STACK:16777216")typedef long long LL;typedef unsigned long long ULL;//typedef int LL; using namespace std;LL qpow(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base;base=base*base;b/=2;}return res;}LL powmod(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base%mod;base=base*base%mod;b/=2;}return res;}// headstruct node{int u, v;}e[maxm];bool g[maxn][maxn];int n, m;void work(){for(int i = 1; i <= n; i++) scanf("%*d%*d");memset(g, 0, sizeof g);for(int i = 1; i <= m; i++) {scanf("%d%d", &e[i].u, &e[i].v);g[e[i].u][e[i].v] = g[e[i].v][e[i].u] = true;}int cnt = 0;for(int i = 1; i <= m; i++) {int u = e[i].u, v = e[i].v;for(int j = 1; j <= n; j++)if(j != u && j != v && g[j][u] && g[j][v])for(int k = 1; k <= n; k++)if(k != j && k != u && k != v && g[j][k] && g[k][v] && g[k][u])cnt++;}if(cnt) {printf("4 %d\n", cnt / 12);return;}for(int i = 1; i <= m; i++) {int u = e[i].u, v = e[i].v;for(int j = 1; j <= n; j++)if(j != u && j != v && g[j][u] && g[j][v])cnt++;}if(cnt) {printf("3 %d\n", cnt / 3);return;}if(m == 0) printf("1 %d\n", n);else printf("2 %d\n", m);}int main(){while(scanf("%d%d", &n, &m)!=EOF) {work();}return 0;}
0 0
- 平面图最大团 HDOJ 5277 YJC counts stars
- HDU 5277 YJC counts stars (二维平面图求最大团)
- HDU 5277 YJC counts stars 最大团+暴力
- hdu5277 YJC counts stars(最大团)
- HDOJ-5277 YJC counts stars(DFS)
- hdu 5277 YJC counts stars
- hdu 5277 YJC counts stars
- HDU5277 YJC counts stars (图论知识平面图)
- HDU 5277 YJC counts stars 数星星
- hdu 5277(BestCoder Round#46 1002)YJC counts stars
- hdu 5277 YJC counts stars(邻接表+构造)
- hdoj 1530 Maximum Clique 【最大团】
- hdoj--1530--Maximum Clique(最大团)
- hdu 5277(最大团问题)
- 最大团
- 最大团
- 最大团
- 最大团
- [LeetCode][Java] Reverse Integer
- Grunt 新手需要了解的一些事情
- Scala 的数据结构
- MFC新线程控制进度条
- Anroid 解决小米和魅族不能在mac上调试
- 平面图最大团 HDOJ 5277 YJC counts stars
- p2p网贷3种运营模式
- Google JavaScript代码风格指南
- Servlet运行的详细步骤
- 找出一个文件的所有硬链接
- android SQLite用法
- Visio绘制UML用例图
- [Leetcode]-Remove Duplicates from Sorted List
- 《C语言及程序设计》实践项目——敲了哪一个键?