1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9. string s ;
  10. cin >>s;
  11. int m;
  12. cin >>m;
  13. vector<int> l(m),r(m);
  14. for(int i = ; i < m ; ++ i )
  15. cin >> l[i]>>r[i];
  16.  
  17. int n = s.length();
  18. vector<int> x(n+,),y(n+,),z(n+,);
  19. for(int i = ; i < n; ++ i){
  20. x[i+] =x[i];
  21. y[i+] = y[i];
  22. z[i+] = z[i];
  23. if(s[i] == 'x') x[i+]++;
  24. else if(s[i] == 'y') y[i+]++;
  25. else z[i+]++;
  26. }
  27.  
  28. for(int i = ; i < m ; ++ i){
  29. if(r[i]-l[i]+ < ) cout<<"YES"<<endl;
  30. else{
  31. vector<int> num(,);
  32. num[] = x[r[i]]-x[l[i]-];
  33. num[] = y[r[i]]-y[l[i]-];
  34. num[] = z[r[i]]-z[l[i]-];
  35. sort(num.begin(),num.end());
  36. if((num[] == num[] && num[] == num[])||
  37. (num[]-num[] == && num[] == num[]) ||
  38. (num[]-num[] == && num[] - num[] == ))
  39. cout<<"YES"<<endl;
  40. else cout<<"NO"<<endl;
  41. }
  42. }
  43. return ;
  44. }

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. volatile关键字与线程间通信

    >>Java内存模型 现在计算机普遍使用多处理器进行运算,并且为了解决计算机存储设备和处理器的运算速度之间巨大的差距,引入了高速缓存作为缓冲,缓存虽然能极大的提高性能,但是随之带来的缓存一 ...

  2. 【JAVA集合框架之Map】

    一.概述.1.Map是一种接口,在JAVA集合框架中是以一种非常重要的集合.2.Map一次添加一对元素,所以又称为“双列集合”(Collection一次添加一个元素,所以又称为“单列集合”)3.Map ...

  3. 【PHP的异常处理【完整】】

    PHP的异常处理机制大多数和java的很相似,但是没有finally,而且还可以自定义顶级异常处理器:捕捉到异常信息后,会跳出try-catch块,如果catch中没有跳转的动作,则会继续执行下一条语 ...

  4. PHP类方法重写原则

    可能我们日常工作中很少用到这块知识点,但我还是喜欢把遇到的却不清楚的知识点摸清 PHP的类方法重写规则 1.final修饰的类方法不可被子类重写 final修饰的类方法不可被子类重写 即便final ...

  5. 2-01SQL的概述

    SQL: Structured Query Languaage:结构化查询语言. 美国国家标准局ANSI. 国际标准化组织. T-SQL: Transact-SQL. T-SQL是SQL的扩展集. 对 ...

  6. [Spring Batch] 图解Spring Batch原理

    找到一副以前学习的图,稻清楚的描述了Spring Batch运行原理:  

  7. PL/SQL Developer 9.x 注册码

    记下来,以备以后使用,好笔头,哈哈哈 Product Code:46jw8l8ymfmp2twwbuur8j9gv978m2q2du serial Number:307254 password:xs3 ...

  8. JDK中的设计模式

    Creational(创建模式) Abstract factory: 创建一组有关联的对象实例.这个模式在JDK中也是相当的常见,还有很多的framework例如Spring.我们很容易找到这样的实例 ...

  9. Codeforces Round #103 (Div. 2) D. Missile Silos(spfa + 枚举边)

    题目链接:http://codeforces.com/problemset/problem/144/D 思路:首先spfa求出中心点S到其余每个顶点的距离,统计各顶点到中心点的距离为L的点,然后就是要 ...

  10. OD附加功能分析

    OD版本:OllyICE v1.10   在从文件菜单选择附加后,OD会在注册一个窗口类后,先创建一个0x138大小的进程表; 再是CreateWindowExA 创建窗口;   00478013 l ...