写在前面:
本题中的关键点:
【1】积分榜是按照以下原则制作的:胜利一个队得3分,平分1分,失败0分。首先,球队按积分顺序排在积分榜上,分数相等比较净胜球,净胜球相等比较进球数。
【2】按照字典顺序输出n/2n/2行进入淘汰赛阶段的球队的名字
【3】输入时的'-'与':'的处理
【净胜球】:是指进球数与失球数的差
原题复刻:
想法与思路:一道模拟题加sort排序,难点在于审清题意以及对输入数据的正确处理。
个人对于'-'的处理:
string tempa,tempb,tempfu;
cin>>tempfu;
tempa=tempfu.substr(0,tempfu.find('-'));
tempb=tempfu.substr(tempfu.find('-')+1);
//不加注释了
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+10;
typedef long long ll;
long long n;
map<string,int>fen,jinshen,jinqiu;
struct dui
{
string name;
int fen,jinshen,jingqiu;
}dui[MAX];
bool cmp1(struct dui a,struct dui b)
{
if(a.fen!=b.fen)return a.fen>b.fen;
else
{
if(a.jinshen!=b.jinshen)return a.jinshen>b.jinshen;
else return a.jingqiu>b.jingqiu;
}
}
bool cmp2(struct dui a,struct dui b)
{
return a.name<b.name;
}
void input()
{
cin>>n;
for(int i=1; i<=n; i++)
{
string temp;
cin>>temp;
fen[temp]=0;
}
ll temp=n*(n-1)/2;
string tempa,tempb,tempfu;
while(temp--)
{
cin>>tempfu;
tempa=tempfu.substr(0,tempfu.find('-'));
tempb=tempfu.substr(tempfu.find('-')+1);
int ji1,ji2;
char c;
cin>>ji1>>c>>ji2;
if(ji1==ji2)
{
fen[tempa]++;
fen[tempb]++;
}
else if(ji1>ji2)fen[tempa]+=3;
else fen[tempb]+=3;
jinshen[tempa]+=ji1-ji2;
jinshen[tempb]+=ji2-ji1;
jinqiu[tempa]+=ji1;
jinqiu[tempb]+=ji2;
}
}
void solve()
{
map<string,int>::iterator it=fen.begin();
for(int i=1; i<=n; i++,it++)
{
dui[i].name=it->first;
dui[i].fen=fen[it->first];
dui[i].jingqiu=jinqiu[it->first];
dui[i].jinshen=jinshen[it->first];
}
sort(dui+1,dui+1+n,cmp1);
sort(dui+1,dui+1+n/2,cmp2);
for(int i=1; i<=n/2; i++)cout<<dui[i].name<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
//cin>>t;
while(t--)
{
input();
solve();
}
}