【瞎搞】 Codeforces Round #215 (Div. 1) A Sereja and Algorithm
来源:互联网 发布:大连知润科技 编辑:程序博客网 时间:2024/05/29 13:23
点击打开链接
题意,判断一个区间的字符任意组合并且 任意连续的3个 能否由 "zyx", "xzy", "yxz" 组成能则输出YES else NO
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>#define cler(arr, val) memset(arr, val, sizeof(arr))typedef long long LL;const int MAXN = 190001;const int MAXM = 11111;const int INF = 0x3f3f3f3f;const LL mod =1000000007;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int n,m,l,r;int a[MAXN];int b[MAXN];int c[MAXN];char s[MAXN];int main(){ cin>>s+1; n=strlen(s+1); cler(a,0),cler(b,0),cler(c,0); for(int i=1;i<=n;i++) { if(s[i]=='x') a[i]=1; if(s[i]=='y') b[i]=1; if(s[i]=='z') c[i]=1; } for(int i=1;i<=n;i++) a[i]=a[i]+a[i-1],b[i]=b[i]+b[i-1],c[i]=c[i]+c[i-1]; cin>>m; for(int i=0;i<m;i++) { scanf("%d%d",&l,&r); if(r-l+1<=2) { printf("YES\n"); continue; } int x=a[r]-a[l-1]; int y=b[r]-b[l-1]; int z=c[r]-c[l-1]; int minn=min(x,min(y,z)); int maxx=max(x,max(y,z)); if(maxx-minn<=1) puts("YES"); else puts("NO"); } return 0;}/**/
0 0
- 【瞎搞】 Codeforces Round #215 (Div. 1) A Sereja and Algorithm
- Sereja and Algorithm -----Codeforces Round #215 div.1 A
- Codeforces Round #215_div2_C. Sereja and Algorithm
- Codeforces Round #215 (Div. 2) -A. Sereja and Coat Rack
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
- Codeforces Round #243 (Div. 1) A Sereja and Swaps
- Codeforces Round #223 (Div. 1) A - Sereja and Prefixes
- codeforces --A - Sereja and Algorithm
- Codeforces Round #215 (diy.2) C. Sereja and Algorithm
- Codeforces Round #223 (Div. 2)--A. Sereja and Dima
- Codeforces Round #223 (Div. 2)A. Sereja and Dima&&B. Sereja and Stairs
- Codeforces 367A Sereja and Algorithm
- CodeForces 367A-Sereja and Algorithm【规律】
- Codeforces 367A Sereja and Algorithm 【规律】
- 【codeforces 367A Sereja and Algorithm】+ 预处理
- CodeForces 367A Sereja and Algorithm
- Codeforces Round #215 (Div. 2) -B. Sereja and Suffixes
- Codeforces Round #215 (Div. 2) -B. Sereja and Suffixes
- CentOS通过删除旧内核解决/boot空间不足的问题
- 使用epoll实现TCP多路复用
- Facebook Graph API - 统计comment的数量
- iOS应用性能调优的25个建议和技巧
- 第21题
- 【瞎搞】 Codeforces Round #215 (Div. 1) A Sereja and Algorithm
- 搬家APP-竞品分析报告
- Jsoup解析html页面实现CSDN博客客户端
- 学习设计模式五步走
- 数组实现顺序栈与队列
- Nginx 在 ubuntu 14.04上的安装配置。
- 51页第18题
- 字符,字符集,编码之间的区别
- android网易顶部导航栏demo .