codeforces 686B
题意:给出一个序列,只允许进行相邻的两两交换,给出使序列变为非降序列的操作方案。
思路:关键点是操作次数不限,冒泡排序。
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll num[];
int main() {
int n;
while(~scanf("%d",&n)) {
for(int i=;i<n;i++) {
cin>>num[i];
}
int temp;
for(int i=;i<n;i++) {
for(int j=;j<n-;j++) {
if(num[j]>num[j+]) {
temp=num[j+];
num[j+]=num[j];
num[j]=temp;
cout<<j+<<" "<<j+<<endl;
}
}
}
} return ;
}
codeforces 686B的更多相关文章
- CodeForces 686B Little Robber Girl's Zoo (构造冒泡排序)
题意:给定一排列,让你通过一个区间交换的方式,完成排序. 析:这个题说了,最多不能超过20000次,而 n 最大才100,那么冒泡排序复杂度为 n * n,才10000,肯定是可以的,所以我们就模拟冒 ...
- codeforces 686B B. Little Robber Girl's Zoo(水题)
题目链接: B. Little Robber Girl's Zoo //#include <bits/stdc++.h> #include <vector> #include ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- 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 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- Nginx之红黑树
/* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGX_RBTREE_H_INCLUDED_ #de ...
- Git--Bug解决篇
Git--公司bug解决篇 作为程序员,我们时常遇到这样的场景,公司的产品上线了,程序员们美滋滋的开始开发新功能希望得到更多的流量.这时候,公司上线的产品发生了很严重的bug,可是我们已经在这个bug ...
- freemarker在xml文件中遍历list数据
delete from pub_channelpackage where channelcode = :channelcode and channeltype = :channeltype ...
- cpu使用率高问题
然后:
- iOS Masonry 抗压缩 抗拉伸
约束优先级: 在Autolayout中每个约束都有一个优先级, 优先级的范围是1 ~ 1000.创建一个约束,默认的优先级是最高的1000 Content Hugging Priority: 该优先级 ...
- mapreduce学习资料
http://blog.csdn.net/tianjun2012/article/category/6794531 http://blog.csdn.net/tianjun2012/article/d ...
- IE8 兼容 getElementsByClassName
IE8以下版本没有getElementsByClassName这个方法,以下是兼容写法 function ieGetElementsByClassName() { if (!document.getE ...
- Android ijkplayer 强大的视频播放器框架教程 -- 导入demo运行(一)
首先介绍下这个开源项目,这个开源项目是BiliBli 开源的,首先感谢他们的团队. 这是开源的地址: https://github.com/Bilibili/ijkplayer 首先我为什么要选这个, ...
- RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter的解决方案(转)
转自:RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter的解 ...
- python 面试题 删除字符串a中包含的字符串b