b. finding team member
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
there is a programing contest named snakeup, 2n 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 aredistinct.
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?
there are 2n 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 ai1, ai2,
... , ai(i - 1).
here aij (1 ≤ aij ≤ 106,
all aij are
distinct) denotes the strength of a team consisting of person i and person j (people
are numbered starting from 1.)
output a line containing 2n numbers. the i-th
number should represent the number of teammate of i-th person.
sample test(s)
note
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
be2, 1, 4, 3 respectively.
題目大意:
就是給你 2*n 個人,給一個下三角矩陣,要求選2n組人,每組兩人,arr[i][j]表示i和j在一起的分數,每次選的結果都是目前可能的最大值,
(一個人隻能在一組裡)
解題思路:
暴力做就行隻是要考慮一下數組的大小,我一般為了友善起見都把數組開的比較大,
1000*1000的就行,其實805*805應該也行。
上代碼: