CF1089A.Alice the Fan

提高+/省选-

通过率:0%

时间限制:1.50s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice is a big fan of volleyball and especially of the very strong "Team A".

Volleyball match consists of up to five sets. During each set teams score one point for winning a ball. The first four sets are played until one of the teams scores at least 25 points and the fifth set is played until one of the teams scores at least 15 points. Moreover, if one of the teams scores 25 (or 15 in the fifth set) points while the other team scores 24 (or 14 in the fifth set), the set is played until the absolute difference between teams' points becomes two. The match ends when one of the teams wins three sets. The match score is the number of sets won by each team.

Alice found a book containing all the results of all matches played by "Team A". The book is old, and some parts of the book became unreadable. Alice can not read the information on how many sets each of the teams won, she can not read the information on how many points each of the teams scored in each set, she even does not know the number of sets played in a match. The only information she has is the total number of points scored by each of the teams in all the sets during a single match.

Alice wonders what is the best match score "Team A" could achieve in each of the matches. The bigger is the difference between the number of sets won by "Team A" and their opponent, the better is the match score. Find the best match score or conclude that no match could end like that. If there is a solution, then find any possible score for each set that results in the best match score.

Alice 是排球的超级粉丝,尤其钟爱实力超强的“队伍 A”。

一场排球比赛最多包含五局。每局中,获胜一方赢得一个积分。前四局采用 25 分制(即先得至少 25 分且领先对手至少 2 分者胜),第五局采用 15 分制(即先得至少 15 分且领先对手至少 2 分者胜)。此外,若某队在前四局中率先得到 25 分而另一队恰好得到 24 分(或在第五局中率先得到 15 分而另一队恰好得到 14 分),则该局需继续进行,直至双方分差达到 2 分为止。当某支队伍赢得三局时,整场比赛结束。比赛比分定义为双方各自赢得的局数。

Alice 找到一本记载了“队伍 A”所有历史比赛结果的旧书。但该书年代久远,部分内容已无法辨认。Alice 无法读取每场比赛中双方各自赢得的局数,也无法读取每局中双方各自的得分,甚至无法确定某场比赛总共进行了多少局。她唯一掌握的信息是:在单场比赛中,双方在整个比赛所有局中各自获得的总积分。

Alice 想知道:对于每场比赛,“队伍 A”所能取得的最优比赛比分是什么?此处,“最优”指“队伍 A”赢得的局数与其对手赢得的局数之差尽可能大。请找出这一最优比赛比分;若不存在满足条件的比赛进程,则判定为无解。若存在解,请给出任意一种满足该最优比赛比分的、各局具体比分的方案。

输入格式

The first line contains a single integer mm (1≤m≤50 0001 \le m \le 50\,000) — the number of matches found by Alice in the book.

Each of the next mm lines contains two integers aa and bb (0≤a,b≤2000 \le a, b \le 200) — the number of points scored by "Team A" and the number of points scored by their opponents respectively.

第一行包含一个整数 mm(1≤m≤50 0001 \le m \le 50\,000)—— 表示爱丽丝在书中找到的比赛场数。

接下来的 mm 行中,每行包含两个整数 aa 和 bb(0≤a,b≤2000 \le a, b \le 200)—— 分别表示“队伍 A”及其对手所得的分数。

输出格式

Output the solution for every match in the same order as they are given in the input. If the teams could not score aa and bb points respectively, output "Impossible".

Otherwise, output the match score formatted as "xx:yy", where xx is the number of sets won by "Team A" and yy is the number of sets won by their opponent.

The next line should contain the set scores in the order they were played. Each set score should be printed in the same format as the match score, with xx being the number of points scored by "Team A" in this set, and yy being the number of points scored by their opponent.

按输入中给出的比赛顺序,依次输出每场比赛的解。如果两支队伍分别无法得到 aa 分和 bb 分,则输出 "Impossible"。

否则,输出比赛比分,格式为 "xx:yy",其中 xx 表示“队 A”赢得的局数,yy 表示其对手赢得的局数。

下一行应按实际进行顺序输出各局的比分。每局比分均采用与比赛比分相同的格式,即 "xx:yy",其中 xx 表示“队 A”在该局中获得的分数,yy 表示其对手在该局中获得的分数。

输入输出样例

  • 输入#1

    6
    75 0
    90 90
    20 0
    0 75
    78 50
    80 100

    输出#1

    3:0
    25:0 25:0 25:0
    3:1
    25:22 25:22 15:25 25:21
    Impossible
    0:3
    0:25 0:25 0:25
    3:0
    25:11 28:26 25:13
    3:2
    25:17 0:25 25:22 15:25 15:11

输入解题思路,AI测评打分。不知道怎么写?

首页