/*
  将给定的一个字符串分解成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. oracle 读书笔记

    1 动态sql即拼接字符串的sql,使用变量代替具体值,10万条语句可以被hash陈一个SQL_ID,可以只解析一次 for i in 1..100000 loop execute immediate ...

  2. 【Java】深深跪了,OJ题目Java与C运行效率对比(附带清华北大OJ内存计算的对比)

    看了园友的评论之后,我也好奇清橙OJ是怎么计算内存占用的.重新测试的情况附在原文后边. -------------------------------------- 这是切割线 ----------- ...

  3. 【整理】--C++三种参数传递方式

    在C++中,共有三种参数传递方式: 按值传递(pass by value) 地址传递(pass by pointer) 引用传递(pass by reference) (1)按值传递的过程为:首先计算 ...

  4. LNMP 部署

    一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.servic ...

  5. unity渲染层级关系小结(转存)

    最近连续遇到了几个绘制图像之间相互遮挡关系不正确的问题,网上查找的信息比较凌乱,所以这里就把自己解决问题中总结的经验记录下来. Unity中的渲染顺序自上而下大致分为三层. 最高层为Camera层,可 ...

  6. 移动开发发展方向-----Hybird混合开发3大方案

    移动开发发展方向-----Hybird混合开发3大方案

  7. Java多线程17:中断机制

    概述 之前讲解Thread类中方法的时候,interrupt().interrupted().isInterrupted()三个方法没有讲得很清楚,只是提了一下.现在把这三个方法同一放到这里来讲,因为 ...

  8. 【C语言学习】《C Primer Plus》第10章 数组和指针

    学习总结 1.数组初始化方式: int a[]={1,2,3} int a[SIZE]={1,2,3} //SIZE是宏定义,数组初始化个数不能大于SIZE,否则报错:当个数小 //SIZE,自动补0 ...

  9. 初探ECMAScript6

    基础变化 String类型新增了三个方法,不必使用indexOf来判断一个字符串是否在另一个字符串内 //String changes var a = "Hello world"; ...

  10. 前端自动化测试工具doh学习总结(二)

    一.robot简介 robot是dojo框架中用来进行前端自动化测试的工具,doh主要目的在于单元测试,而robot可以用来模仿用户操作来测试UI.总所周知,Selenium也是一款比较流行的前端自动 ...