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 ...
随机推荐
- bt和wifi的共存
转自:http://bbs.52rd.com/Thread-291892-1-1.html 蓝牙和802.11b/g/n都可能工作在2.4GISM,可能互相干扰.干扰的典型应用之一是VOIP,用手机的 ...
- 重温WCF之发送和接收SOAP头(三)
SOAP头可以理解为一种附加信息,就是附加到消息正文的内容. 既然消息头是附加信息,那有啥用呢?你可别说,有时候还真有不少用处.举个例子,WCF的身份验证是不是很麻烦?还要颁发什么证书的(当然不是荣誉 ...
- Delphi多线程开发注意事项
Q1: 多线程中需避免多个线程同时向全局变量进行写入操作,导致访问冲突问题. A1: 可以通过使用加锁机制(比如:临界区.互斥.信号量)解决此问题. Q2:多线程中对于结构体和CLASS类型的全局变 ...
- <转>SQL语句执行顺序说明
原文地址:http://www.cnblogs.com/summer_adai/archive/2011/10/28/2227605.html SQL 不同于与其他编程语言的最明显特征是处理代码的顺序 ...
- Debian 的 preinst, postinst, prerm, 和 postrm 脚本
转自:http://jianjian.blog.51cto.com/35031/395468 这些是软件包安装前后自动运行的可执行脚本. 统称为控制文件, 是 Deian 软件包的"控制&q ...
- C++中单例模式
//C++单例模式:指一个类只生成一个对象 #include <iostream> using namespace std; class A{ public: static A* getA ...
- C# 使用 NPOI 库读写 Excel 文件
NPOI 是开源的 POI 项目的.NET版,可以用来读写Excel,Word,PPT文件.在处理Excel文件上,NPOI 可以同时兼容 xls 和 xlsx.官网提供了一份 Examples,给出 ...
- Java Socket编程(转)
Java Socket编程 对于Java Socket编程而言,有两个概念,一个是ServerSocket,一个是Socket.服务端和客户端之间通过Socket建立连接,之后它们就可以进行通信了.首 ...
- UVA136 求第1500个丑数
枚举大范围数据..暴力检查题目条件 #include <iostream> #include <cstdio> #include <vector> #include ...
- 【MongoDB】2.可视化工具的安装和使用
首先:关于 能支持MongoDB新版本的可视化工具,争议不断,各人都有各人的支持. 因此之前选择安装的时候就安装了MongoDB 3.0.14版本的. 最终,确定使用Robomongo作为我第一个 ...