思路:阅读题....读懂题目之后就是结构体排个序
#include<bits\stdc++.h>
using namespace std;
struct Node
{
int i,j,d;
}nodes[805*806];
bool cmp(Node a,Node b)
{
return a.d>b.d;
}
int ans[805];
int main()
{
memset(ans,-1,sizeof(ans));
int n;
int pos = 0;
scanf("%d",&n);
for(int i = 2;i<=n*2;i++)
for(int j = 1;j<i;j++)
{
scanf("%d",&nodes[pos].d);
nodes[pos].i=i;
nodes[pos++].j=j;
}
sort(nodes,nodes+pos,cmp);
for(int i = 0;i<pos;i++)
if(ans[nodes[i].i]==-1 && ans[nodes[i].j]==-1)
{
ans[nodes[i].i]=nodes[i].j;
ans[nodes[i].j]=nodes[i].i;
}
for(int i = 1;i<2*n;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[2*n]);
}