/*
  将给定的一个字符串分解成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. 解决VS2010子目录中的.cpp文件引用上一级目录的stdafx.h找不到定义的问题

    Source目录 |-- stdafx.h |--Util目录 |--Util.h |--Util.cpp 现在的发现Util.cpp各种变量的定义全是红色波浪线,找不到定义,但是却能够编译过 问题就 ...

  2. 使用printf输出各种格式的字符串( 转载)

    1. 原样输出字符串:    printf("%s", str); 2. 输出指定长度的字符串, 超长时不截断, 不足时右对齐:    printf("%Ns" ...

  3. 从csdn博客搬家过来,请多关照!

    之前一直在csdn博客,也写了不少关于java的文章,主要是学习java上的一些问题.想通过这种方式来加深对问题的认知,同时也可以帮助到志同道合的人,一起在编程的道路上共进,共勉.

  4. Byte,TBytes,array of Byte, array[0..9] of byte的区别

    Byte前面已经说是存放bit的单元,是电脑内存的基本单位,byte表示0-255中的256个数字 下面为Byte的用法: var B: Byte; // 表示0-255的数字 begin B := ...

  5. CXF实现webservice

    虽然网上有很多cxf的教程,但还是要自己写写, “好记性不如烂笔头” 1.服务端 1.1  DEMO,用于测试传递对象 package com.xq.model; import javax.persi ...

  6. document.write 摘抄

    页面载入过程中用实时脚本创建页面内容,以及用延时脚本创建本窗口或新窗口的内容.该方法需要一个字符串参数,它是写到窗口或框架中的HTML内容.这些字符串参数可以是变量或值为字符串的表达式,写入的内容常常 ...

  7. poj 2481 - Cows(树状数组)

    看的人家的思路,没有理解清楚,,, 结果一直改一直交,,wa了4次才交上,,, 注意: 为了使用树状数组,我们要按照e从大到小排序.但s要从小到大.(我开始的时候错在这里了) 代码如下: #inclu ...

  8. 使用gson在解析unicode时遇到的问题

    之前在用gson解析的时候未记录下来,所以今天做一个小的总结, 比如遇到像这种"\u003d"的unicode的字符,我们想解码这个字符,用gson可以这样表达 Gson gson ...

  9. [leetcode 34] search for a range

    1 题目: Given a sorted array of integers, find the starting and ending position of a given target valu ...

  10. Java中类继承、接口实现的一些细节(长期更新)

    前言 在Java中,子类继承父类,类实现接口是属于常识性的内容了,作为一个Java程序员应该也比较熟悉.不过子类继承父类,类实现接口中还是有一些小细节值得注意一下,本文就从个人工作.学习中入手,总结一 ...