CF659B.Qualifying Contest
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and it was attended by n Berland students. There were at least two schoolboys participating from each of the m regions of Berland. The result of each of the participants of the qualifying competition is an integer score from 0 to 800 inclusive.
The team of each region is formed from two such members of the qualifying competition of the region, that none of them can be replaced by a schoolboy of the same region, not included in the team and who received a greater number of points. There may be a situation where a team of some region can not be formed uniquely, that is, there is more than one school team that meets the properties described above. In this case, the region needs to undertake an additional contest. The two teams in the region are considered to be different if there is at least one schoolboy who is included in one team and is not included in the other team. It is guaranteed that for each region at least two its representatives participated in the qualifying contest.
Your task is, given the results of the qualifying competition, to identify the team from each region, or to announce that in this region its formation requires additional contests.
很快,贝尔兰将举办一场校级编程奥林匹克竞赛。来自贝尔兰的 m 个地区,每个地区都将派出一支由两人组成的队伍参赛。为组建各支队伍而举办的资格赛已结束,共有 n 名贝尔兰学生参加了该资格赛。贝尔兰的 m 个地区中,每个地区至少有两名学生参加了资格赛。每位资格赛参赛者的成绩是一个介于 0 到 800(含端点)之间的整数分数。
每个地区的代表队由该地区参加资格赛的两名学生组成,且需满足如下条件:该队中任意一名成员都不能被同地区另一名未入选该队、但得分更高的学生所替代。在某些情况下,某个地区的代表队可能无法被唯一确定,即存在不止一支满足上述条件的校队。此时,该地区必须另行组织一场附加赛。若两支队伍中至少有一名学生只属于其中一支队伍而不属于另一支,则认为这两支队伍互不相同。题目保证:每个地区至少有两名代表参加了资格赛。
你的任务是:根据资格赛的成绩,为每个地区确定其代表队;若某地区无法唯一确定代表队,则宣布该地区需要举行附加赛。
输入格式
The first line of the input contains two integers n and m (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 10 000, n ≥ 2_m_) — the number of participants of the qualifying contest and the number of regions in Berland.
Next n lines contain the description of the participants of the qualifying contest in the following format: Surname (a string of length from 1 to 10 characters and consisting of large and small English letters), region number (integer from 1 to m) and the number of points scored by the participant (integer from 0 to 800, inclusive).
It is guaranteed that all surnames of all the participants are distinct and at least two people participated from each of the m regions. The surnames that only differ in letter cases, should be considered distinct.
输入的第一行包含两个整数 n 和 m(2 ≤ n ≤ 100000,1 ≤ m ≤ 10000,且 n ≥ 2m)—— 分别表示资格赛的参赛人数以及 Berland 国的地区数量。
接下来的 n 行描述资格赛的参赛者,每行格式如下:姓氏(一个长度为 1 至 10 的字符串,仅由大小写英文字母组成)、地区编号(取值范围为 1 至 m 的整数)以及该参赛者获得的分数(取值范围为 0 至 800 的整数,含端点)。
保证所有参赛者的姓氏互不相同,且每个地区至少有两人参赛。仅大小写不同的姓氏被视为不同姓氏。
输出格式
Print m lines. On the i-th line print the team of the i-th region — the surnames of the two team members in an arbitrary order, or a single character "?" (without the quotes) if you need to spend further qualifying contests in the region.
输出 m 行。在第 i 行输出第 i 个赛区的队伍——以任意顺序输出两名队员的姓氏,或者若该赛区需额外举行资格赛,则输出单个字符 ?(不带引号)。
输入输出样例
输入#1
5 2 Ivanov 1 763 Andreev 2 800 Petrov 1 595 Sidorov 1 790 Semenov 2 503
输出#1
Sidorov Ivanov Andreev Semenov
输入#2
5 2 Ivanov 1 800 Andreev 2 763 Petrov 1 800 Sidorov 1 800 Semenov 2 503
输出#2
? Andreev Semenov
说明/提示
In the first sample region teams are uniquely determined.
In the second sample the team from region 2 is uniquely determined and the team from region 1 can have three teams: "Petrov"-"Sidorov", "Ivanov"-"Sidorov", "Ivanov" -"Petrov", so it is impossible to determine a team uniquely.
在第一个样例区域中,队伍是唯一确定的。
在第二个样例中,来自区域 2 的队伍是唯一确定的,而来自区域 1 的队伍可能有三种组合:“Petrov”–“Sidorov”、“Ivanov”–“Sidorov”、“Ivanov”–“Petrov”,因此无法唯一确定一支队伍。
输入解题思路,AI测评打分。不知道怎么写?