CF200C.Football Championship
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Any resemblance to any real championship and sport is accidental.
The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship:
- the team that kicked most balls in the enemy's goal area wins the game;
- the victory gives 3 point to the team, the draw gives 1 point and the defeat gives 0 points;
- a group consists of four teams, the teams are ranked by the results of six games: each team plays exactly once with each other team;
- the teams that get places 1 and 2 in the group stage results, go to the next stage of the championship.
In the group stage the team's place is defined by the total number of scored points: the more points, the higher the place is. If two or more teams have the same number of points, then the following criteria are used (the criteria are listed in the order of falling priority, starting from the most important one):
- the difference between the total number of scored goals and the total number of missed goals in the championship: the team with a higher value gets a higher place;
- the total number of scored goals in the championship: the team with a higher value gets a higher place;
- the lexicographical order of the name of the teams' countries: the country with the lexicographically smaller name gets a higher place.
The Berland team plays in the group where the results of 5 out of 6 games are already known. To be exact, there is the last game left. There the Berand national team plays with some other team. The coach asks you to find such score X:Y (where X is the number of goals Berland scored and Y is the number of goals the opponent scored in the game), that fulfills the following conditions:
- X > Y, that is, Berland is going to win this game;
- after the game Berland gets the 1st or the 2nd place in the group;
- if there are multiple variants, you should choose such score X:Y, where value X - Y is minimum;
- if it is still impossible to come up with one score, you should choose the score where value Y (the number of goals Berland misses) is minimum.
与任何真实锦标赛和体育项目的相似之处纯属巧合。
贝尔兰国家队参加了当地的足球锦标赛,目前正处于小组赛阶段。下面描述当地锦标赛的正式规则:
- 在对方球门区域内射入球数最多的球队赢得比赛;
- 胜利为该队获得 3 分,平局获得 1 分,失利获得 0 分;
- 每个小组由四支队伍组成;小组排名依据六场比赛的结果:每支队伍恰好与其他三支队伍各交手一次;
- 小组赛中排名前两位(即第 1 名和第 2 名)的队伍晋级锦标赛下一阶段。
在小组赛中,队伍的名次由其总积分决定:积分越高,名次越靠前。若两支或更多队伍积分相同,则按以下标准(按优先级从高到低顺序)进一步排序:
- 本届锦标赛中总进球数与总失球数之差(即净胜球数):该值越大,名次越高;
- 本届锦标赛中总进球数:该值越大,名次越高;
- 队伍所属国家名称的字典序:字典序更小的国家名对应的队伍名次更高。
贝尔兰队所在小组的六场比赛中,已有五场结果确定,仅剩最后一场比赛未进行。这场比赛正是贝尔兰国家队对阵另一支队伍。教练要求你找出一个比分 X:Y(其中 X 表示贝尔兰队的进球数,Y 表示对手的进球数),使其满足以下条件:
- X>Y,即贝尔兰队将赢得本场比赛;
- 本场比赛结束后,贝尔兰队在小组中位列第 1 名或第 2 名;
- 若存在多个满足条件的比分,则应选择使 X−Y 最小的那个比分;
- 若仍存在多个满足条件的比分,则应选择其中 Y(即贝尔兰队失球数)最小的那个比分。
输入格式
The input has five lines.
Each line describes a game as "_team_1 _team_2 _goals_1:_goals_2" (without the quotes), what means that team _team_1 played a game with team _team_2, besides, _team_1 scored _goals_1 goals and _team_2 scored _goals_2 goals. The names of teams _team_1 and _team_2 are non-empty strings, consisting of uppercase English letters, with length of no more than 20 characters; _goals_1, _goals_2 are integers from 0 to 9.
The Berland team is called "BERLAND". It is guaranteed that the Berland team and one more team played exactly 2 games and the the other teams played exactly 3 games.
输入共五行。
每行描述一场比赛,格式为“_team_1 _team_2 _goals_1:_goals_2”(不含引号),表示球队 _team_1 与球队 _team_2 进行了一场比赛,其中 _team_1 打进 _goals_1 个球,_team_2 打进 _goals_2 个球。球队名 _team_1 和 _team_2 均为非空字符串,仅由大写英文字母组成,长度不超过 20 个字符;_goals_1、_goals_2 均为 0 到 9 之间的整数。
伯兰德队(Berland team)名为 “BERLAND”。保证伯兰德队与另一支队伍恰好各进行了 2 场比赛,其余所有队伍均恰好进行了 3 场比赛。
输出格式
Print the required score in the last game as X:Y, where X is the number of goals Berland scored and Y is the number of goals the opponent scored. If the Berland team does not get the first or the second place in the group, whatever this game's score is, then print on a single line "IMPOSSIBLE" (without the quotes).
Note, that the result score can be very huge, 10:0 for example.
以 X:Y 的格式输出最后一场比赛所需的比分,其中 X 表示贝尔兰队的进球数,Y 表示对手的进球数。如果无论最后一场比赛比分为何,贝尔兰队都无法获得小组第一或第二名,则在单独一行中输出 "IMPOSSIBLE"(不带引号)。
注意,结果比分可能非常大,例如 10:0。
输入输出样例
输入#1
AERLAND DERLAND 2:1 DERLAND CERLAND 0:3 CERLAND AERLAND 0:1 AERLAND BERLAND 2:0 DERLAND BERLAND 4:0
输出#1
6:0
输入#2
AERLAND DERLAND 2:2 DERLAND CERLAND 2:3 CERLAND AERLAND 1:3 AERLAND BERLAND 2:1 DERLAND BERLAND 4:1
输出#2
IMPOSSIBLE
说明/提示
In the first sample "BERLAND" plays the last game with team "CERLAND". If Berland wins with score 6:0, the results' table looks like that in the end:
- AERLAND (points: 9, the difference between scored and missed goals: 4, scored goals: 5)
- BERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 6)
- DERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 5)
- CERLAND (points: 3, the difference between scored and missed goals: -4, scored goals: 3)
In the second sample teams "AERLAND" and "DERLAND" have already won 7 and 4 points, respectively. The Berland team wins only 3 points, which is not enough to advance to the next championship stage.
在第一个样例中,“BERLAND”队与“CERLAND”队进行最后一场比赛。若“BERLAND”以 6:0 获胜,则最终积分榜如下:
- AERLAND(积分:9,净胜球数:4,进球数:5)
- BERLAND(积分:3,净胜球数:0,进球数:6)
- DERLAND(积分:3,净胜球数:0,进球数:5)
- CERLAND(积分:3,净胜球数:-4,进球数:3)
在第二个样例中,“AERLAND”队与“DERLAND”队已分别获得 7 分和 4 分。“BERLAND”队仅能获得 3 分,不足以晋级下一届锦标赛阶段。
输入解题思路,AI测评打分。不知道怎么写?