#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. java 缩略图

    http://www.cnblogs.com/digdeep/p/4829471.html http://www.jb51.net/article/57648.htm http://blog.csdn ...

  2. Pyqt QListWidget之缩略图列表

    QListWidget 可以设置模型setViewMode  当setViewMode值为QListView.IconMode 表示Icon模式 以下代码来自Pyqt Example #!/usr/b ...

  3. HTML+CSS页面滚动效果处理

    HTML+CSS代码如下: <!doctype html> <html> <head> <meta charset="utf-8"> ...

  4. python中最简单的多进程程序

    学着.. #!/usr/bin/env python # -*- coding: utf-8 -*- # Spawn a Process: Chapter 3: Process Based Paral ...

  5. 终于看完<LEARNING SQL>第二版,立此存照

  6. php重修

    阅读顺序: http://www.laruence.com/2008/08/11/147.html  深入浅出php http://www.laruence.com/2008/06/18/221.ht ...

  7. Introduction to replication 翻译

    翻译自用,还有很多谬误之处,敬请甄别,转载请注明出处 Introduction to replication (replication介绍)   Replication is one of the m ...

  8. php抓取网页信息

    index.php <?php include_once 'simple_html_dom.php'; //获取html数据转化为对象 $html = file_get_html('http:/ ...

  9. 1080P、720P、4CIF、CIF所需要的理论带宽

    转自:http://blog.sina.com.cn/s/blog_64684bf30101hdl7.html 在视频监控系统中,对存储空间容量的大小需求是与画面质量的高低.及视频线路等都有很大关系. ...

  10. Serializable序列化对象

    Serializable序列化对象发送: Intent intent = new Intent(); intent.setClass(mContext, HomeDetailReportActivit ...