B. Finding Team Member
                                                                              time limit per test

2 seconds

                                                                              memory limit per test

256 megabytes

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 are 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 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.

Sample test(s)
Input
2
6
1 2
3 4 5
Output
2 1 4 3

题解:没脑子的找就是了
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define maxn 800+6
vector< pair<int ,pair<int ,int > > > mp;
set<int >s;
int ans[maxn];
int main()
{ int n,x;
cin>>n;
for(int i=;i<=*n;i++)
{
for(int j=;j<i;j++)
{
cin>>x;
mp.push_back(make_pair(x,make_pair(i,j)));
}
}
sort(mp.begin(),mp.end());
int k=mp.size();
for(int i=k-;i>=;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(int i=;i<=*n;i++)
cout<<ans[i]<<" ";
return ;
}

代码

Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] B. Finding Team Member 排序的更多相关文章

  1. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] C. Weakness and Poorness 三分 dp

    C. Weakness and Poorness Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  2. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. "Or" Game 线段树贪心

    B. "Or" Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/578 ...

  3. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. "Or" Game

    题目链接:http://codeforces.com/contest/578/problem/B 题目大意:现在有n个数,你可以对其进行k此操作,每次操作可以选择其中的任意一个数对其进行乘以x的操作. ...

  4. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] E. Weakness and Poorness 三分

    E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] A. Raising Bacteria【位运算/二进制拆分/细胞繁殖,每天倍增】

    A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] D 数学+(前缀 后缀 预处理)

    D. "Or" Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] E 三分+连续子序列的和的绝对值的最大值

    E. Weakness and Poorness time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  8. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] C A Weakness and Poorness (三分)

    显然f(x)是个凹函数,三分即可,计算方案的时候dp一下.eps取大了会挂精度,指定循环次数才是正解. #include<bits/stdc++.h> using namespace st ...

  9. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B "Or" Game (贪心)

    首先应该保证二进制最高位尽量高,而位数最高的数乘x以后位数任然是最高的,所以一定一个数是连续k次乘x. 当出现多个最高位的相同的数就枚举一下,先预处理一下前缀后缀即可. #include<bit ...

  10. Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A A Problem about Polyline(数学)

    题目中给出的函数具有周期性,总可以移动到第一个周期内,当然,a<b则无解. 假设移动后在上升的那段,则有a-2*x*n=b,注意限制条件x≥b,n是整数,则n≤(a-b)/(2*b).满足条件的 ...

随机推荐

  1. 第1节 hive安装:2、3、4、5、(多看几遍)

    第1节 hive安装: 2.数据仓库的基本概念: 3.hive的基本介绍: 4.hive的基本架构以及与hadoop的关系以及RDBMS的对比等 5.hive的安装之(使用mysql作为元数据信息存储 ...

  2. ffmpeg裁剪

    http://it6655.com/2012/09/ffmpeg-9-2-html 1 configure参数 1 通用选项 在linux下进入终端,找到ffmpeg解压位置,输入如下命令: root ...

  3. qrcode.js扫码邀请

    //js引用部分<script src="../qrcode.js" type="text/javascript"></script> ...

  4. python在linux下的使用

    1.查看python(解释器)的版本(什么版本的解释器支持哪一版版的语言标准) 一般在linux上已经预装了python,只要在Bash Shell中输入python,即可看到如下版本信息: 按Ctr ...

  5. 笔试算法题(58):二分查找树性能分析(Binary Search Tree Performance Analysis)

    议题:二分查找树性能分析(Binary Search Tree Performance Analysis) 分析: 二叉搜索树(Binary Search Tree,BST)是一颗典型的二叉树,同时任 ...

  6. 零基础入门学习Python(29)--文件:一个任务

    知识点 一个任务:将文件(record.txt)中的数据进行分割并按照以下规律保存起来: #record.txt文件内容: 小客服:小甲鱼,今天有客户问你有没有女朋友? 小甲鱼:咦?? 小客服:我跟她 ...

  7. 零基础入门学习Python(24)--递归:汉诺塔

    知识点 这节课主要讲解用递归的方法,实现汉诺塔的解答 对于游戏的玩法,我们可以简单分解为三个步骤: 1) 将前63个盘子从X移动到Y上. 2) 将最底下的第64个盘子从X移动到Z上. 3) 将Y上的6 ...

  8. Courses on Turbulence

    Courses on Turbulence Table of Contents 1. Lecture 1.1. UIUC Renewable energy and turbulent environm ...

  9. 全文搜索(AC-1)-互联网信息过载问题

    什么是信息过载? 信息检索技术是什么? 信息过滤技术是什么?

  10. 582. Kill Process

    Problem statement: Given n processes, each process has a unique PID (process id) and its PPID (paren ...