HDU 6152 Friend-Graph

Problem Description

It is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team. 
In a team with n members,if there are three or more members are not friends with each other or there are three or more members who are friends with each other. The team meeting the above conditions can be called a bad team.Otherwise,the team is a good team. 
A company is going to make an assessment of each team in this company. We have known the team with n members and all the friend relationship among these n individuals. Please judge whether it is a good team.

Input

The first line of the input gives the number of test cases T; T test cases follow.(T<=15) 
The first line od each case should contain one integers n, representing the number of people of the team.(n≤3000)

Then there are n-1 rows. The ith row should contain n-i numbers, in which number aij represents the relationship between member i and member j+i. 0 means these two individuals are not friends. 1 means these two individuals are friends.

Output

Please output ”Great Team!” if this team is a good team, otherwise please output “Bad Team!”.

Sample Input



1 1 0 
0 0 
1

Sample Output

Great Team!

题目大意:

输入的第一行给出测试用例T的数量; (T <= 15) 
每个案件的第一行应包含一个整数n,表示团队人数(n≤3000) 
那么有n-1行。 第i行应包含n-i个数字,其中a[i][j]表示成员i与成员j + i之间的关系。 0表示这两个人不是朋友。 1表示这两个人是朋友。在一个有n个成员的团队中,如果有三个或更多的成员不是彼此的朋友,或者有三个或更多的成员是彼此的朋友。符合以上条件的球队可以称为坏队,否则,球队是一支好球队。 
这道题给的时候够大可以直接暴力,不过这道题卡内存,刚开始用int型超内存,后来改为bool类型就过了。

c++

内存超限代码

#include<iostream>
#include<cstdio>
using namespace std;
int m[3010][3010];
int dg(int n)
{
    int a,b,c,d,e;
    for(c=1;c<=n;c++)
    {
        for(d=c+1;d<=n;d++)
        {
            for(a=d+1;a<=n;a++)
            {
                if(m[c][d]==m[c][a]&&m[c][a]==m[d][a]&&m[c][d]==m[d][a])
                    return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int a,b,c,d,e,f;
    scanf("%d",&a);
    while(a--)
    {
        scanf("%d",&b);
        for(c=1;c<b;c++)
        {
            for(d=1+c;d<=b;d++)
            {
                scanf("%d",&m[c][d]);
                m[d][c]=m[c][d];
            }
        }
        e=dg(b);
        if(e==0)
            printf("Great Team!\n");
        else
            printf("Bad Team!\n");
    }
    return 0;
}

AC代码

#include<iostream>
#include<cstdio>
using namespace std;
bool m[3010][3010];
int dg(int n)
{
    int a,b,c,d,e;
    for(c=1;c<=n;c++)
    {
        for(d=c+1;d<=n;d++)
        {
            for(a=d+1;a<=n;a++)
            {
                if(m[c][d]==m[c][a]&&m[c][a]==m[d][a]&&m[c][d]==m[d][a])
                    return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int a,b,c,d,e,f;
    scanf("%d",&a);
    while(a--)
    {
        scanf("%d",&b);
        for(c=1;c<b;c++)
        {
            for(d=1+c;d<=b;d++)
            {
                scanf("%d",&f);
                if(f==1)
                    m[d][c]=m[c][d]=false;
                else
                    m[d][c]=m[c][d]=true;
            }
        }
        e=dg(b);
        if(e==0)
            printf("Great Team!\n");
        else
            printf("Bad Team!\n");
    }
    return 0;
}











全部评论

相关推荐

狸猫换offer:神通广大的互联网
点赞 评论 收藏
分享
关于“实习生工资多少才算正常”,其实并没有一个放之四海而皆准的标准,但如果结合一线城市的生活成本、工作强度以及实习本身创造的价值来看,我个人认为6000&nbsp;元左右应当是一个基本及格线,也就是每天&nbsp;200&nbsp;多元。如果能达到&nbsp;300、400&nbsp;元一天,甚至更高,那无疑是更理想的状态。首先,从现实成本看,房租、通勤、餐饮几乎都是刚性支出。低于这个水平的实习,往往意味着实习生需要用家庭或存款“倒贴”工作,这在长期来看并不合理。实习本质上是学习,但并不等于“廉价劳动力”,更不应该是经济压力的来源。其次,愿意给实习生更高薪资的公司,通常不会是差公司。这至少说明两点:一是公司资金相对充足,不是靠压缩人力成本勉强维持;二是公司认可实习生的价值,希望你真正参与业务、创造产出,而不是只做边角料工作。很多高薪实习往往伴随着更规范的培养体系、更高的信息密度和更真实的项目经验。当然,高工资并不等于一切,但它往往是一个重要信号。能给到&nbsp;300、400&nbsp;元一天甚至更多的公司,往往对效率、能力和长期发展更有追求,也更可能处在一个有前景的赛道中。总结来说,实习工资不仅是钱的问题,更是公司态度、实力和发展前景的体现。在条件允许的情况下,争取一份“付得起你时间”的实习,本身就是一种理性选择。
北国牛马:你是不是忘了你一周只能上五天班,月薪6000那你日薪就得300了,日薪200一个月也就4000,也就刚好覆盖生活成本了
实习生工资多少才算正常?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务