Codeforces Round #771 (Div. 2), problem: (B) Odd Swap Sort
就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数
结果只需输出是否可以整成升序的
思路: 需要奇数偶数分开讨论, 如果奇数和偶数都分别是单增的那么可行, 反之为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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门 Problem - D - Codeforces 题意 n个数字,n ...
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...
- 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 ...
- 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 ...
- Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- 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 ...
- 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 ...
随机推荐
- Intellij IDEA远程debug线上项目记录
远程调试,特别是当你在本地开发的时候,你需要调试服务器上的程序时,远程调试就显得非常有用. JAVA 支持调试功能,本身提供了一个简单的调试工具JDB,支持设置断点及线程级的调试同时,不同的JVM通过 ...
- 使用 Docker 部署 LNMP 并搭建 wordpress
准备 系统版本:CentOS Linux release 7.4.1708 (Core) 内核版本:3.10.0-693.el7.x86_64 IP:192.168.31.43 可访问 ...
- dpwwn-01
环境配置 靶机下载地址: https://download.vulnhub.com/dpwwn/dpwwn-01.zip 下载好解压打开.vmx文件即可 启动后如图: 无法直接获得靶机ip,用kali ...
- leedcode算法
1.LeetCode - 合并两个链表 2. 3. 链表是否有环 https://jingyan.baidu.com/article/066074d69afb8d83c31cb068.ht ...
- 关于web以及浏览器处理预加载有哪些思考?
图片等静态资源在使用之前就提前请求资源使用到的时候能从缓存中加载, 提升用户体验页面展示的依赖关系维护
- springboot监听kafka(不使用spring-kafka)
一.不使用spring-kafka的原因 kafka服务端版本为0.10.0.1-Ipv20191220-hbp2.1.0,为避免版本问题导致监听失败,客户端也采用0.10.0.1版本,客户端0.10 ...
- jQuery--筛选【串联函数】
串联函数简介 A.add(B) 将A和B组合成一个对象 A.children().andSelf() 将之前的对象添加到操作集合中 A.children().children().end() 回到最近 ...
- Redis6.0配置文件翻译(Google手动翻译)
原文链接(一般情况下你打不开这个网页):https://raw.githubusercontent.com/redis/redis/6.0/redis.conf Redis配置文件 请注意,为了读取配 ...
- MySQL 如何优化 DISTINCT?
DISTINCT 在所有列上转换为 GROUP BY,并与 ORDER BY 子句结合使用. SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;
- 在java web工程中实现登入和安全验证
登入页面的话我们之前做过直接可以拿来用翻一翻之前的博客就可以找到 在这个基础上添加验证功能 代码如下: 1 package security; 2 /** 3 * @author 鐜嬭儨鍗? 4 */ ...