#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. max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

    在/etc/syscurity/limits.conf 加入以下两行: elastic hard nofile 65536 elastic soft nofile  65536 #备注:elastic ...

  2. 端口扫描之王-----------nmap

    [root@ok data]# nmap -F -sT -v nmap.org Starting Nmap 5.51 ( http://nmap.org ) at 2016-10-23 12:46 C ...

  3. .NET开发工具之Excel导出公共类

    来源:Pino晨 链接:cnblogs.com/chenxygx/p/5954870.html 说明 最近接了一个任务,就是做一个列表的Excel导出功能.并且有很多页面都会使用这个功能. 导出的Ex ...

  4. linux cpuInfo

    转自:http://blog.csdn.net/lgstudyvc/article/details/7889364   /proc/cpuinfo文件分析 在Linux系统中,提供了proc文件系统显 ...

  5. 重温WCF之WCF传输安全(十三)(2)基于SSL的WCF匿名客户端(转)

    转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/13/2683514.html 这一篇我们利用上一篇制作的证书,来演示一个基于SSL的WCF服务, ...

  6. sql server 用户'sa'登录失败(错误18456)(转载)

    转载地址:http://thenear.blog.51cto.com/4686262/865544 用户'sa'登录失败(错误18456)解决方案图解 当我们在使用sql server 的时候可能会遇 ...

  7. How many Fibs?【sudt 2321】【大数的加法及其比较】

    How many Fibs? Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Recall the definition of t ...

  8. 无废话ExtJs 入门教程十一[下拉列表:Combobox]

    无废话ExtJs 入门教程十一[下拉列表:Combobox] extjs技术交流,欢迎加群(201926085) 继上一节内容,我们在表单里加了个一个下拉列表: 1.代码如下: 1 <!DOCT ...

  9. hdu 1247:Hat’s Words(字典树,经典题)

    Hat’s Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  10. 调整vbox虚拟机下的linux全屏模式及分辨率

    >>Step1 在VirtualBox菜单栏中选择[设备]->[安装增强功能] >>Step2 点击右上角的[齿轮]图标,然后选择[Log Out],重新登录即可 lin ...