The world cup is coming

Title Description

The 2018 World Cup in Russia ended, France won the championship, and the fans all over the world had a very happy summer. As a Chinese fan, we can't always watch others play football. It's not good. According to the unanimous decision of FIFA (International Football Association) and all member associations, the 2118 World Cup will be held in China. As the host country, the Chinese team will directly participate in the final stage of the competition without participating in the preliminary competition.

The rules are as follows:

A total of n (n is even) teams play

Top n/2 teams enter the knockout stage according to the score of group match

The rules for ranking points are as follows: the team wins 3 points, draws 1 point, loses 0 point, and ranks in the way of decreasing points, decreasing net wins and decreasing goals.

Write a program, according to the given team list and the results of all competitions, to find out the team list that has successfully entered the knockout stage.

[input form]

   The first line of input contains the unique integer n (1 < = n < = 50), the number of teams that will play in the World Cup finals. The next N lines are the names of the teams, which are not longer than 30 characters in English. Next n*(n-1)/2 lines, each line format name1-name2 num1:num2 (0 < = num1, num2 < = 100), indicating the team and score. 

[output form]

   Enter n/2 lines to indicate the teams entering the knockout stage, and arrange them according to the dictionary order. Each team name takes up one line.

[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

AC code

#include<iostream>
#include<cstring>

using namespace std;

int main()
{
	int n;
	cin>>n;
	cin.get();
	string str[n];
	for(int i=0;i<n;i++){
		getline(cin,str[i]);
	}
	int m=n*(n-1)/2,a[n][3]={0};
	while(m--){
		string string,str1,str2;
		char x;
		int q1,q2,k=0;
		cin>>string;
		cin>>q1>>x>>q2;
		for(int i=0;i<n;i++){
			if(string[i]=='-') {
				k=i;
				break;
			}
		}
		int m=string.length();
		str1=string.substr(0,k);
		str2=string.substr(k+1,m-1);
		for(int i=0;i<n;i++){
			if(str[i]==str1){
				if(q1>q2) a[i][0]=a[i][0]+3;
				if(q1==q2) a[i][0]=a[i][0]+1;
				a[i][1]=a[i][1]+q1-q2;
				a[i][2]=a[i][2]+q1;
			} 
			if(str[i]==str2){
				if(q1<q2) a[i][0]=a[i][0]+3;
				if(q1==q2) a[i][0]=a[i][0]+1;
				a[i][1]=a[i][1]+q2-q1;
				a[i][2]=a[i][2]+q2;
			 } 
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(a[i][0]<a[j][0]){
				string sw=str[i]; str[i]=str[j]; str[j]=sw;
				int l=a[i][0]; a[i][0]=a[j][0]; a[j][0]=l;
				 l=a[i][1]; a[i][1]=a[j][1]; a[j][1]=l;
				 l=a[i][2]; a[i][2]=a[j][2]; a[j][2]=l;
			}
			if(a[i][0]==a[j][0]){
				if(a[i][1]<a[j][1]){
					string sw=str[i]; str[i]=str[j]; str[j]=sw;
					int l=a[i][0]; a[i][0]=a[j][0]; a[j][0]=l;
					 l=a[i][1]; a[i][1]=a[j][1]; a[j][1]=l;
					 l=a[i][2]; a[i][2]=a[j][2]; a[j][2]=l;
				}
				if(a[i][1]==a[j][1]){
					if(a[i][2]<a[j][2]){
						string sw=str[i]; str[i]=str[j]; str[j]=sw;
						int l=a[i][0]; a[i][0]=a[j][0]; a[j][0]=l;
						 l=a[i][1]; a[i][1]=a[j][1]; a[j][1]=l;
						 l=a[i][2]; a[i][2]=a[j][2]; a[j][2]=l;
					}
				}
			}
		}
		}
		int y=n/2;
		string st[y];
		for(int i=0;i<y;i++){
			st[i]=str[i];
		}
		for(int i=0;i<y-1;i++){
			for(int j=i+1;j<y;j++){
				if(st[i]>st[j]){
					string qw=st[i]; st[i]=st[j]; st[j]=qw;
				}
			} 
		}
		for(int i=0;i<y;i++){
			cout<<st[i]<<endl;
		}
	return 0;
}

Added by Shovinus on Sun, 03 Nov 2019 08:42:17 +0200