DP:

According to the meaning of problems,if we check n to m, assume x and y are both solvable,then we only should:



(1). check  xy;

(2). check AxA

(3). check AxAyA



if any one of the three is solvable ,  n to m is solvable



#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 200;
char str[MAXN], dp[MAXN][MAXN];
bool dfs(int n, int m){
if(n > m) return true;
if(n == m) return false;
if(dp[n][m] == 1) return true;
if(dp[n][m] == -1) return false;
for(int i = n+1;i < m-1;i ++){
if(dfs(n, i) && dfs(i+1, m)){ //check xy;
dp[n][m] = 1;
return true;
}
}
if(str[n] == str[m]){
if(dfs(n+1, m-1)){ //check AxA
dp[n][m] = 1;
return true;;
}
for(int i = n+1;i < m;i ++){
if(str[i] != str[n]) continue;
if(dfs(n+1, i-1) && dfs(i+1, m-1)){ //check AxAyA
dp[n][m] = 1;
return true;
}
}
}
dp[n][m] = -1;
return false;
}
int main(){
memset(str, 0, sizeof(str));
freopen("in.c", "r", stdin);
while(~scanf("%s", str)){
memset(dp, 0, sizeof(dp));
int len = strlen(str);
if(dfs(0, len-1)) printf("solvable\n");
else printf("unsolvable\n");
}
return 0;
}

HDU 3427的更多相关文章

  1. (二分搜索 )Strange fuction -- HDU -- 2899

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2899 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  2. HDU 5641 King's Phone 模拟

    King's Phone 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5641 Description In a military parade, ...

  3. HDU 4391 Paint The Wall(分块+延迟标记)

    Paint The Wall Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. tomcat 192.168.1.110?不烦吗?

    最近做一个在线播放器,因为要用到网络服务器做在线播放,又不想直接在本地用tomcat做实验,因为没有真实感. so,手边两台电脑,同时连在局域网. 客户端,笔记本,ip1:192.168.1.101 ...

  2. 解决ie8不兼容jquery trim问题

    /*为原形添加方法*/String.prototype.trimBoth = function() { return this.replace(/(^\s*)|(\s*$)/g, "&quo ...

  3. prefix和unprefix

    exports._esModule = true; exports.default = { prefix: function prefix(prop){ if (prop[0] === '-'){ v ...

  4. 判断浏览器是否支持某个css3属性的javascript方法

    判断浏览器是否支持css3某个属性的方法: /** * 判断浏览器是否支持某一个CSS3属性 * @param {String} 属性名称 * @return {Boolean} true/false ...

  5. Python原型模式

    如果想根据现有对象复制出新的对象并对其修改,可以考虑原型模式(Prototype Pattern) class Point: __slots__ = ("x", "y&q ...

  6. 【BZOJ】1044: [HAOI2008]木棍分割 二分+区间DP

    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1044 Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, ...

  7. UrlConnection doPost Https请求 、编码设置

    UrlConnection doPost Https请求 .编码设置 UrlConnection doPost方法 /** * 发送POST请求 * * @param url 请求地址url * @p ...

  8. 记一次Oracle数据库迁移部署

    --20141230部署脚本(按照时间顺序从上往下) --命令行,导出要部署的数据库数据(无分号) --expdp RMB3/test123@orcl3 SCHEMAS=RMB3 directory= ...

  9. aircrack-ng on OSX 从零开始之安装

    今天在知乎上看到了Evil1m0在知乎上写的一个关于无线网入侵的帖子,激起我也想折腾一下想法.其实这个想法已经由来已久了.如今WIFI遍地都有,这里面的安全隐患我真心觉得太大.实在需要舆论来给大家普及 ...

  10. Hadoop集群(第10期)_MySQL关系数据库

    1.MySQL安装 MySQL下载地址:http://www.mysql.com/downloads/ 1.1 Windows平台 1)准备软件 MySQL版本:mysql-5.5.21-win32. ...