cf C. Sereja and Algorithm
http://codeforces.com/contest/368/problem/C
从左向右记录从1位置到每一个位置上x,y,z的个数。然后判断在l,r区间内的x,y,z的关系满不满足abs(x-y)<=1&&abs(x-z)<=1&&abs(y-z)<=1,满足输出YES,否则输出NO。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 200000
using namespace std; char str[maxn];
int hx[maxn],hy[maxn],hz[maxn];
int m;
int l,r; int main()
{
while(scanf("%s",str)!=EOF)
{
int t1=,t2=,t3=;
memset(hx,,sizeof(hx));
memset(hy,,sizeof(hy));
memset(hz,,sizeof(hz));
int len=strlen(str);
for(int i=; i<len; i++)
{
if(str[i]=='x')
{
t1++;
hx[i+]=t1;
hy[i+]=t2;
hz[i+]=t3;
}
else if(str[i]=='y')
{
t2++;
hx[i+]=t1;
hy[i+]=t2;
hz[i+]=t3;
}
else if(str[i]=='z')
{
t3++;
hx[i+]=t1;
hy[i+]=t2;
hz[i+]=t3;
}
}
scanf("%d",&m);
for(int i=; i<=m; i++)
{
scanf("%d%d",&l,&r);
int len=r-l+;
if(len<)
{
printf("YES\n");
continue;
}
else
{
int x=hx[r]-hx[l-];
int y=hy[r]-hy[l-];
int z=hz[r]-hz[l-];
if(abs(x-y)<=&&abs(x-z)<=&&abs(y-z)<=)
{
printf("YES\n");
}
else printf("NO\n");
}
}
}
return ;
}
cf C. Sereja and Algorithm的更多相关文章
- Codeforces Round #215 (Div. 2) C. Sereja and Algorithm
#include <iostream> #include <vector> #include <algorithm> #include <string> ...
- cf D. Sereja ans Anagrams
http://codeforces.com/contest/368/problem/D #include <cstdio> #include <cstring> #includ ...
- cf B. Sereja and Suffixes
http://codeforces.com/contest/368/problem/B 从后往前找一遍就可以. #include <cstdio> #include <cstring ...
- CF 314C Sereja and Subsequences(树状数组)
题目链接:http://codeforces.com/problemset/problem/314/C 题意:给定一个数列a.(1)写出a的不同的所有非下降子列:(2)定义某个子列的f值为数列中各个数 ...
- 【CF】Sereja and Arcs
#include <bits/stdc++.h> #define llong long long using namespace std; const int N = 1e5; const ...
- Android 签名比较
一. keytool -list -printcert -jarfile "%filename%" 二. 非常low方法:下载的应用安装能成功覆盖原应用则签名一致三. 作者:陈子腾 ...
- Codeforces 367
A. Sereja and Algorithm 水题不解释. B. Sereja ans Anagrams 模p同余的为一组,随便搞. C. Sereja and the Arrangement of ...
- Codeforces Round #215 (Div. 1)
A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...
- 如何判断 Android 应用的 Apk 签名是否一致?
可以比对apk签名的fingerprint. 假定安装了JDK,如果想查HelloWorld.apk所使用的签名的fingerprint,可以这样做: 1. 查找apk里的rsa文件 (Windows ...
随机推荐
- [Operationg System Labs] 我对 Linux0.00 中 boot.s的理解和注释
(如有错误请立即指正,么么哒!) ! boot.s!! It then loads the system at 0x10000, using BIOS interrupts. Thereafte ...
- Android 按钮按下效果
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="htt ...
- openstack neutron debugs lists
- lesson6:java线程中断
正常的情况下,业务系统都不会去中断它的线程,但是由于一些特殊情况的发生,线程已经不能正常结束了,并且此类线程已经影响到业务系统提供服务的能力,如果系统设计的健壮,便会通过监控线程去主动的中断此类线程. ...
- Javascript:sort()方法快速实现对数组排序
定义和用法: sort() 方法用于对数组的元素进行排序. 语法: arrayObject.sort(sortby) 注释:sortby,可选,规定排序顺序,必须是函数. 说明: 如果调用该方法时没有 ...
- solr 3.5 配置及server设置
一.solr 的简单介绍 Apache Solr 是一个开源的搜索server.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache Solr 中 ...
- MySQL加密的性能测试
这是对MySQL进行加密性能测试的两篇文章系列之二.在第一篇中,我专门使用MySQL的内置的对SSL的支持来 做压力测试,产生了一些令人惊讶的结果. AD:WOT2015 互联网运维与开发者大会 热销 ...
- Linux进程调度与切换
2016-04-15 张超<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.分析 进程调度的时机与进程 ...
- 服务 Service 基本介绍
Activity public class MainActivity extends ListActivity { private boolean flag;//是否开启线程 publ ...
- 使用VS Code开发AngularJS 2 第一个应用程序
使用VS Code开发AngularJS 2 第一个应用程序 目录 运行环境 创建项目 安装依赖包 创建TypeScript应用程序 配置应用程序 运行应用程序 运行环境 运行环境: Windows ...