当前位置:网站首页>6. The world cup is coming
6. The world cup is coming
2022-07-27 01:18:00 【lzl_ 0408】
【 Problem description 】
2018 The world cup in Russia is over , France won the championship , Fans all over the world had a very happy summer . As a Chinese fan , You can't always watch others play football , This is not welfare , according to FIFA( FIFA ) And the unanimous decision of all member associations ,2118 The world cup will be held in China , As the host , The Chinese team will directly participate in the Finals without participating in the qualifiers .
The rules of the game are as follows :
in total n(n For the even ) Teams play
Rank according to the points of the group match , front n/2 Our team entered the knockout
The rules for ranking points are as follows : The team won 3 branch , A draw would be 1 branch , Defeated 0 branch , Decrease by integral 、 Ranking by decreasing goal difference and decreasing number of goals
Write a program , According to the list of participating teams and the results of all competitions , Find out the list of teams that have successfully entered the knockout stage .
【 Input form 】
The first line of input contains a unique integer n(1<=n<=50), The number of teams participating in the World Cup finals . Next n OK is the name of each team , Is not longer than 30 English characters of characters . Next n*(n-1)/2 That's ok , Format per line name1-name2 num1:num2(0<=num1, num2<=100), It means the team and score .
【 Output form 】
Input n/2 That's ok , It means the team entering the knockout stage , Arrange in dictionary order , Each team name is on one line .
【 The sample input 】
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
【 Sample output 】
A
D
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct Team
{
string name;
int score=0;
int ncount=0;
int mcount=0;
};
bool cmp(Team a, Team b)
{
if (a.score==b.score)
{
if(a.ncount==b.ncount)
return a.mcount>b.mcount;
else
return a.ncount>b.ncount;
}
else
return a.score>b.score;
}
map<string,int>maps;
bool cmp1(Team a,Team b)
{
return maps[a.name]<maps[b.name];
}
int main()
{
int n;
cin>>n;
Team team[n];
for(int i=0;i<n;i++)
{
string str;
cin>>str;
team[i].name=str;
maps[str]=i;
}
int m=n*(n-1)/2;
for(int i=0;i<m;i++)
{
string team1,team2,vs,st;
char vt;
int score1,score2;
cin>>st>>score1>>vt>>score2;//A-B 3:2
stringstream ss(st);
string sub_str;
getline(ss,sub_str,'-');
team1=sub_str;
getline(ss,sub_str,'-');
team2=sub_str;
int n1=maps[team1],n2=maps[team2];
team[n1].mcount+=score1;
team[n2].mcount+=score2;
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+n,cmp);
for(int i=0;i<n/2;i++)
{
sort(team,team+n/2,cmp1);
cout<<team[i].name<<endl;
}
return 0;
}边栏推荐
- Jenkins--基础--5.1--系统配置--插件管理
- 复杂度OJ题
- 集中式版本控制工具代码合并问题
- Come and help you understand the mobile Internet in a minute
- The shortest way to realize video applets: from bringing goods to brand marketing
- Flinksql multi table (three table) join/interval join
- The basic concept of how Tencent cloud mlvb technology can highlight the siege in mobile live broadcasting services
- Li Hongyi machine learning (2017 Edition)_ P3-4: Regression
- 随着5G越来越普及,我们的生活会受到哪些积极的影响
- 玩客云搭配zerotier保姆级教学,保证学废
猜你喜欢

快来帮你三分钟了解物联网

Are you ready for the Internet of things to revolutionize manufacturing?

Wu Enda's in-depth learning series teaching video learning notes (I) -- logistic regression function for binary classification

Li Hongyi machine learning (2017 Edition)_ P3-4: Regression

Database interim (I)

被围绕的区域

5.xshell连接服务器拒绝访问,密码错误

What is kubernetes?

复杂度OJ题

非递归前中后序遍历二叉树
随机推荐
集中式版本控制工具代码合并问题
Li Hongyi machine learning (2017 Edition)_ P21: convolutional neural network CNN
SQL学习(2)——表的基础查询与排序
李宏毅机器学习(2017版)_P14:反向传播
最长公共子串
adb. Exe stopped working popup problem
Doris or starrocks JMeter pressure measurement
adb.exe已停止工作 弹窗问题
解决Pytorch中Cuda无法GPU加速问题
MySQL关闭连接事务自动提交的问题
李宏毅机器学习(2017版)_P5:误差
Iptables detailed explanation and practical cases
[CTF attack and defense world] questions about backup in the web area
Li Hongyi machine learning (2017 Edition)_ P3-4: Regression
创建MDK工程
玩客云刷机 5.9
How can Tencent cloud live plug-in mlvb make use of these advantages to become the divine assistant of anchor Live Streaming?
Solve the problem that rsyslog service occupies too much memory
Flinksql multi table (three table) join/interval join
In depth learning report (3)