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. 利用Redis对批量数据实现分布式锁

    需求背景 在开发的收入结转平台界面上有一个归集按钮,可以实现抓取结转表里面的多条数据进行归集操作.为了防止多人多电脑同时操作一条数据,我们自己开发了一个简单的基于Redis实现的分布式锁. 代码实现 ...

  2. xx局点FusionCloud6.3type1修改配额占用

    问题描述: SC中配额占用跟实际资源使用不一致 SC界面显示参数: 实例已使用:35 内存已使用:440G VCPU已使用:220 云硬盘已使用:11850G/56个 SC实际统计参数: 实例已使用: ...

  3. 计算机网络:套接字(Socket)| Python socket实现服务器端与客户端通信,使用TCP socket阿里云ECS服务器与本机通信

    所谓套接字(Socket),就是对网络中不同主机上的应用进程之间进行双向通信的端点的抽象.一个套接字就是网络上进程通信的一端,提供了应用层进程利用网络协议交换数据的机制.从所处的地位来讲,套接字上联应 ...

  4. C# XML基础入门(XML文件内容增删改查清)

    前言: 最近对接了一个第三方的项目,该项目的数据传输格式是XML.由于工作多年只有之前在医疗行业的时候有接触过少量数据格式是XML的接口,之后就几乎没有接触过了.因此对于XML这块自己感觉还是有很多盲 ...

  5. String -- char[]互转

    1.String --> char[] String str = "abc"; char[] chs = str.toCharArray(); 2.char[] --> ...

  6. bash shell 中的 hash 命令有什么作用?

    linux 命令'hash'管理着一个内置的哈希表,记录了已执行过的命令的完整路径,用该命令可以打印出你所使用过的命令以及执行的次数. [root@localhost ~]# hashhits com ...

  7. 说说对 SQL 语句优化有哪些方法?(选择几条)

    1.Where 子句中:where 表之间的连接必须写在其他 Where 条件之前,那些可 以过滤掉最大数量记录的条件必须写在 Where 子句的末尾.HAVING 最后. 2.用 EXISTS 替代 ...

  8. 什么是 JavaConfig?

    Spring JavaConfig 是 Spring 社区的产品,它提供了配置 Spring IoC 容器的纯 Java 方法.因此它有助于避免使用 XML 配置.使用 JavaConfig 的优点在 ...

  9. java-反射-注解-json-xml

    反射: 框架设计的灵魂 框架:半成品软件.可以再框架的基础上进行软件开发,简化代码 定义:将类的各个组成部分封装为其他对象,这就是反射机制 好处: 可以再程序运行过程中,操作这些对象 可以解耦,提高程 ...

  10. 学习Kvm(七)

    六,管理虚拟网络 [x] Linux网桥基本概念 [x] qemu-kvm支持的网络 [x] 向虚拟机添加虚拟网络连接 [x] 基于NAT的虚拟网络 [x] 基于网桥的虚拟网络 [x] 用户自定义的隔 ...