/*
  将给定的一个字符串分解成ABABA 或者 ABABCAB的形式!
思路:暴力枚举A, B, C串!
*/
1 #include<iostream>
#include<cstring>
#include<cstdio>
#include<string> using namespace std;
string str;
char ch[];
int main(){
int t;
scanf("%d", &t);
getchar();
while(t--){
char cc;
int cnt=;
scanf("%c", &cc); while(cc!='\n'){
if((cc>='A' && cc<='Z' || cc>='a' && cc<='z'))
ch[cnt++]=cc;
scanf("%c", &cc);
}
ch[cnt]='\0';
str=string(ch);
int len=strlen(ch);
bool flag=false;
for(int i=; i<len/; ++i){
string A=str.substr(, i);
for(int j=; j<len/; ++j){
if(i+j>len/) break;
string B=str.substr(+i, j);
if(A==B) continue;
int ll=i;
int k=i+j, x; for(x=; x<ll && k<len; ++k, ++x)
if(A[x] != ch[k])
break;
if(x==ll){
k=i+j+i;
ll=j;
for(x=; x<ll && k<len; ++k, ++x)
if(B[x] != ch[k])
break;
if(x==ll){ ll=i;
k=i+j+i+j;
for(x=; x<ll && k<len; ++k, ++x)
if(A[x] != ch[k])
break;
if(x==ll && k==len)
flag=true;
if(!flag){
k=i+j+i+j;
ll=j;
int m=len-;
for(x=ll-; x>= && m>k; --m, --x)
if(B[x] != ch[m])
break;
if(x==-){
ll=i;
for(x=ll-; x>= && m>k; --m, --x)
if(A[x] != ch[m])
break;
if(x==-){
string C=str.substr(k, m-k+);
if(A!=C && B!=C)
flag=true;
}
}
}
}
}
}
}
if(flag) printf("Yes\n");
else printf("No\n");
}
return ;
}

2014牡丹江网络赛ZOJPretty Poem(暴力枚举)的更多相关文章

  1. 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...

  2. zoj 3809 枚举水题 (2014牡丹江网赛 A题)

    题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...

  3. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...

  4. 2013 acm 长沙网络赛 G题 素数+枚举 Goldbach

    题目 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3856 先预处理求出两个素数的和与积,然后枚举n-prime和n/pr ...

  5. 2014 牡丹江区域赛 B D I

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...

  6. ACM-ICPC北京赛区(2017)网络赛1【模拟+枚举+数组操作】

    题目1 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for n ...

  7. 2014牡丹江 现场赛 F zoj 3824 Fiber-optic Network

    首先赞一下题目, 好题 题意: Marjar University has decided to upgrade the infrastructure of school intranet by us ...

  8. zoj 3820(2014牡丹江现场赛B题)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...

  9. 2014牡丹江网络zoj3816Generalized Palindromic Number(dfs或者bfs)

    #include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> ...

随机推荐

  1. jQqery EasyUI dategrid行中多列数据的可编辑操作

    最近的项目中需要在前台dategrid列表中直接修改某些列的数据,并且修改后的数据需要不通过后台而自动更新在列表中. 带着这一问题开始寻找实现的思路,首先想到的就是去jQqery EasyUI官网找例 ...

  2. [Leetcode][JAVA] Flatten Binary Tree to Linked List

    Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6   ...

  3. [XAF] 多级联列表显示

    XAF给的例子已经实现,详细可查看例子中的代码. 工作车间--工作中心--机器

  4. JSP中<base href="<%=basePath%>">作用

    通常在JSP页面开通有如下代码: <% String path = request.getContextPath(); String basePath = request.getScheme() ...

  5. (原创)Louis Aston Knight 的家(摄影,欣赏)

    本文图片转自腾讯文化:www.cal.qq.com 1.Abstract     记忆中的家,深情刻画. 2.Content 图1 图2 图3 图4 图5 图6 图7 图8 图9 图10 图10 图1 ...

  6. 读入一个c程序,并按字母表顺序分组打印变量名,每组前N个字符相同(TCPL 练习6-2)

    在建立结构tnode的过程中,我们没有预设门槛.这道题目就设置了门槛,必须根据前N个字符来进行分组,于是排除了长度小于N的变量,以便减轻负担. 因为要求对变量名分组打印,组别理所应当地应该按照至少是升 ...

  7. Python之*args,**kw

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #021ca1; background-color: #8e352 ...

  8. [转]Git - 重写历史

    转自http://git-scm.com/book/zh/Git-%E5%B7%A5%E5%85%B7-%E9%87%8D%E5%86%99%E5%8E%86%E5%8F%B2    重写历史 很多时 ...

  9. 找回消失的ASUS显卡

    笔记本蓝屏了几次之后,发现独立显卡GT335M不见了,设备管理器,驱动精灵,都找不到,网上问这个问题的人还不少,得到的回答几乎都是说重装驱动.根本不行,这时候安装nVIDIA驱动,会提示说“未找到兼容 ...

  10. poj 1806 分块模拟

    Manhattan 2025 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1318   Accepted: 703 Des ...