zoukankan      html  css  js  c++  java
  • HDU

    题意:给定n个人的关系,若存在三个及以上的人两两友好或两两不友好,则"Bad Team!",否则"Great Team!"。

    分析:3000*3000内存10000+,因此存关系要用bool数组,否则mle。

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define Min(a, b) ((a < b) ? a : b)
    #define Max(a, b) ((a < b) ? b : a)
    const double eps = 1e-12;
    inline int dcmp(double a, double b)
    {
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 3000 + 10;
    const int MAXT = 3025 + 10;
    using namespace std;
    bool pic[MAXN][MAXN];
    int main(){
        int T;
        scanf("%d", &T);
        while(T--){
            memset(pic, 0, sizeof pic);
            int n;
            scanf("%d", &n);
            int x;
            for(int i = 1; i <= n; ++i){
                for(int j = i + 1; j <= n; ++j){
                    scanf("%d", &x);
                    if(x) pic[j][i] = pic[i][j] = true;
                    else pic[j][i] = pic[i][j] = false;
                }
            }
            bool ok = true;
            for(int i = 1; i <= n; ++i){
                for(int j = i + 1; j <= n; ++j){
                    for(int k = j + 1; k <= n; ++k){
                        if((pic[i][j] && pic[i][k] && pic[j][k]) || (!pic[i][j] && !pic[i][k] && !pic[j][k])){
                            ok = false;
                            break;
                        }
                    }
                    if(!ok) break;
                }
                if(!ok) break;
            }
            if(ok) printf("Great Team!
    ");
            else printf("Bad Team!
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    单击按钮左键弹起菜单
    高亮选中MEMO某一行
    DelphiTXT文档编辑器
    桌面名人名言
    判断richtextbox选中的是否为图片
    数组
    解决Linux下IDEA无法使用ibus输入法的问题和tip乱码
    Spring实现AOP的多种方式
    java术语(PO/POJO/VO/BO/DAO/DTO)
    idea intellij对Spring进行单元测试
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/7467521.html
Copyright © 2011-2022 走看看