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