CF579B.Finding Team Member

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There is a programing contest named SnakeUp, 2n2n 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 AA and BB 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 2n2n lines in the input.

The first line contains an integer nn ( 1<=n<=4001<=n<=400 ) — the number of teams to be formed.

The ii -th line ( i>1 ) contains i1i-1 numbers ai1a_{i1} , ai2a_{i2} , ... , ai(i1)a_{i(i-1)} . Here aija_{ij} ( 1<=aij<=1061<=a_{ij}<=10^{6} , all aija_{ij} are distinct) denotes the strength of a team consisting of person ii and person jj (people are numbered starting from 11 .)

输出格式

Output a line containing 2n2n numbers. The ii -th number should represent the number of teammate of ii -th person.

输入输出样例

  • 输入#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 11 and 22 will be teammates and so do contestant 33 and 44 , so the teammate of contestant 11 , 22 , 33 , 44 will be 22 , 11 , 44 , 33 respectively.

首页