当前位置:网站首页>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;
}边栏推荐
- Wu Enda's in-depth learning series teaching video learning notes (I) -- logistic regression function for binary classification
- 以赛促练-力扣第303场周赛反思
- 07 - setup and attack of log server
- What is kubernetes?
- 创建MDK工程
- Naive Bayes Multiclass训练模型
- Android——LitePal数据库框架的基本用法
- 大四老学长的自我批评记录
- In depth learning report (2)
- FaceNet
猜你喜欢

Create MDK project

Naive Bayes Multiclass训练模型

Flink1.11 intervaljoin watermark generation, state cleaning mechanism source code understanding & demo analysis

移动直播选择 RTMP 还是RTC协议

What is kubernetes?

Jenkins--基础--5.2--系统配置--系统配置

Jenkins -- Basic -- 5.2 -- system configuration -- system configuration

Scala pattern matching

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

Come on: encourage college graduates to return home to start businesses and employment, and help rural revitalization
随机推荐
Android——数据持久化技术(三) 数据库存储
Jenkins -- Basic -- 5.3 -- system configuration -- global security configuration
IDEA导入外部项目时pom文件的依赖无效问题解决
Tencent upgrades the live broadcast function of video Number applet. Tencent's foundation for continuous promotion of live broadcast is this technology called visual cube (mlvb)
MTCNN
New experience of mlvb cloud live broadcast: millisecond low latency live broadcast solution (with live broadcast performance comparison)
腾讯升级视频号小程序直播功能,腾讯持续推广直播的底气是这项叫视立方(MLVB)的技术
Play guest cloud brush machine 5.9
As 5g becomes more and more popular, what positive effects will our lives be affected
短视频App开发有哪些必备的功能?
Contextcompat. Checkselfpermission() method
Simple explanation of database table connection
Jenkins--基础--5.1--系统配置--插件管理
Android -- Data Persistence Technology (III) database storage
Understanding of Flink checkpoint source code
Zhimi Tencent cloud live mlvb plug-in optimization tutorial: six steps to improve streaming speed + reduce live delay
深度学习报告(3)
Deep understanding of pod objects: basic management
Uni-app开发App和插件以后如何开通广告盈利:uni-AD
How to open ads for profit after uni app develops apps and plug-ins: uni ad