题意:给出一个序列,只允许进行相邻的两两交换,给出使序列变为非降序列的操作方案。

思路:关键点是操作次数不限,冒泡排序。

#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的更多相关文章

  1. CodeForces 686B Little Robber Girl's Zoo (构造冒泡排序)

    题意:给定一排列,让你通过一个区间交换的方式,完成排序. 析:这个题说了,最多不能超过20000次,而 n 最大才100,那么冒泡排序复杂度为 n * n,才10000,肯定是可以的,所以我们就模拟冒 ...

  2. codeforces 686B B. Little Robber Girl's Zoo(水题)

    题目链接: B. Little Robber Girl's Zoo //#include <bits/stdc++.h> #include <vector> #include ...

  3. Codeforces Round #359 div2

    Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. kernel feature collection

    Fault injection http://lwn.net/Articles/209257/ The framework can cause memory allocation failures a ...

  2. SWERC13 Decoding the Hallway

    找规律 S+1 = S +'L'+~rev(S) Problem D Decoding the Hallway Problem D Edward is now 21 years old. He has ...

  3. ubuntu16.04上安装深度学习基本框架caffe2 pytorch tensorflow opencv

    anaconda3.5.2.0----python3.6: conda  install   tensorflow-gpu  -y --prefix  /media/wkr/diskHgst/ubun ...

  4. setpgid()

    #include<unistd.h> int setpgid(pid_t pid,pid_t pgid); 函数作用:将pid进程的进程组ID设置成pgid,创建一个新进程组或加入一个已存 ...

  5. junit测试时报No runnable methods错误的解决方法

    1.因为你@Test时import的是@org.testng.annotations.Test所以会报错 解决方法:改为import org.junit.Test;就可以了

  6. [转]Ubuntu Server命令行更换软件源

    sucd /etc/aptwget http://mirrors.163.com/.help/sources.list.lucidmv sources.list sources.list.backup ...

  7. sublime使用技巧(4)-- 其他技巧【持续更新】

    命令模式 1.切换语言格式,ctrl + shirt + p 2.简化操作 ctrl + shirt + p 输入 snippet:function 自动生成function的基本结构!tab键 移动 ...

  8. linux kernel的cmdline參数解析原理分析

    利用工作之便,今天研究了kernel下cmdline參数解析过程.记录在此.与大家共享.转载请注明出处.谢谢. Kernel 版本:3.4.55 Kernel启动时会解析cmdline,然后依据这些參 ...

  9. PHP新手必学之刚进公司装环境

    由于今天去一家公司做项目,又重新的装了一遍所熟悉的PHP环境,所以记录下来,总结下. PHP环境主要: PHPstudy(apache+mysql+php)+phpstorm+navicate 解释: ...

  10. LR报错 No buffer space available Try changing the registry value 端口号不够用了

    报错:Action.c(6): Error -27796: Failed to connect to server "10.16.137.8:10035": [10055] No ...