NEFU要崛起——第17场 A-Word Cup

 

这是一个字符串处理的题,没用到什么算法,但是处理起来还是有点棘手的,改了老半天才弄好委屈

 

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

struct Team
{
    string name;
    int fi,se,th;
}t[60];

int cmp(Team a,Team b)
{
    if (a.fi!=b.fi) return a.fi>b.fi;
    else if (a.se!=b.se) return a.se>b.se;
    else return a.th>b.th;
}

/*int cmp1(string aa,string bb)
{
    return (strcmp(aa,bb)<0?1:0);
}
*/

int main()
{

    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>t[i].name;
//fi[i]=se[i]=th[i]=0;
        t[i].fi=t[i].se=t[i].th=0;
    }

    for (int i=0;i<n*(n-1)/2;i++)
    {
        string te,t1,t2;
        int a,b;
        char ch;
        cin>>te>>a>>ch>>b;
//cout<<a<<" "<<b<<"============="<<endl;
        t1=te.substr(0, te.find('-'));
        t2=te.substr(te.find('-')+1);

//	cout<<"--"<<t1<<"--"<<t2<<"---"<<endl;

        for (int j=0;j<n;j++)
        {
            if (t[j].name==t1)
            {
//	cout<<t1<<"====="<<endl;
                if (a>b)
                    t[j].fi+=3;
                else if (a==b)
                    t[j].fi+=1;

                t[j].se+=a-b;
                t[j].th+=a;
            }

            if (t[j].name==t2)
            {
//cout<<t2<<"--------"<<endl;
                if (a<b)
                    t[j].fi+=3;
                else if (a==b)
                    t[j].fi+=1;

                t[j].se+=b-a;
                t[j].th+=b;
            }

        }


    }
    string ans[30];
    sort(t,t+n,cmp);
    for (int i=0;i<n/2;i++)
        ans[i]=t[i].name;
    sort(ans,ans+n/2);
    for (int i=0;i<n/2;i++)
        cout<<ans[i]<<endl;

    return 0;
}

/*
4
A
B
C
D
A-B 1:1
A-C 2:2
A-D 1:0
B-C 1:0
B-D 0:3
C-D 0:3
2
a
A
a-A 2:1
*/


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值