CF579B.Finding Team Member
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a programing contest named SnakeUp, 2_n_ people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.
Every contestant hopes that he can find a teammate so that their team’s strength is as high as possible. That is, a contestant will form a team with highest strength possible by choosing a teammate from ones who are willing to be a teammate with him/her. More formally, two people A and B may form a team if each of them is the best possible teammate (among the contestants that remain unpaired) for the other one.
Can you determine who will be each person’s teammate?
有一场名为“SnakeUp”的编程竞赛,共有 2n 人希望参赛。为了参加该竞赛,选手必须恰好两人一组组成队伍。现给出每一对可能的两人组合所对应的队伍实力值,且所有实力值互不相同。
每位选手都希望找到一名队友,使得自己所在队伍的实力尽可能高。也就是说,每位选手将从当前尚未配对、且愿意与他/她组队的选手中,选择能使其队伍实力最大化的队友。更严格地定义如下:两个人 A 和 B 可以组成一队,当且仅当在所有尚未配对的选手中,A 是 B 最佳(即能组成最高实力队伍)的潜在队友,且 B 同样是 A 最佳的潜在队友。
你能确定每个人的队友是谁吗?
输入格式
There are 2_n_ lines in the input.
The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed.
The i-th line (i > 1) contains i - 1 numbers _a__i_1, _a__i_2, ... , a__i(i - 1). Here a__ij (1 ≤ a__ij ≤ 106, all a__ij are distinct) denotes the strength of a team consisting of person i and person j (people are numbered starting from 1.)
输入共有 2n 行。
第一行包含一个整数 n(1≤n≤400)—— 表示需要组成的队伍数量。
第 i 行(i>1)包含 i−1 个数字 ai1,ai2,…,ai(i−1)。其中 aij(1≤aij≤106,所有 aij 互不相同)表示由第 i 个人与第 j 个人(人从 1 开始编号)组成的队伍的强度。
输出格式
Output a line containing 2_n_ numbers. The i-th number should represent the number of teammate of i-th person.
输出一行,包含 2n 个数字。其中第 i 个数字应表示第 i 个人的队友数量。
输入输出样例
输入#1
2 6 1 2 3 4 5
输出#1
2 1 4 3
输入#2
3 487060 3831 161856 845957 794650 976977 83847 50566 691206 498447 698377 156232 59015 382455 626960
输出#2
6 5 4 3 2 1
说明/提示
In the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
在第一个样例中,参赛者 1 和 2 将成为队友,参赛者 3 和 4 也将成为队友,因此参赛者 1、2、3、4 的队友分别为 2、1、4、3。
输入解题思路,AI测评打分。不知道怎么写?