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

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

#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. jvm性能调优常用命令

    说明和名词解释: ①  只有进行的运行用户才可以调用命令查看相关信息 ②  [pid] 为需要查看的进程的端口号 ③  [file] 为需要导出到的文件的具体地址 ④ [tid] 进程中线程的id 1 ...

  2. python文件备份脚本

    import osimport time source = ['D:\\MyDrivers\hotfix']   #这里可以用自然字符串表示r',因为windows下的分隔符与python的有冲突,所 ...

  3. php使用imagick模块实现图片缩放、裁剪、压缩示例

    PHP 使用Imagick模块 缩放,裁剪,压缩图片 包括gif图片 缩放 裁剪 复制代码代码如下: /**  * 图片裁剪  * 裁剪规则:  *   1. 高度为空或为零   按宽度缩放 高度自适 ...

  4. cocos2dx 3.0rc怎样创建项目

    转自官网的文档. How to Run cpp-tests on win32 In this article, I will show you how to run cpp-tests on your ...

  5. IntelliJ idea——》创建tag、删除tag

    https://blog.csdn.net/weixin_43453386/article/details/83857038

  6. git add -A使用说明

    git help add -A, --all            Like -u, but match <filepattern> against files in the workin ...

  7. ios 深入讲解iOS键盘一:控制键盘隐藏显示

    在iOS的开发中,我们一般使用UITextField.UITextView处理文字输入等操作,大部分情况下我们只需要一两行代码去手动管理键盘的显示隐藏:让UITextField或UITextView成 ...

  8. 驱动程序分层分离概念_总线驱动设备模型_P

    分层概念: 驱动程序向上注册的原理: 比如:输入子程序一个input.c作为一层,下层为Dev.c和Dir.c,分别编写Dev.c和Dir.c向上Input.c注册:如图所示 分离概念: 分离概念主要 ...

  9. [SCOI2009]生日礼物(尺取法)

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2201  Solved: 1186[Submit][Status][Discuss] Descript ...

  10. 白昼夢 / Daydream(模拟)

    C - 白昼夢 / Daydream Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You ...