hdoj 6152 Friend-Graph
来源:互联网 发布:淘宝手机端网页制作 编辑:程序博客网 时间:2024/06/03 21:12
题目链接:Friend-Graph
题目大意:给你n个点,然后给出n个点之间的关系,1为认识,0为不认识,试问在这个图中是否存在三个或以上的点都互相认识的情况或者三个或以上的点都互相不认识的情况
题目思路:三个以上的情况存在则三个情况一定存在,所以只需要判断三个的情况,然后我们可以判断有三个存在的情况,判断三个都不存在的情况我们只需要将图翻转一下就好了,然后套用拉姆齐定理,然后三重暴力冲上去邻接矩阵判断,人有多大胆,地有多大产
#include <map>#include <set>#include <cmath>#include <vector>#include <queue>#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 3e3+10;int t,n,a[maxn][maxn];template <class T>inline bool scan_d(T &ret){ char c; int sgn; if (c = getchar(), c == EOF) { return 0; //EOF } while (c != '-' && (c < '0' || c > '9')) { c = getchar(); } sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0' && c <= '9') { ret = ret * 10 + (c - '0'); } ret *= sgn; return 1;}int main(){ scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i = 1;i < n;i++) for(int j = i+1;j <= n;j++) scanf("%d",&a[i][j]); if(n >= 6) {puts("Bad Team!");continue;} int flag = 0; for(int i = 1;i <= n;i++){ if(flag == 1) break; for(int j = i+1;j <= n;j++){ if(flag == 1) break; if(a[i][j] == 0) continue; for(int k = j+1;k <= n;k++){ if(a[i][k] == 1&&a[j][k] == 1) {flag = 1;puts("Bad Team!");break;} } } } if(flag == 1) continue; for(int i = 1;i < n;i++) for(int j = i+1;j <= n;j++) a[i][j] = (a[i][j]+1)%2; for(int i = 1;i <= n;i++){ if(flag == 1) break; for(int j = i+1;j <= n;j++){ if(flag == 1) break; if(a[i][j] == 0) continue; for(int k = j+1;k <= n;k++){ if(a[i][k] == 1&&a[j][k] == 1) {flag = 1;puts("Bad Team!");break;} } } } if(flag == 0) puts("Great Team!"); } return 0;}
阅读全文
0 0
- hdoj 6152 Friend-Graph
- HDU 6152 Friend-Graph
- HDU 6152 Friend-Graph
- hdu-6152 Friend-Graph
- HDU 6152 Friend-Graph
- HDU 6152 Friend-Graph
- hdu 6152 Friend-Graph
- HDU-6152Friend-Graph
- HDU 6152 Friend-Graph
- Hdu 6152 Friend-Graph【暴力】
- Friend-Graph
- Friend-Graph
- Friend-Graph
- Friend-Graph
- Friend-Graph
- Friend-Graph
- HDU 6152-Friend-Graph(ccpc)
- HDU 6152 Friend-Graph(定理)
- oracle 学习笔记
- HDU 3663 Power Stations DLX精确覆盖
- java中Action层、Service层和Dao层的功能区分
- HDU-Kolakoski
- Android数据解析JSON解析之FastJson解析
- hdoj 6152 Friend-Graph
- jQuery源码分析之数据类型判断方法——$.type()
- 神经网络反向传播算法
- gevent-1.2.2-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform
- JSP基础(一)
- JavaScript 常用的简写技巧
- 梯度下降
- SpringMVC详解(一)
- java中 == 与 equal 的区别