#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的更多相关文章

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

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

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

  4. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes

    #include <iostream> #include <vector> #include <algorithm> #include <set> us ...

  5. Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  6. Codeforces Round #215 (Div. 1)

    A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...

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

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

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

随机推荐

  1. set -x 跟踪脚本执行信息

    注意set -x其中"-"与"x"之间没有空格 [root@GitLab sh]# ./sx.sh heelo + a=heelo + echo heelo h ...

  2. BlueTooth: 蓝牙基础知识进阶——链路控制操作

    转自:http://blog.csdn.net/augusdi/article/details/25887395 七链路控制操作 链路控制操作就是用来描述一个设备是如何加入piconet又是如何从一个 ...

  3. Logcat打印调试信息

    Android Logcat调试中的V.D.I.W.E的分别代表什么? Log.v -- 黑色 -- verbose infoLog.d -- 蓝色 -- debug infoLog.i -- 绿色 ...

  4. [LeetCode] Ugly Number II

    Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...

  5. [LeetCode] Merge Sorted Array

    Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume tha ...

  6. android 入门-Service实时向Activity通过BroadcastReceiver传递数据

    引文: http://www.cnblogs.com/linjiqin/p/3147764.html <RelativeLayout xmlns:android="http://sch ...

  7. WPF PRISM开发入门二(Unity依赖注入容器使用)

    这篇博客将通过一个控制台程序简单了解下PRISM下Unity依赖注入容器的使用.我已经创建了一个例子,通过一个控制台程序进行加减乘除运算,项目当中将输入输出等都用接口封装后,结构如下: 当前代码可以点 ...

  8. android开子线程避免出现main错误

    Runnable SonThread=new Runnable() { @Override public void run() { // TODO Auto-generated method stub ...

  9. linux内核的组成,王明学learn

    linux内核的组成 一.linux内核源代码目录结构 arch: 包含和硬件体系结构相关的代码, 每种平台占一个相应的目录, 如 i386.ARM.PowerPC.MIPS 等. block:块设备 ...

  10. FAST特征点检测

    Features From Accelerated Segment Test 1. FAST算法原理 博客中已经介绍了很多图像特征检测算子,我们可以用LoG或者DoG检测图像中的Blobs(斑点检测) ...