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?

Input

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

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

Examples
input
2
6
1 2
3 4 5
output
2 1 4 3
input
3
487060
3831 161856
845957 794650 976977
83847 50566 691206 498447
698377 156232 59015 382455 626960
output
6 5 4 3 2 1
#include<string.h>
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct Node
{
int a,b;
int wei;
}team[];
bool cmp(Node n1,Node n2){
return n1.wei>n2.wei;
}
int main(){
int n;
int ans[];
int t=;
scanf("%d",&n);
for(int i=;i<*n+;i++){
ans[i]=-;
}
for(int i=;i<=*n;i++){
for(int j=;j<i;j++){
scanf("%d",&team[t].wei);
team[t].a=j;
team[t].b=i;
t++;
}
}
sort(team,team+t,cmp);
for(int i=;i<t;i++){
if(ans[team[i].a]<&&ans[team[i].b]<){
ans[team[i].a]=team[i].b;
ans[team[i].b]=team[i].a; }
}
int flag=;
for(int i=;i<=n*;i++){
if(flag) printf(" ");
printf("%d",ans[i] );
flag=;
}
printf("\n");
return ;
}

水题,但是要注意题目给出到是n支队伍,而不是n个人,开始到时候wa了多次,因为没有注意到这一点。

CodeForces 579b的更多相关文章

  1. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. sql server阻塞(block)处理

    sp_who2 ACTIVE --从下图可知spid = 65进程被76阻塞 --或 * FROM sys.sysprocesses WHERE blocked <> 0 ) --查看阻塞 ...

  2. PL/SQL如何远程连接ORACLE

    如何在没有装ORACLE的电脑上用PLSQL远程连接ORACLE 下载instantclient,我的是WIN7,下载的是instantclient-basiclite-nt-12.1.0.1.0.z ...

  3. TestNG 一、 概论

    一. 概论         TestNG,即Testing, NextGeneration,下一代测试技术,是一套根据JUnit 和NUnit思想而构建的利用注释来强化测试功能的一个测试框架,即可以用 ...

  4. ScrollView 和 ListView 冲突解决方案

    网上说了很多阿,什么linearLayout 实现listView 什么的.还设置高什么的. 其实,你们可能忘记了,如果出现 ScrollView 和 ListView 同时出现,那就是设计错误了. ...

  5. HDU-2665-Kth number(划分树)

    Problem Description Give you a sequence and ask you the kth big number of a inteval.   Input The fir ...

  6. PHPMailer_v5.1 使用[转]

    <?php /* * email 报警,主要检查服务器数据库是否还能正常连接 */ require("../common/config.php"); include(&quo ...

  7. iOS sort array 数组排序里面的对象

    一:如下代码 //对数据按次数排序 NSArray *sortArrays = [pinCiDataArray sortedArrayUsingComparator:^NSComparisonResu ...

  8. 使用js+Ajax请求API接口数据-带请求头方式

    C# http请求带请求头部分 先上代码: <script type="text/javascript"> function zLoginCheck() { var A ...

  9. c++对象模型介绍

    http://www.cnblogs.com/skynet/p/3343726.html

  10. 测试的一些基本概念知识(TCP )

    一.TCP报头部中的SYN.FIN.ACK: ACK : TCP协议规定,只有ACK=1时有效,也规定连接建立后所有发送的报文的ACK必须为1. SYN(SYNchronization) : 在连接建 ...