Problem - B - Codeforces

就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数

结果只需输出是否可以整成升序的

思路: 需要奇数偶数分开讨论, 如果奇数和偶数都分别是单增的那么可行, 反之为no

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
const int N = 1e5+10;
int a[N];
int main()
{
int t;
cin >> t;
while(t --)
{
bool f = 0;
int n;
cin >> n;
for(int i=0; i < n; i ++)cin >> a[i]; int odd=0, even=0;
for(int i = 0; i <n; i ++)
{
if(a[i]%2)
{
if(odd>a[i])
{
f=1;
break;
}
odd=a[i];
}
else
{
if(even>a[i])
{
f=1;
break;
}
even=a[i];
}
}
if(f)cout << "NO\n";
else cout << "YES\n";
}
return 0;
}

Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort的更多相关文章

  1. Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

  2. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  3. Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation

    还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n ...

  4. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  5. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii ...

  6. Codeforces Round #439 (Div. 2) Problem B (Codeforces 869B)

    Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense ...

  7. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  8. Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索

    Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...

  9. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

随机推荐

  1. Arcgis 离线部署api 4.x的两种本地部署方法!

    引言:本文用的是api4.6版本 方法一  拷贝api进去tomcat服务器用绝对地址引用 首先将下载好的api放入Tomcat服务中的Webapp下: 1  可以打开下载好的的 api46/arcg ...

  2. Linux移植总结--uboot从不同介质上启动分析

    @ 目录 1.启动地址 2.uboot占用内存 3.2440从NAND启动 4.2440从NOR启动 5.某开发板从SPI FLASH启动 1.启动地址 先以2440开发板为例,SDRAM(0x300 ...

  3. linux命令管道工作原理与使用方法

    一.管道定义 管道是一种两个进程间进行单向通信的机制.因为管道传递数据的单向性,管道又称为半双工管道.管道的这一特点决定了器使用的局限性.管道是Linux支持的最初Unix IPC形式之一,具有以下特 ...

  4. 【Python 第0课】Why Python?

    为什么用Python作为编程入门语言? 原因很简单. 嗯...原因就是,很简单... 每种语言都会有它的支持者和反对者.去Google一下"why python"(程序员准则:要G ...

  5. vs2017连接sqlsever数据库

    vs2017连接mysql数据库操作步骤 怎样使用vs2017连接数据库 [C++]VS2015/VS2017连接Mysql数据库教程

  6. SpringBoot的 Actuator 是做什么的?

    本质上,Actuator 通过启用 production-ready 功能使得 SpringBoot 应用程序变得更有生命力.这些功能允许我们对生产环境中的应用程序进行监视和管理. 集成 Spring ...

  7. springboot服务引入外部jar包在windows运行正常,在linux环境上无法加载到引入jar包的类

    一.问题描述 最近开发了一个springboot程序,需要依赖第三方jar包,这个jar包无法直接通过pom远程仓库下载,需要从自己本地引入,于是配置pom文件如下:将本地jar包引入工程,syste ...

  8. Spring Cloud 解决了哪些问题?

    在使用 Spring Boot 开发分布式微服务时,我们面临的问题很少由 Spring Cloud解决.与分布式系统相关的复杂性 – 包括网络问题,延迟开销,带宽问题,安 全问题.处理服务发现的能力 ...

  9. 解释 MySQL 外连接、内连接与自连接的区别 ?

    先说什么是交叉连接: 交叉连接又叫笛卡尔积,它是指不使用任何条件,直接将一 个表的所有记录和另一个表中的所有记录一一匹配. 内连接 则是只有条件的交叉连接,根据某个条件筛选出符合条件的记录,不符合 条 ...

  10. Eureka server

    Eureka server使用的不是spring mvc的框架,而是使用Jersey. Eureka server ,启动的流程,追本溯源,是在 DiscoveryClient里面,使用这个构造方法 ...