L - Who is the Champion (排序)

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.

Sample 1

InputcopyOutputcopy
2
0 1
2 0
2

Sample 2

InputcopyOutputcopy
2
0 1
1 0
play-offs

Sample 3

InputcopyOutputcopy
3
0 1 3
1 0 4
0 0 0
2

思路:

1,按着题意模拟,用结构体排序

2,胜球与输球的意思,在ij位置的球数,相当于i胜j输

代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxj=1e5+100,mod=1e9+7,inf=0x7f7f7f7f7f7f7f7f;

struct node{
    int score=0,win=0,lose=0,id;
}dd[110];//结构体排序,
bool cmp (node a,node b){
    if(a.score==b.score){
        return (a.win-a.lose)<(b.win-b.lose);
    }else{
        return a.score<b.score;
    }
}
int a[110][110];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        dd[i].id=i;
        for(int j=1;j<=n;++j){
            cin>>a[i][j];
            dd[i].win+=a[i][j];
            dd[j].lose+=a[i][j];
        }   
    }if(n==1){//特例的判断
        puts("1");
        return ;
    }
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            if(a[i][j]==a[j][i]){
                dd[i].score++;
                dd[j].score++;
            }else if(a[i][j]>a[j][i]){
                dd[i].score+=3;
            }else{
                dd[j].score+=3;
            }
        }
    }sort(dd+1,dd+1+n,cmp);
    if(dd[n].score==dd[n-1].score&&(dd[n].win-dd[n].lose)==(dd[n-1].win-dd[n-1].lose)){
        puts("play-offs");
    }else cout<<dd[n].id<<'\n';
}
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    t=1;
    while(t--)solve();
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值