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. Linux C 程序 函数,数组,指针,gdb调试器(SEVEN)

    函数,数组,指针,gdb调试器 1.函数定义 如果明确指定返回类型,默认为int 参数传递:实参对形参的参数传递是单向的,实参只是把自己的值赋给形参.                      形参的 ...

  2. [转]LoadRunner脚本录制常见问题整理

    LoadRunner脚本录制常见问题整理 1.LoadRunner录制脚本时为什么不弹出IE浏览器? 当一台主机上安装多个浏览器时,LoadRunner录制脚本经常遇到不能打开浏览器的情况,可以用下面 ...

  3. Python设计模式——单例模式

    单例模式是日常应用中最广泛的模式了,其目的就是令到单个进程中只存在一个类的实例,从而可以实现数据的共享,节省系统开销,防止io阻塞等等 但是在多进程的应用中,单例模式就实现不了了,例如一些web应用, ...

  4. 七,WPF的元素绑定

    数据绑定是一种关系,该关系告诉WPF从一个源对象提取一些信息,并使用这些信息设置目标对象的属性,目标属性总是依赖项属性,然而,源对象可以是任何内容. 源对象是WPF元素并且源属性是依赖项属性的数据绑定 ...

  5. EventLog组件

    1.使用EventLog组件读写事件日志 SourceExists方法  确定事件源是否已在本地计算机上注册 DeleteEventSource方法  用于从事件日志中移除应用程序的事件源注册 pri ...

  6. 什么是UI控件

    凡是带有Widget参数的组件都是控件.

  7. Bootstrap 分页功能

    function bootstrappage() { var options = { currentPage: currentPage, totalPages: totalPages, size: ' ...

  8. [cc150] 括号问题

    Implement an algorithm to print all valid ( properly opened and closed) combinations of n-pairs of p ...

  9. IIS的Unicode漏洞攻击

    IIS有十多种常见漏洞,但利用得最多的莫过于Unicode解析错误漏洞.微软IIS 4.0/5.0在Unicode字符解码的实现中存在一个安全漏洞,用户可以远程通过IIS执行任意命令.当IIS打开文件 ...

  10. jquery prop and attr

    http://www.javascript100.com/?p=877 http://blog.sina.com.cn/s/blog_655388ed01017cnc.html http://www. ...