B-1003
来源:互联网 发布:南丹县政府网络问政 编辑:程序博客网 时间:2024/05/17 05:16
#include<cstdio>#include<string.h>char s[110];int main(){ int n; while(scanf("%d", &n)==1){ for(int i = 0; i < n; i++){ scanf("%s", s); int len = strlen(s), P_tag, T_tag; if(s[0]=='P' && s[len-1]=='T'){ P_tag = 0; T_tag = len-1; if(T_tag-P_tag <= 1){ printf("NO\n"); continue;} int j; for(j = P_tag+1; j < T_tag && s[j]=='A'; j++); if(j==T_tag) printf("YES\n"); else printf("NO\n"); continue; } if(s[0]=='A' && s[len-1]=='A'){ if(strchr(s,'P')==NULL || strchr(s,'T')==NULL){ printf("NO\n"); continue;} int j; for(j = 1; j < len && s[j]!='P'; j++); P_tag = j; for(j = 1; j < len && s[j]!='T'; j++); T_tag = j; if(P_tag<T_tag){ if(T_tag-P_tag <= 1){ printf("NO\n"); continue;} int k; for(k = 1; k < P_tag && s[k]=='A'; k++); if(k!=P_tag){printf("NO\n"); continue;} for(k = T_tag+1; k < len && s[k]=='A'; k++); if(k!=len){printf("NO\n"); continue;} for(k = P_tag+1; k < T_tag && s[k]=='A'; k++); //printf("%d %d %d\n", P_tag, T_tag, k); if(k==T_tag && (T_tag-P_tag-1)*P_tag == len-1-T_tag) printf("YES\n"); else printf("NO\n"); } else printf("NO\n"); } else printf("NO\n"); } } return 0;}
阅读全文
0 0
- B-1003
- 题目1003:A+B
- 题目1003:A+B
- 题目1003:A+B
- 题目1003:A+B
- hoj 1003 A-B
- 题目1003:A+B
- 题目1003:A+B
- 题目1003:A+B
- 题目1003:A+B
- A+B(1003)
- 题目1003:A+B
- 题目1003:A+B
- 1003 Problem B
- 题目1003:A+B
- 1003_A+B
- 题目1003:A+B
- 题目1003:A+B
- 设计模式(8)观察者模式-行为型
- C#实现listview Group收缩扩展的方法
- LintCode题解(1)--A+B问题
- 解决ubuntu14.04系统没有声音的问题
- web.xml is missing and <failonmissingwebxml> is set to true
- B-1003
- RabbitMQ 笔记
- variational autoEncoder介绍
- Centos 7.3 Install LNMP
- Python中的logging模块
- Python函数式编程(高阶函数、map()、reduce()、filter()、sorted()、lambda、decorator装饰器)
- ++i和i++的区别
- 碰撞检测算法(2D矩形)
- matlab imfill函数