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 ...
随机推荐
- volatile关键字与线程间通信
>>Java内存模型 现在计算机普遍使用多处理器进行运算,并且为了解决计算机存储设备和处理器的运算速度之间巨大的差距,引入了高速缓存作为缓冲,缓存虽然能极大的提高性能,但是随之带来的缓存一 ...
- 【JAVA集合框架之Map】
一.概述.1.Map是一种接口,在JAVA集合框架中是以一种非常重要的集合.2.Map一次添加一对元素,所以又称为“双列集合”(Collection一次添加一个元素,所以又称为“单列集合”)3.Map ...
- 【PHP的异常处理【完整】】
PHP的异常处理机制大多数和java的很相似,但是没有finally,而且还可以自定义顶级异常处理器:捕捉到异常信息后,会跳出try-catch块,如果catch中没有跳转的动作,则会继续执行下一条语 ...
- PHP类方法重写原则
可能我们日常工作中很少用到这块知识点,但我还是喜欢把遇到的却不清楚的知识点摸清 PHP的类方法重写规则 1.final修饰的类方法不可被子类重写 final修饰的类方法不可被子类重写 即便final ...
- 2-01SQL的概述
SQL: Structured Query Languaage:结构化查询语言. 美国国家标准局ANSI. 国际标准化组织. T-SQL: Transact-SQL. T-SQL是SQL的扩展集. 对 ...
- [Spring Batch] 图解Spring Batch原理
找到一副以前学习的图,稻清楚的描述了Spring Batch运行原理:
- PL/SQL Developer 9.x 注册码
记下来,以备以后使用,好笔头,哈哈哈 Product Code:46jw8l8ymfmp2twwbuur8j9gv978m2q2du serial Number:307254 password:xs3 ...
- JDK中的设计模式
Creational(创建模式) Abstract factory: 创建一组有关联的对象实例.这个模式在JDK中也是相当的常见,还有很多的framework例如Spring.我们很容易找到这样的实例 ...
- Codeforces Round #103 (Div. 2) D. Missile Silos(spfa + 枚举边)
题目链接:http://codeforces.com/problemset/problem/144/D 思路:首先spfa求出中心点S到其余每个顶点的距离,统计各顶点到中心点的距离为L的点,然后就是要 ...
- OD附加功能分析
OD版本:OllyICE v1.10 在从文件菜单选择附加后,OD会在注册一个窗口类后,先创建一个0x138大小的进程表; 再是CreateWindowExA 创建窗口; 00478013 l ...