2014牡丹江网络赛ZOJPretty Poem(暴力枚举)
/*
将给定的一个字符串分解成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(暴力枚举)的更多相关文章
- 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...
- zoj 3809 枚举水题 (2014牡丹江网赛 A题)
题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...
- 2013 acm 长沙网络赛 G题 素数+枚举 Goldbach
题目 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3856 先预处理求出两个素数的和与积,然后枚举n-prime和n/pr ...
- 2014 牡丹江区域赛 B D I
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...
- ACM-ICPC北京赛区(2017)网络赛1【模拟+枚举+数组操作】
题目1 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for n ...
- 2014牡丹江 现场赛 F zoj 3824 Fiber-optic Network
首先赞一下题目, 好题 题意: Marjar University has decided to upgrade the infrastructure of school intranet by us ...
- zoj 3820(2014牡丹江现场赛B题)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...
- 2014牡丹江网络zoj3816Generalized Palindromic Number(dfs或者bfs)
#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> ...
随机推荐
- SSM+DUBBO/ZK异常
1.Could not find resource(mybatis本身不支持通配符,是spring提供的ant匹配法) 2.ClassNotFoundException: org.I0Itec.zkc ...
- Bookstore project using XAMPP 详细配置 Part 3
3. Create PHP 1) “Sublime Text” is used as text editor. 2) HTML part of “hello.php” was created as s ...
- Webalizer中文安装解析IP配置
之前安装的都是英文的,现在替换成中文的,并且新增ip位置解析 参考地址 : http://haolulu.blog.51cto.com/3164472/630894 1.安装webalizer所需的 ...
- xml笔记
<?xml version="1.0" encoding="UTF-8"?> ----------------------------------- ...
- Icident event 分析
现象 备库中断,显示如下错误 Connect_Retry: 60 Master_Log_File: mysql-bin.000185 Read_Master_Log_Pos: 308647804 Re ...
- C#异常Retry通用类
系统里面常常调用服务和读写文件里面需要对发生异常,操作失败时进行Retry来尽可能程序的健壮性.最近工作中遇到了,参考了网上的资料,扩展了下.在博客里面备用下: //Retry机制 public st ...
- StrongSwan 5.1.1 发布,Linux 的 IPsec 项目
StrongSwan是一个完整的2.4和2.6的Linux内核下的IPsec和IKEv1 的实现.它也完全支持新的IKEv2协议的Linux 2.6内核.结合IKEv1和IKEv2模式与大多数其他基于 ...
- RCP:美化基于eclipse3.7.2的RCP界面
从e4开始,eclipse rcp界面具备了深度自定义的能力. 但是在eclipse3.7.2上,几乎没有提供能够用于修改界面的外部接口. 这里介绍一种方式来自定义你自己的eclipse rcp. 先 ...
- UWP?UWP! - Build 2015有些啥?(1)
UWP?UWP! - Build 2015有些啥? Build 2015圆满落幕了,不知大家有多少人刷夜看了直播呢?不管怎么说,想必各位都很好奇在这场微软开发者盛宴上,Microsoft又发布了什么令 ...
- require、module、exports dojo中的三个特殊模块标识
查看dojo源码过程中,发现这三个模块名并不以dojo.dijit.dojox开头,在dojo加载器中属于特殊模块名. require 这是一个上下文智能的加载器. 我们通过dojoConfig配置了 ...