Codeforces Round #320 (Div. 2) [Bayan Thanks-round] B. Finding Team Member sort

Source: Internet
Author: User

B. Finding Team Member                         ,         &NB Sp                          ,         &NB Sp       time limit per test                                               ,         &NB Sp                     2 seconds          &NB Sp                          ,         &NB Sp                               memory limit Per test                                nbsp;                          ,         &NB Sp         256 Megabytes

There is a programing contest named Snakeup, 2n people want to compete for it. In order to attend the contest, people need to form teams of exactly, people. You is given the strength of each possible combination of the people. All the values of the strengths is 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 would form a team with highest strength possible by choosing a teammate from ones who was willing to Be a teammate with him/her. More formally, both people a and B may form a team if each of the them are the best possible teammate (among the contestants that remain unpaired) for the other one.

Can you determine who would be are each person ' s teammate?

Input

There is 2n lines in the input.

The first line contains a 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 Sub class= "Lower-index" > ij ≤106, all a ij is distinct) denotes the strength of a team consisting of person i and Person J (People is numbered starting from 1.)

Output

Output a line containing 2n numbers. The i-th number should represent the number of teammate of I-th person.

Sample Test (s) Input
2
6
0 S
3 4 5
Output
2 1 4 3


The puzzle: Just look for the brain.
#include <cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<vector>#include<Set>using namespacestd;#defineMAXN 800+6Vector< pair<int,pair<int,int> > >MP;Set<int>s;intANS[MAXN];intMain () {intn,x; CIN>>N;  for(intI=2; i<=2*n;i++)    {         for(intj=1; j<i;j++) {cin>>x;        Mp.push_back (Make_pair (X,make_pair (I,J)));    }} sort (Mp.begin (), Mp.end ()); intk=mp.size ();  for(inti=k-1; i>=0; i--)    {        if(S.count (mp[i].second.first) | | S.count (Mp[i].second.second))Continue;        S.insert (Mp[i].second.first);        S.insert (Mp[i].second.second); Ans[mp[i].second.first]=Mp[i].second.second; Ans[mp[i].second.second]=Mp[i].second.first; }     for(intI=1; i<=2*n;i++) cout<<ans[i]<<" "; return 0;}
Code

Codeforces Round #320 (Div. 2) [Bayan Thanks-round] B. Finding Team Member sort

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.