CF43A Football

CF43A Football

题意翻译

题目大意

两只足球队比赛,现给你进球情况,问哪支队伍赢了。

第一行一个整数nn (1\leq n\leq 1001≤n≤100 ),表示有nn 次进球,接下来nn 行,每行一个长度不超过1010 ,只由大写字母组成的字符串,表示一个进球的球队名,保证只有两个球队。

输出一个字符串表示胜利球队的球队名,不会平局。

Translated by Khassar

题目描述

One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn‘t find the overall score of the match; however, he got hold of a profound description of the match‘s process. On the whole there are nn lines in that description each of which described one goal. Every goal was marked with the name of the team that had scored it. Help Vasya, learn the name of the team that won the finals. It is guaranteed that the match did not end in a tie.

输入输出格式

输入格式:

The first line contains an integer nn ( 1<=n<=1001<=n<=100 ) — the number of lines in the description. Then follow nn lines — for each goal the names of the teams that scored it. The names are non-empty lines consisting of uppercase Latin letters whose lengths do not exceed 10 symbols. It is guaranteed that the match did not end in a tie and the description contains no more than two different teams.

输出格式:

Print the name of the winning team. We remind you that in football the team that scores more goals is considered the winner.

输入输出样例

输入样例#1: 复制

1
ABC

输出样例#1: 复制

ABC

输入样例#2: 复制

5
A
ABA
ABA
A
A

输出样例#2: 复制

A

思路:因为只有两队,所以只统计一个队伍的成绩即可,总分减去该队伍的成绩就是另一个队伍的成绩。

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n;
int grade[2];
string str,name[2];
int main(){
    scanf("%d",&n);
    cin>>name[0];grade[0]++;
    for(int i=1;i<=n-1;i++) {
        cin>>str;
        if(str!=name[0])    name[1]=str;
        else grade[0]++;
    }
    if(grade[0]>n-grade[0])    cout<<name[0];
    else    cout<<name[1];
}

原文地址:https://www.cnblogs.com/cangT-Tlan/p/8442500.html

时间: 2024-10-08 16:12:07

CF43A Football的相关文章

Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

A. Vasya and Football Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red

POJ 3071 Football

Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all teams still in the tournament are placed in a list in order of increasing index. Then, the first team in the l

CodeForces 432B Football Kit(水)

Description Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color xi and the kit for away games of this team has color yi(xi ≠ 

POJ 3071 Football(简单 概率DP)

Football 原文链接:http://blog.csdn.net/xuechelingxiao/article/details/38520105 大意:2^n 个球队进行单场淘汰赛,每两只球队之间比赛会有胜负的概率,问最后谁夺冠的概率最大. 思路:简单的概率DP问题,主要是怎么处理哪两个球队比赛的问题. DP方程为 dp[i][j] = ∑(dp[i-1][j]*dp[i-1][k]*p[j][k]); //dp[i][j]表示第 i 轮的时候,第 j 支队伍赢的概率.. 对于其中位运算,可

Football

Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2882   Accepted: 1466 Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, …, 2n. In each round of the tournament, all teams still in the tourname

432B - Football Kit

解题思路: 暴力绝对TLE 一个队伍穿主场球衣的次数 = 这个队伍的客场球衣颜色与其他队主场球衣颜色起冲突的次数 + (n - 1) #include <stdio.h> #include <string.h> #include <iostream> using namespace std; const int MAXSIZE = 100; const int INF = 0x3f3f3f3f; int a[100001], b[100001], c[100001],

HDU 4924 Football Manager(状压DP)

题目连接 : http://acm.hdu.edu.cn/showproblem.php?pid=4924 题意 : n(<=20)个人选出11个人作为首发组成a-b-c阵容,每个人都有自己擅长的位置,并且每个人和其他人会有单向的厌恶和喜欢关系,每个人对于自己擅长的位置都有两个值CA和PA,有喜欢或者厌恶关系的两个人在一起也会影响整个首发的CA总值,要求选出一套阵容使得CA最大,或者CA一样的情况下PA最大. 思路 : 状压搞,dp[s]s的二进制表示20个人中选了那几个人,然后规定选进来的顺序

UVa 10194 - Football (aka Soccer)

题目:给你一些球队的比赛记录,对球队的成绩进行排序. 分析:模拟.按照题意模拟即可. 排序优先级:1.分数高 ,2.胜场多,3.净胜球多,4.进球多,5.比赛场次少,6.队名字典序. 注意:队名大小写不敏感,即大小写认为是相同的. #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> using namesp

湖南省第十三届大学生计算机程序设计竞赛 Football Training Camp 贪心

2007: Football Training Camp[原创-转载请说明] Submit Page   Summary   Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 228     Solved: 30 Description 在一次足球联合训练中一共有n支队伍相互进行了若干场比赛. 对于每场比赛,赢了的队伍得3分,输了的队伍不得分,如果为平局则两支队伍各得1分. Input 输入包含不超过1000组数据. 每组数据的第