CF234E.Champions' League
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the autumn of this year, two Russian teams came into the group stage of the most prestigious football club competition in the world — the UEFA Champions League. Now, these teams have already started to play in the group stage and are fighting for advancing to the playoffs. In this problem we are interested in the draw stage, the process of sorting teams into groups.
The process of the draw goes as follows (the rules that are described in this problem, are somehow simplified compared to the real life). Suppose n teams will take part in the group stage (n is divisible by four). The teams should be divided into groups of four. Let's denote the number of groups as m (
). Each team has a rating — an integer characterizing the team's previous achievements. The teams are sorted by the rating's decreasing (no two teams have the same rating).
After that four "baskets" are formed, each of which will contain m teams: the first m teams with the highest rating go to the first basket, the following m teams go to the second one, and so on.
Then the following procedure repeats m - 1 times. A team is randomly taken from each basket, first from the first basket, then from the second, then from the third, and at last, from the fourth. The taken teams form another group. After that, they are removed from their baskets.
The four teams remaining in the baskets after (m - 1) such procedures are performed, form the last group.
In the real draw the random selection of teams from the basket is performed by people — as a rule, the well-known players of the past. As we have none, we will use a random number generator, which is constructed as follows. Its parameters are four positive integers x, a, b, c. Every time there is a call to the random number generator, it produces the following actions:
- calculates
; - replaces parameter x by value y (assigns
); - returns x as another random number.
Operation
means taking the remainder after division:
,
.
A random number generator will be used in the draw as follows: each time we need to randomly choose a team from the basket, it will generate a random number k. The teams that yet remain in the basket are considered numbered with consecutive integers from 0 to s - 1, in the order of decreasing rating, where s is the current size of the basket. Then a team number
is taken from the basket.
Given a list of teams and the parameters of the random number generator, determine the result of the draw.
今年秋季,两支俄罗斯球队进入了世界最高水平的足球俱乐部赛事——欧洲冠军联赛(UEFA Champions League)的小组赛阶段。目前,这两支球队已开始参加小组赛,并为争夺晋级淘汰赛资格而奋战。本题关注的是抽签阶段,即把各参赛队分入不同小组的过程。
抽签过程如下(本题所描述的规则相较于现实情况有所简化)。假设有 n 支球队参加小组赛(n 可被 4 整除),需将它们划分为每组 4 支球队的若干小组。记小组总数为 m(
)。每支球队有一个“积分”(rating)——一个整数,用于表征该队过往成绩。所有球队按积分降序排列(任意两支球队积分互不相同)。
随后,构建四个“篮子”(basket),每个篮子包含 m 支球队:积分最高的前 m 支球队进入第一个篮子,接下来的 m 支进入第二个篮子,依此类推。
接着,重复以下操作 m−1 次:依次从第一个篮子、第二个篮子、第三个篮子和第四个篮子中随机抽取一支球队;这四支被抽出的球队组成一个新的小组;然后将它们从各自所属的篮子中移除。
经过上述 m−1 轮操作后,四个篮子中各自剩余的一支球队,组成最后一个小组。
在真实抽签中,从篮子中随机选取球队的工作由人完成——通常是昔日著名球员。由于我们无人可用,故采用一个伪随机数生成器,其参数为四个正整数 x,a,b,c。每次调用该随机数生成器时,执行如下操作:
- 计算
; - 将参数 x 更新为值 y(即赋值
); - 返回新的 x 作为本次生成的随机数。
符号
表示取模运算(即除法余数):
,
。
该随机数生成器在抽签中的使用方式如下:每次需要从某个篮子中随机选取一支球队时,生成一个随机数 k;此时,篮子中尚存的球队按积分降序排列,并依次编号为 0 至 s−1(含),其中 s 为该篮子当前大小;然后选取编号为
的球队。
给定球队列表及随机数生成器的参数,请确定本次抽签的最终结果。
输入格式
The first input line contains integer n (4 ≤ n ≤ 64, n is divisible by four) — the number of teams that take part in the sorting. The second line contains four space-separated integers x, a, b, c (1 ≤ x, a, b, c ≤ 1000) — the parameters of the random number generator. Each of the following n lines describes one team. The description consists of the name of the team and its rating, separated by a single space. The name of a team consists of uppercase and lowercase English letters and has length from 1 to 20 characters. A team's rating is an integer from 0 to 1000. All teams' names are distinct. All team's ratings are also distinct.
第一行输入包含一个整数 n(4≤n≤64,且 n 能被 4 整除)—— 表示参与排序的队伍数量。
第二行包含四个用空格分隔的整数 x, a, b, c(1≤x,a,b,c≤1000)—— 随机数生成器的参数。
接下来的 n 行每行描述一支队伍。每支队伍的描述由其名称及其评分组成,二者之间以一个空格分隔。队伍名称仅由大小写英文字母构成,长度为 1 至 20 个字符。一支队伍的评分为 0 至 1000 之间的整数。所有队伍的名称互不相同,所有队伍的评分也互不相同。
输出格式
Print the way the teams must be sorted into groups. Print the groups in the order, in which they are formed in the sorting. Number the groups by consecutive uppercase English letters, starting from letter 'A'. Inside each group print the teams' names one per line, in the order of decreasing of the teams' rating. See samples for a better understanding of the output format.
输出队伍分组的方式。按分组生成的顺序输出各组。用连续的大写英文字母对组进行编号,起始字母为 'A'。在每组内部,按队伍评分降序排列,每行输出一个队伍的名称。参见样例以更好地理解输出格式。
输入输出样例
输入#1
8 1 3 1 7 Barcelona 158 Milan 90 Spartak 46 Anderlecht 48 Celtic 32 Benfica 87 Zenit 79 Malaga 16
输出#1
Group A: Barcelona Benfica Spartak Celtic Group B: Milan Zenit Anderlecht Malaga
说明/提示
In the given sample the random number generator will be executed four times:
,
,
,
.
在给定的样例中,随机数生成器将被执行四次:
,
,
,
.
输入解题思路,AI测评打分。不知道怎么写?