当前位置:网站首页>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;
}边栏推荐
- SQL learning (3) -- complex query and function operation of tables
- 进入2022年,移动互联网的小程序和短视频直播赛道还有机会吗?
- SQL learning (1) - table related operations
- Flink1.11 write MySQL test cases in jdcb mode
- Flinksql window triggered in advance
- 游戏项目导出AAB包上传谷歌提示超过150M的解决方案
- 创建MDK工程
- x 的平方根
- 5. Legal bracket string
- 什么是数字经济,它是如何改变商业模式的?
猜你喜欢

进入2022年,移动互联网的小程序和短视频直播赛道还有机会吗?

In depth learning report (3)

MTCNN

adb. Exe stopped working popup problem

The dependency of POM file is invalid when idea imports external projects. Solution

短视频App开发有哪些必备的功能?

SQL学习(2)——表的基础查询与排序

Li Hongyi machine learning (2017 Edition)_ P14: back propagation

李宏毅机器学习(2021版)_P7-9:训练技巧

李宏毅机器学习(2017版)_P13:深度学习
随机推荐
In depth learning report (3)
When a transaction encounters a distributed lock
3. 拳王阿里
MySQL字符集设置为UTF-8,但控制台仍然出现中文乱码问题
Flink1.11 SQL local run demo & local webui visual solution
李宏毅机器学习(2017版)_P5:误差
Android -- Data Persistence Technology (III) database storage
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)
Jenkins--基础--5.2--系统配置--系统配置
Play guest cloud brush machine 5.9
解决Pytorch中Cuda无法GPU加速问题
深度学习报告(3)
Verilog过程赋值语句
25 common questions in Flink interview (no answer)
VSCode2015下编译darknet生成darknet.ext时error MSB3721:XXX已退出,返回代码为 1。
IDEA导入外部项目时pom文件的依赖无效问题解决
Jenkins--基础--02--安装
Jenkins -- Basic -- 5.2 -- system configuration -- system configuration
Li Hongyi machine learning (2017 Edition)_ P21: convolutional neural network CNN
吴恩达深度学习系列教学视频学习笔记(一)——用于二分类的logistic回归函数