codeforces -1214 E
题目https://codeforces.com/problemset/problem/1214/E
就是得知奇数之间不产生影响,先造出一条链,再用偶数往里插就行。链要di从大到小排个序呀!!
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#define maxn 202000
using namespace std;
struct Node {
int ans;
int pos;
}list[maxn];
bool bml(Node a, Node b) {
return a.ans > b.ans;
}
vector<int>ans;
int main() {
int n; scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &list[i].ans);
list[i].pos = i * 2 - 1;//奇数
}
sort(list + 1, list + 1 + n, bml);
for (int i = 1; i < n; i++) {
printf("%d %d\n", list[i].pos, list[i + 1].pos);
ans.push_back(list[i].pos);
}
ans.push_back(list[n].pos); for (int i = 1; i <= n; i++) {
int t = list[i].ans + i - 2; printf("%d %d\n", ans[t], list[i].pos + 1);
if (ans.size()-1 == t) ans.push_back(list[i].pos + 1);
}
return 0;
}
codeforces -1214 E的更多相关文章
- Codeforces 1214 F G H 补题记录
翻开以前打的 #583,水平不够场上只过了五题.最近来补一下题,来记录我sb的调试过程. 估计我这个水平现场也过不了,因为前面的题已经zz调了好久-- F:就是给你环上一些点,两两配对求距离最小值. ...
- codeforces 1214
D 比赛的时候居然看漏了条件... 若在(x, y)格子,那么只能移动到(x+1, y)或(x, y+1) 这样的话就好做了,直接dp,然后统计每一种路径长度经过的点数. #include<cs ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- MyBatis动态批量插入、更新Mysql数据库的通用实现方案
一.业务背景 由于需要从A数据库提取大量数据同步到B系统,采用了tomikos+jta进行分布式事务管理,先将系统数据源切换到数据提供方,将需要同步的数据查询出来,然后再将系统数据源切换到数据接收方, ...
- 2019-2-3-VisualStudio-扩展开发-添加输出窗口
title author date CreateTime categories VisualStudio 扩展开发 添加输出窗口 lindexi 2019-02-03 11:41:40 +0800 2 ...
- python 字典创建
- python 浮点型(float)
- 荣获“5G MEC优秀商用案例奖”,阿里云边缘计算发力新零售
4月24日,在中国联通合作伙伴大会的 “5G MEC(Mobile Edge Computing,移动边缘计算)边缘云赋能行业数字化转型”分论坛上,阿里云“基于5G边缘计算的新零售应用案例”荣获201 ...
- python 直接if判断和is not None的区别
tmpName = ''if tmpName: print tmpName #没有输出if tmpName is not None: print tmpName #有输出,是空行
- AUTOSSH设置ssh隧道,实现反向代理访问内网主机
内网主机上配置: autossh -M -CNR :localhost: ubuntu@123.207.121.121 可以实现将访问主机123.207.121.121的1234端口的数据,通过隧道转 ...
- python命令之m参数 局域网传输
在命令行中使用python时,python支持在其后面添加可选参数. python命令的可选参数有很多,例如:使用可选参数h可以查询python的帮助信息: 可选参数m 下面我们来说说python命令 ...
- [kuangbin带你飞]专题九 连通图D - Network POJ - 3694
这道题其实也非常简单,只是在求割边及其个数的情况下,每次往里面加入新的边,并再次计算割边的个数. 我们用tarjan可以求出原图的桥以及个数,当然我们不能暴力加边,然后求解,那么如何求呢??? 其实非 ...
- H3C 单播与广播