还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com)

传送门  Problem - D - Codeforces

题意

n个数字,n个字符, 数字与字符一一对应, 其中字符R红色代表数字可以上升, B蓝色代表可以下降, 问一顿操作下来能否使n个数含有1~n的所有数

题解

当时真的没想到, 蓝色一定在数组前面, 红色一定在数组后面,( 反正就算有方案使得蓝不在前面, 红不在后面,蓝红也是可以交换的)。 排序后, 前面的蓝色数字如果>=i+1 或者红色的数字<=i+1 即可, 不符合条件的数最后都没有去处

AC代码

// #include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std; typedef long long LL;
typedef pair<char,int> PII;
const int N = 2e5+10;
PII a[N]; int main(void)
{
int t;
cin >> t;
while(t --)
{
int n;
string s;
cin >> n;
for(int i = 0; i <n; i ++) cin >> a[i].second;
for(int i = 0; i <n; i ++) cin >> a[i].first; sort(a, a+n);
bool flag = 1;
for(int i = 0; i < n; i ++)
{
if(a[i].first == 'B'){
if(a[i].second < i+1)
{
flag = 0;
break;
}
}
else{
if(a[i].second > i+1)
{
flag = 0;
break;
}
}
}
if(flag)puts("YES");
else puts("NO");
} return 0;
}

Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation的更多相关文章

  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 C (Codeforces 869C) - 组合数学

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

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

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

  4. 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 ...

  5. 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 ...

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

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

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #427 (Div. 2) Problem A Key races (Codeforces 835 A)

    Two boys decided to compete in text typing on the site "Key races". During the competition ...

随机推荐

  1. springWeb——Servlet

    6.1.Servlet简介 servlet是sun公司开发动态web的一门技术 sum在这些API中提供了一个接口叫做:Servlet.开发的两个步骤: 编写一个类,实现Servlet接口 把开发好的 ...

  2. notepad++给每一列数据加单引号及逗号结尾

    原始数据: 对列操作--先加前引号(光标放在第一行哦):编辑-->列块编辑 再加后引号和逗号(文本尾端不齐,就用替换): 打开替换窗口:ctrl+F(其实就是查找) 加完引号和逗号效果:(如果最 ...

  3. 阿里一面,说说你了解zookeeper的应用场景有哪些?

    1.前言 又到了金三银四的时候,大家都按耐不住内心的躁动,我在这里给大家分享下之前面试中遇到的一个知识点(zookeeper应用场景),希望对大家有些帮助.如有不足,欢迎大佬们指点指点. 2.zook ...

  4. vue学习过程总结(08) - vue开发报错提示缺少本地文件的包

    vue开发启动过程会报错某个src下自己写的包找不到为安装,原因有两个 1.import的from后面的路径不正确 2.如果开发中用到了scss是也会一直报这个错,这时候可能你没有安装scss加载器, ...

  5. CF1404E Bricks (最大权独立集)

    考虑把答案进行转化,通过分矩形条,我们能去掉一些夹在#之间的边 那么答案= #个数 - 能去掉的边个数 但去掉是有限制的,同一个#格子的横边和竖边不能同时去掉 把边转化成点,限制变成边. 横竖边的点 ...

  6. Python中的鸭子类型

    今天,我们来聊一聊Python中的鸭子类型(duck typing). 编程语言具有类型概念,例如Python中有数字类型.字符串类型.布尔类型,或者更加复杂的结构,例如元组tuple.列表list. ...

  7. Pytorch自动混合精度(AMP)介绍与使用

    背景: pytorch从1.6版本开始,已经内置了torch.cuda.amp,采用自动混合精度训练就不需要加载第三方NVIDIA的apex库了.本文主要从三个方面来介绍AMP: 一.什么是AMP? ...

  8. Zookeeper 有哪几种几种部署模式?

    部署模式:单机模式.伪集群模式.集群模式.

  9. 客户端回调 Watcher ?

    客户端 SendThread 线程接收事件通知,交由 EventThread 线程回调 Watcher. 客户端的 Watcher 机制同样是一次性的,一旦被触发后,该 Watcher 就失效了.

  10. Linux基础学习 | 目录及文件

    一.目录结构 Linux目录采用树形结构,以根目录/向下延伸呈一个倒置的树的形状. 每个目录下都有其相对应的子目录,而子目录中又有其子目录的存在,就像一棵树的树枝分叉,所有的目录层次结构分明,每个目录 ...