Football the most popular sport in the world (americans insist to call it "Soccer", but we will call it "Football"). As everyone knows, Brasil is the country that have most World Cup titles (four of them: 1958, 1962, 1970 and 1994). As our national tournament have many teams (and even regional tournaments have many teams also) it's a very hard task to keep track of standings with so many teams and games played!

So, your task is quite simple: write a program that receives the tournament name, team names and games played and outputs the tournament standings so far.

A team wins a game if it scores more goals than its oponent. Obviously, a team loses a game if it scores less goals. When both teams score the same number of goals, we call it a tie. A team earns 3 points for each win, 1 point for each tie and 0 point for each loss.

Teams are ranked according to these rules (in this order):

Most points earned.

Most wins.

Most goal difference (i.e. goals scored - goals against)

Most goals scored.

Less games played.

Lexicographic order.

The Input

The first line of input will be an integer N in a line alone (0 < N < 1000). Then, will follow N tournament descriptions. Each one begins with the tournament name, on a single line. Tournament names can have any letter, digits, spaces etc. Tournament names will have length of at most 100. Then, in the next line, there will be a number T (1 < T <= 30), which stands for the number of teams participating on this tournament. Then will follow T lines, each one containing one team name. Team names may have any character that have ASCII code greater than or equal to 32 (space), except for '#' and '@' characters, which will never appear in team names. No team name will have more than 30 characters.

Following to team names, there will be a non-negative integer G on a single line which stands for the number of games already played on this tournament. G will be no greater than 1000. Then, G lines will follow with the results of games played. They will follow this format:

team_name_1#goals1@goals2#team_name_2

For instance, the following line:

Team A#3@1#Team B

Means that in a game between Team A and Team B, Team A scored 3 goals and Team B scored 1. All goals will be non-negative integers less than 20. You may assume that there will not be inexistent team names (i.e. all team names that appear on game results will have apperead on the team names section) and that no team will play against itself.

The Output

For each tournament, you must output the tournament name in a single line. In the next T lines you must output the standings, according to the rules above. Notice that should the tie-breaker be the lexographic order, it must be done case insenstive. The output format for each line is shown bellow:

[a]) Team_name [b]p, [c]g ([d]-[e]-[f]), [g]gd ([h]-[i])

Where:

[a] = team rank

[b] = total points earned

[c] = games played

[d] = wins

[e] = ties

[f] = losses

[g] = goal difference

[h] = goals scored

[i] = goals against

There must be a single blank space between fields and a single blank line between output sets. See the sample output for examples.

Sample Input

2

World Cup 1998 - Group A

4

Brazil

Norway

Morocco

Scotland

6

Brazil#2@1#Scotland

Norway#2@2#Morocco

Scotland#1@1#Norway

Brazil#3@0#Morocco

Morocco#3@0#Scotland

Brazil#1@2#Norway

Some strange tournament

5

Team A

Team B

Team C

Team D

Team E

5

Team A#1@1#Team B

Team A#2@2#Team C

Team A#0@0#Team D

Team E#2@1#Team C

Team E#1@2#Team D

Sample Output

World Cup 1998 - Group A

  1. Brazil 6p, 3g (2-0-1), 3gd (6-3)
  2. Norway 5p, 3g (1-2-0), 1gd (5-4)
  3. Morocco 4p, 3g (1-1-1), 0gd (5-5)
  4. Scotland 1p, 3g (0-1-2), -4gd (2-6)

Some strange tournament

  1. Team D 4p, 2g (1-1-0), 1gd (2-1)
  2. Team E 3p, 2g (1-0-1), 0gd (3-3)
  3. Team A 3p, 3g (0-3-0), 0gd (3-3)
  4. Team B 1p, 1g (0-1-0), 0gd (1-1)
  5. Team C 1p, 2g (0-1-1), -1gd (3-4)

shi一样长的laji题目,给出若干球队和比赛结果,要你做出最后的积分榜。

胜平负积分分别为3,1,0;

积分榜的排名标准:

1.积分

2.获胜场次

3.净胜球

4.进球数

5.更少的场次

6.队名的字典序(尼玛这里忽略大小写艹艹艹艹)

读入数据有点麻烦,注意格式控制

