当前位置:网站首页>4. European Champions League
4. European Champions League
2022-07-27 01:18:00 【lzl_ 0408】
【 Problem description 】
The Champions League is often praised as the most influential club level event in the world . In the group stage of the game , European football clubs are divided into eight groups , Four teams in each group . The teams in each group are sorted according to the following rules :
The team will get points according to the result of the game . The two sides of a game are called the home team and the visiting team . If one side scores more goals than the other , Then the side with more goals will get 3 branch , The other party gets 0 branch . If the two sides draw , Then each gets 1 branch .
The net winning goal of a team is the number of goals minus the number of goals lost ( Whether the team is the home team or the visiting team in the game ).
The team with higher points ranks higher .
If two teams have the same score , Then the team with more goal difference ranks high .
The teams of the group have a round robin , That is, every two teams play two games , The two sides alternate as the home team . Given a group 12 The result of the game , Ask for the team to qualify : That is, the first and second teams .
Make sure the answer is unique .
【 Input form 】
The first line of input contains an integer T, Represents the number of groups of test data . Next is T Group data .
Each group of data has 12 That's ok , Each line describes a game , The format is :“ Home team name home team goals vs. The number of goals scored by the visiting team is the name of the visiting team ”, among “ The name of the home team ” and “ The name of the visiting team ” For the string ,“ The number of goals scored by the home team ” and “ The number of goals scored by the visiting team ” For the number of goals scored by each team in this game .
1 ≤ T ≤ 50
The team name only contains lowercase English letters
The length of the team name shall not exceed 10 Characters
0 ≤ goals ≤ 100
【 Output form 】
For each set of data , Output one line , Contains two strings , The name of the team representing the first and second ranked teams .
【 The sample input 】
2 manutd 8 vs. 2 arsenal lyon 1 vs. 2 manutd fcbarca 0 vs. 0 lyon fcbarca 5 vs. 1 arsenal manutd 3 vs. 1 fcbarca arsenal 6 vs. 0 lyon arsenal 0 vs. 0 manutd manutd 4 vs. 2 lyon arsenal 2 vs. 2 fcbarca lyon 0 vs. 3 fcbarca lyon 1 vs. 0 arsenal fcbarca 0 vs. 1 manutd a 3 vs. 0 b a 0 vs. 0 c a 0 vs. 0 d b 0 vs. 0 a b 4 vs. 0 c b 0 vs. 0 d c 0 vs. 0 a c 0 vs. 0 b c 1 vs. 0 d d 3 vs. 0 a d 0 vs. 0 b d 0 vs. 0 c
【 Sample output 】
manutd fcbarca d b
【 Sample explanation 】
The first set of data : The points and goal difference of each team are :
manutd:16 branch , Goal difference 12.
manutd:8 branch , Goal difference 4.
manutd:5 branch , Goal difference −5.
manutd:4 branch , Goal difference −11.
The second set of data : The points and goal difference of each team are :
d:7 branch , Goal difference 2.
b:7 branch , Goal difference 1.
a:7 branch , Goal difference 0.
c:7 branch , Goal difference −3.
All teams have the same points , But the team with more goal difference ranks higher .
#include<iostream>
#include <algorithm>
#include<map>
using namespace std;
struct Team
{
string name;
int score=0;
int ncount=0;
};
bool cmp(Team a, Team b)
{
if (a.score==b.score)
return a.ncount>b.ncount;
else
return a.score>b.score;
}
int main()
{
int n;
cin>>n;
while(n--)
{
Team team[4];// Four teams
string team1,team2,vs;
int score1,score2;
map<string,int> maps;
int remark=0;
for(int i=0;i<12;i++)// Twelve groups of competitions
{
cin>>team1>>score1>>vs>>score2>>team2;
if(remark < 4 && maps.find(team1)== maps.end())// There are only four teams && This team name has never appeared
{
team[remark].name=team1;
maps[team1]=remark;// Put keywords ( Team name ) Corresponds to the subscript of the array , Convenient to visit later
remark++;
}
if(remark < 4 && maps.find(team2)== maps.end())// The two team names you enter should be judged
{
team[remark].name=team2;
maps[team2]=remark;
remark++;
}
int n1 = maps[team1], n2 = maps[team2];// It's really convenient to map team names to array subscripts
if(score1!=score2)
{
if(score1>score2)
{
team[n1].score+=3;
team[n1].ncount+=abs(score1-score2);
team[n2].ncount-=abs(score1-score2);
}
else
{
team[n2].score+=3;
team[n2].ncount+=abs(score1-score2);
team[n1].ncount-=abs(score1-score2);
}
}
else
{
team[n1].score+=1;
team[n2].score+=1;
}
}
sort(team, team + 4, cmp);
cout << team[0].name << " " << team[1].name << endl;
}
return 0;
}边栏推荐
- Zhimi Tencent cloud live mlvb plug-in optimization tutorial: six steps to improve streaming speed + reduce live delay
- 5. 合法的括号串
- 深度学习报告(3)
- Doris or starrocks JMeter pressure measurement
- 4.root用户登录
- When a transaction encounters a distributed lock
- Play guest cloud brush machine 5.9
- Scala pattern matching
- Li Hongyi machine learning (2017 Edition)_ P5: error
- 05 - attack and defense of phishing websites
猜你喜欢

New experience of mlvb cloud live broadcast: millisecond low latency live broadcast solution (with live broadcast performance comparison)

随着5G越来越普及,我们的生活会受到哪些积极的影响

MySQL关闭连接事务自动提交的问题

腾讯升级视频号小程序直播功能,腾讯持续推广直播的底气是这项叫视立方(MLVB)的技术

Neo4j Basic Guide (installation, node and relationship data import, data query)

Game project export AAB package upload Google tips more than 150m solution

SQL学习(3)——表的复杂查询与函数操作

Jenkins--基础--04--安装中文插件

More than live streaming: what other eye-catching functions does Tencent cloud live mlvb plug-in have besides streaming / streaming

SQL学习(2)——表的基础查询与排序
随机推荐
Flink1.11 intervaljoin watermark generation, state cleaning mechanism source code understanding & demo analysis
Rabbit learning notes
Uni-app 小程序 App 的广告变现之路:Banner 信息流广告
ContextCompat.checkSelfPermission()方法
IDEA导入外部项目时pom文件的依赖无效问题解决
Li Hongyi machine learning (2017 Edition)_ P21: convolutional neural network CNN
Spark ---- shuffle and partition of RDD
微信大量下架数字藏品相关小程序:NFT产品究竟是未来还是陷阱?
Li Hongyi machine learning (2017 Edition)_ P3-4: Regression
The setup of KEIL development environment is delivered to the installation package
Verilog过程赋值语句
物联网将彻底改变制造业,你准备好了吗?
When a transaction encounters a distributed lock
Wu Enda's in-depth learning series teaching video learning notes (I) -- logistic regression function for binary classification
Li Hongyi machine learning (2021 Edition)_ P7-9: training skills
Create MDK project
ks 怎么抓salt值?api,did?
Jenkins--基础--03--安装后设置向导
SQL关系代数——除法
5. 合法的括号串