Who is the Champion(icpc南昌区域赛)

Soccer is probably the sport with the greatest fans in this country. However, the national team has a poor record on the world stage. In order to energize youth players, the Soccer National Championship is organized every year.

In this year, there are nn teams taking part in the championship. As usual, the single round-robin system is adopted so that each team plays every other team once. A standard match askes ten players and a goalkeeper for both teams, which contains 2222 players in total. They confront each other, defend their nets and attack the opponent's goal in a rectangular grass court.

In a 90-minute game, they try to shoot again and again. When the game is over, the team with higher goals will win and obtain 33 points in the scoreboard, while the loser will obtain nothing. A very special but common case is that both teams get the same goals, which is a draw; then both of them will obtain one point in the scoreboard.

At the end of the season, the league will declare the champion which is the team with the highest score in total. If two or more teams have the same highest score in total, the one with the highest goal differential (which is calculated as the number of goals scored in all league matches minus the number of goals conceded) will be the champion. The worst situation that several teams have the same highest score in total and the same goal differential will be solved by extra play-offs.

Input

The first line contains an integer n~(1\le n \le 100)n (1≤n≤100) indicating the number of teams.

Each of the following nn lines contains nn integers.The jj-th integer in the ii-th line, which is non-negative and up to five, represents the number of goals scored by the ii-th team against the jj-th team.

We guarantee that a_{i,i}=0ai,i​=0 for all 1\le i \le n1≤i≤n.

Output

If the league can declare the champion, output the index of the team who will be the champion or output play-offs (without quotes), if extra play-offs will be organized.

样例输入1复制

2
0 1
2 0

样例输出1复制

2

样例输入2复制

2
0 1
1 0

样例输出2复制

play-offs

样例输入3复制

3
0 1 3
1 0 4
0 0 0

样例输出3复制

2

【题意】

求那支队伍赢得了冠军,并输出那支队伍;

否则输出play-offs。

【思路】

定义一个结构体,三个变量队伍编号,得分,胜场数。

如果得分不同,按照分从高到低排序;如果分一样,按照胜场数从高到低排序。

胜了:得分加3,胜场数加一,同时输的那一方胜场数减一。

最后输出结果。

#include <bits/stdc++.h>
using namespace std;
const int N=110;
struct team
{
    int id;
    int score;
    int diff;
};
bool cmp(team a, team b)
{
    if(a.score!=b.score)
        return a.score>b.score;
    else
        return a.diff>b.diff;
}
int n,score[N][N];
team teams[N];
int main()
{
    int i,j;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        teams[i].id=i;
        teams[i].score=0;
        teams[i].diff=0;
        for(j=1;j<=n;j++)
        {
            scanf("%d",&score[i][j]);
        }
    }
    if(n==1)
    {
        cout<<1<<endl;
        return 0;
    }
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if (score[i][j]>score[j][i])
            {
                teams[i].score+=3;
                teams[i].diff+=(score[i][j]-score[j][i]);
                teams[j].diff+=(score[j][i]-score[i][j]);
            }
            else if(score[i][j]==score[j][i])
            {
                teams[i].score+=1;
                teams[j].score+=1;
            }
            else
            {
                teams[j].score+=3;
                teams[j].diff+=(score[j][i]-score[i][j]);
                teams[i].diff+=(score[i][j]-score[j][i]);
            }
        }
    }
    sort(teams+1,teams+n+1,cmp);
    if(teams[1].score==teams[2].score&&teams[1].diff==teams[2].diff)
       cout<<"play-offs"<<endl;
    else
        cout<<teams[1].id<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Good evening everyone, I am honored to stand before you today to talk about a topic that is very close to my heart - the power of self-confidence. Self-confidence is the foundation upon which we build our dreams and aspirations. Let me start by sharing some data with you. According to a study by the University of Wolverhampton, individuals with high self-confidence are more likely to succeed in their personal and professional lives, have better mental health, and enjoy a higher quality of life than those with low self-esteem. Now, let's talk about some famous personalities who have inspired us with their self-confidence. Oprah Winfrey, a self-made billionaire, once said, "It doesn't matter who you are, where you come from. The ability to triumph begins with you. Always." She is a living example of how self-confidence can help you overcome obstacles and achieve success. Another inspiring story is that of J.K. Rowling, the author of the Harry Potter series. She was rejected by several publishers before her manuscript was finally accepted. Her self-confidence and belief in her work kept her going, and today she is one of the most successful authors in the world. And who can forget the legendary Muhammad Ali? He was not just a great boxer but also a great believer in himself. He said, "I am the greatest. I said that even before I knew I was." He had unwavering self-confidence and went on to become a world champion. These are just a few examples of how self-confidence can change your life. But the truth is that self-confidence is not something that comes naturally to everyone. It is something that needs to be practiced and nurtured over time. So, how can we develop self-confidence? Firstly, we need to stop comparing ourselves to others. We are all unique individuals with our own strengths and weaknesses. Secondly, we need to focus on our strengths and work on improving them. Thirdly, we need to surround ourselves with positive people who encourage and support us. In conclusion, self-confidence is not just a feeling, it's a mindset. It's about believing in yourself, your abilities, and your dreams. I urge you all to nurture your self-confidence and let it be the driving force behind your success. Thank you.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值