Codeforces Round #215 (Div. 2) C. Sereja and Algorithm
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> using namespace std; int main(){
string s ;
cin >>s;
int m;
cin >>m;
vector<int> l(m),r(m);
for(int i = ; i < m ; ++ i )
cin >> l[i]>>r[i]; int n = s.length();
vector<int> x(n+,),y(n+,),z(n+,);
for(int i = ; i < n; ++ i){
x[i+] =x[i];
y[i+] = y[i];
z[i+] = z[i];
if(s[i] == 'x') x[i+]++;
else if(s[i] == 'y') y[i+]++;
else z[i+]++;
} for(int i = ; i < m ; ++ i){
if(r[i]-l[i]+ < ) cout<<"YES"<<endl;
else{
vector<int> num(,);
num[] = x[r[i]]-x[l[i]-];
num[] = y[r[i]]-y[l[i]-];
num[] = z[r[i]]-z[l[i]-];
sort(num.begin(),num.end());
if((num[] == num[] && num[] == num[])||
(num[]-num[] == && num[] == num[]) ||
(num[]-num[] == && num[] - num[] == ))
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return ;
}
Codeforces Round #215 (Div. 2) C. Sereja and Algorithm的更多相关文章
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes map
B. Sereja and Suffixes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- Codeforces Round #215 (Div. 1) B. Sereja ans Anagrams 匹配
B. Sereja ans Anagrams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- Codeforces Round #215 (Div. 2) D. Sereja ans Anagrams
http://codeforces.com/contest/368/problem/D 题意:有a.b两个数组,a数组有n个数,b数组有m个数,现在给出一个p,要你找出所有的位置q,使得位置q q+ ...
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes
#include <iostream> #include <vector> #include <algorithm> #include <set> us ...
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- Codeforces Round #215 (Div. 1)
A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...
- Codeforces Round #223 (Div. 2) E. Sereja and Brackets 线段树区间合并
题目链接:http://codeforces.com/contest/381/problem/E E. Sereja and Brackets time limit per test 1 secon ...
- Codeforces Round #215 (Div. 2) D题(离散化+hash)
D. Sereja ans Anagrams time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #223 (Div. 2)--A. Sereja and Dima
Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- 重温WCF之WCF抛出异常的处理SOAP Fault(十二)
1.(服务端)抛出和(客户端)捕获SOAP Fault 当我们需要客户端获取到WCF服务端的抛出的异常的时候,使用FaultException类 WCF类库在System.ServiceModel命名 ...
- Android消息推送怎么实现?
在开发Android和iPhone应用程序时,我们往往需要从服务器不定的向手机客户端即时推送各种通知消息,iPhone上已经有了比较简单的和完美的推送通知解决方案,可是Android平台上实现起来却相 ...
- SSH入门简单搭建例子
因为公司涉及项目使用SSH,为了解SSH搭建方式和运作原理,就自己搭建了一个. 采用尽量以最少的JAR包,搭建一个简单的struts2+spring+hibernate环境,希望像我这样的入门者都能理 ...
- Fallout4 Creation Kit
按住SHIFT是旋转视角,按住鼠标中键 E是移动物品 双击W是旋转物品 数字键2 是调整物品大小
- ThinkPHP中使用ajaxReturn进行ajax交互
以管理员登录为例来介绍下$this->ajaxReturn与模板页进行ajax交互使用方法 首先看PHP控制器的处理,在application/Admin/Controller/LoginCon ...
- PHP json数据格式化方法
php 的json_encode能把数组转换为json格式的字符串.字符串没有缩进,中文会转为unicode编码,例如\u975a\u4ed4.人阅读比较困难.现在这个方法在json_encode的基 ...
- JVM字节码之整型入栈指令(iconst、bipush、sipush、ldc)
官网:http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html 原文地址:http://www.linmuxi.com/2016/02 ...
- vector的主要操作
vector常用方法 assign() 对Vector中的元素赋值 void assign( input_iterator start, input_iterator end ); // void a ...
- HeapSort自己yy-未完成
#include <iostream> #include <cstdio> using namespace std; ; int a[maxn]; int HeapSize; ...
- shell-bash学习01基础、打印、环境变量
基础 终端提示符: username@hostname$; $: 一般用户 #:root用户 运行脚本 Bash执行: * bash script.sh; 直接运行: 脚本开头添加shebang起始: ...