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. Mybatis数据库操作的返回值

    mybatis配置 <!-- 配置mybatis --> <bean id="sqlSessionFactory" class="org.mybatis ...

  2. http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html

    http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html

  3. R简易安装

    post={"title":"my Blog post","content":"Here's my blog post" ...

  4. 【java】Could not find or load main class

    https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean A comm ...

  5. 使用JTextArea示例

    相对于JLabel显示提示文字,JTextArea有一个先天优势:文字可以拷贝出来.经过下面设置它也能在外观上和JLabel一致. 代码如下: JTextArea txtArea=new JTextA ...

  6. 创建CSS3警示框渐变动画

    来源:GBin1.com 在线演示   在线下载 现代的网页设计技术已经允许开发人员在大多数浏览器中快速实现所支持的动画,其中消息警示是非常普遍的.由于默认的JavaScript警示框往往设计不佳和过 ...

  7. Eclipse中,快捷键使用总结

    (1)Alt+shift+L:new ReadItem().readItems(file);的返回对象是Map<String,String>用这个快捷键有两个效果示例1:输入光标停在new ...

  8. 【MVC5】使用权限+角色

    1.在Ticket中设置用户角色 在权限的Ticket中设置用户的角色(这里是逗号分割). List<string> roles = new List<string>(); i ...

  9. nodejs之SVG转图片下载方案

    本文介绍在nodejs基础上.怎样实现将svg转为png并下载的功能. 所需Webkit和node module简单介绍: phantomjs:一个基于WebKit的server端JavaScript ...

  10. taro 请求函数封装

    1.项目目录 2.代码 app/src/service/api.js import Taro from '@tarojs/taro' import { HTTP_STATUS } from '../c ...