输出注意最后一组数据后不要空行

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
//#define for(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;
using namespace std;
const double pi=acos(-1.0);
struct qq
{
string name;
int point;//赢得点数
int game;//比赛场数
int win,ties,loss;//赢平输
int get,against;//得球和失球
}a[35];
bool cmp(qq a,qq b)
{
if(a.point !=b.point )
return a.point >b.point;
if(a.win !=b.win )
return a.win >b.win ;
if((a.get-a.against)!=(b.get-b.against))
return (a.get-a.against)>(b.get-b.against);
if(a.get!=b.get)
return a.get>b.get;
if(a.game!=b.game)
return a.game<b.game;
string t1,t2;
for (int i=0;i<a.name.size();i++)
t1+=tolower(a.name[i]);
for (int i=0;i<b.name.size();i++)
t2+=tolower(b.name[i]);
return t1<t2;
}
int main()
{
int re;
// freopen("output1.txt", "w", stdout);
cin>>re;
getchar();
string discrub;
while(re--)
{
getline(cin,discrub);
// cout<<discrub<<endl;
int n,m;
sf("%d",&n);
getchar();
for(int i=0;i<n;i++)
{
getline(cin,a[i].name);
a[i].against =0;
a[i].get =0;
a[i].game =0;
a[i].loss =0;
a[i].point =0;
a[i].ties =0;
a[i].win =0;
}
sf("%d",&m);
getchar();
string x;
while(m--)
{
getline(cin,x);
int point1=0,point2=0;
int i;
for(i=0;i<x.size();i++)
if(x[i]=='#') break;
string name1(x,0,i);
i++;
for(;;i++)
{
if(x[i]=='@') break;
point1=point1*10+x[i]-48;
}
i++;
for(;;i++)
{
if(x[i]=='#') break;
point2=point2*10+x[i]-48;
}
i++;
string name2(x,i,x.size()-i);
for(i=0;i<n;i++)
{
if(a[i].name ==name1)
{
a[i].game ++;
a[i].get+=point1;
a[i].against+=point2;
if(point1==point2)
{
a[i].ties++;
a[i].point++;
}else if(point1>point2)
{
a[i].win++;
a[i].point +=3;
}
else if(point1<point2) a[i].loss ++;
}
if(a[i].name==name2)
{
a[i].game ++;
a[i].get+=point2;
a[i].against +=point1;
if(point1==point2)
{
a[i].ties++;
a[i].point++;
}else if(point1<point2)
{
a[i].win++;
a[i].point +=3;
}
else if(point1>point2) a[i].loss ++;
}
}
}
sort(a,a+n,cmp);
cout<<discrub<<endl;
for(int i=0;i<n;i++)
{
pf("%d) ",i+1);
cout<<a[i].name;
pf(" %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n",a[i].point,a[i].game,a[i].win,a[i].ties,a[i].loss,a[i].get-a[i].against,a[i].get,a[i].against);
}
if(re!=0)
cout<<endl;
}
return 0;
}

D - Football (aka Soccer)的更多相关文章

  1. UVA 10194 Football (aka Soccer)

     Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (america ...

  2. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  3. 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)

    第一题:340 - Master-Mind Hints UVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Item ...

  4. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  5. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

  6. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  7. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  8. Volume 1. Sorting/Searching(uva)

    340 - Master-Mind Hints /*读了老半天才把题读懂,读懂了题输出格式没注意,结果re了两次. 题意:先给一串数字S,然后每次给出对应相同数目的的一串数字Si,然后优先统计Si和S ...

  9. Randy Pausch’s Last Lecture

          he University of Virginia American Studies Program 2002-2003.                     Randy Pausch ...

随机推荐

  1. Revit选择增强插件易蜀预选择过滤器

    Revit本身提供的选择过滤器能让我们快速选择到我们需要的图元,而将那些不需要的图元排除在选择集之外,如下图所示,假如我们需要选择全部的风管弯头,那么一种方法,我们可以点选,还有就是框选所有弯头,这样 ...

  2. 【T07】不要低估tcp的性能

    1.tcp在ip的基础上增加了校验和.可靠性和流量控制的功能,而udp只增加了校验和的功能,看起来udp应该会比tcp快很多, 但事实不是这样,有时候tcp比udp的性能还要好. 2.思考,在什么情况 ...

  3. Python:提取网页中的电子邮箱

    import requests, re #regex = r"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"#这个正则表达式过滤 ...

  4. 用 JAAS 和 JSSE 实现 Java 安全性

    JAAS 和 JSSE 概述 JAAS 提供了一种灵活的.说明性的机制,用于对用户进行认证并验证他们访问安全资源的能力.JSSE 定义了通过安全套接字层(SSL)进行安全 Web 通信的一种全 Jav ...

  5. JProfiler进行Java运行时内存分析

    原文地址:https://www.cnblogs.com/onmyway20xx/p/3963735.html 在最近的工作中,通过JProfiler解决了一个内存泄漏的问题,现将检测的步骤和一些分析 ...

  6. Activity标题(title)的显示和隐藏

    开发Android应用程序,我们总会遇到Activity的title把显示的内容遮挡了一部分.如果能把它去掉,我们的应用界面就会变得更加简洁,那该多好.下面有两种方法可以去掉: (方法一):通过一句J ...

  7. 模仿Semaphore自定义自己的 信号量

    简介 这里模仿Semaphore,自定义自己的信号量,利用AQS共享模式 1.MySemaphore.java package com.jacky; import java.util.concurre ...

  8. 【九天教您南方cass 9.1】01 安装Cad和Cass9.1

    同学们大家好,欢迎收看由老王测量上班记出品的cass9.1视频课程 今后会将cass的教程目录定期发布在测量空间中. 我是本节课主讲老师九天. [点击索取cass教程]5元立得 (给客服说暗号:“老王 ...

  9. 完美解决"Encountered an NTFS Volume with a logfile ..."

    完美解决Ghost镜像文件时出现"Encountered an NTFS Volume with a logfile that has not been flushed(536)" ...

  10. python进行数据分析

    1.  python进行数据分析----线性回归 2. python进行数据分析------相关分析 3. python进行数据分析---python3卡方 4. 多重响应分析,多选题二分法思路 5. ...