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. POJ 1275-Cashier Employment(差分约束系统)

    题目地址:id=1275">POJ 1275 题意: 给出一个超市24小时各须要R[i]个雇员工作,有N个雇员能够雇佣.他们開始工作时间分别为A[i],求须要的最少的雇员人数. 思路: ...

  2. java程序计算数独游戏

    兴趣来了,写了个简单的数独游戏计算程序,未做算法优化. 通过文件来输入一个二维数组,9行,每行9个数组,数独游戏中需要填空的地方用0来表示.结果也是打印二维数组. import java.io.Fil ...

  3. 再说rocketmq消息存储

    两篇精彩的文章: <RocketMQ源码 — 三. Producer消息发送过程> <RocketMQ源码解析:Message存储> rocketmq通过netty获取到消息请 ...

  4. linux经常使用文字处理命令总结

    linux grep命令 作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正則表達式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressio ...

  5. sqlite developer注册码

    sqlite developer注册码网上没有找到,只有通过注册表,删除继续使用,删除注册表中 HKEY_CURRENT_USER\SharpPlus\SqliteDev.

  6. CEdit自动换行和状态栏添加

    CEdit自动换行在对话框的属性中是可以直接设置的. Auto HScroll设置为False Auto VScroll设置为True Mulitline设置为True Want Return设置为T ...

  7. 多媒体封装格式详解---MP4

    MP4文件格式详解——结构概述 http://blog.csdn.net/pirateleo/article/details/7061452 一.基本概念 1. 文件,由许多Box和FullBox组成 ...

  8. 【转】java中抽象类与接口的区别

    转自:http://blog.chinaunix.net/uid-20586655-id-215667.html 含有abstract修饰符的class 即为抽象类,abstract类不能创建实例对象 ...

  9. winfrom 底层类 验证码

    效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzgxNjcwOQ==/font/5a6L5L2T/fontsize/400/fill/I ...

  10. COSMOSBOX手遊制作手册(Word备份)

    20140712版 版本号 Version 日期 Date 作者 Author 变更主要原因描述 Brief Description 1.0 2014-4-26 陈霈霖 初稿 2.0 1. 前言 本手 ...