题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4545

这题太坑了,小明的串可以任意删掉某个字符 这句话不知道大家是怎么理解的,我觉得应该是能够删除其中的一种字符,但是个数不限。

AC:直接模拟,相同或是能够转换得到就往后继续,不能就删除小明的,然后在判断。

坑死了。。。。。。。祭恋

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. #define MAX 1005
  8.  
  9. char ch[][];
  10. char ch1[MAX];
  11. char ch2[MAX];
  12. int m;
  13.  
  14. bool judge(char a,char b);
  15. int main()
  16. {
  17. //freopen("1.txt","r",stdin);
  18. // freopen("1.txt","w",stdout);
  19. int t;
  20. int x = ;
  21. scanf("%d",&t);
  22. int len1,len2;
  23.  
  24. while(t--)
  25. {
  26. scanf("%s%s",ch1,ch2);
  27. scanf("%d",&m);
  28. memset(ch,'',sizeof(ch));
  29.  
  30. for(int i = ; i < m; i++)
  31. {
  32. getchar();
  33. ch[i][] = getchar();
  34. getchar();
  35. ch[i][] = getchar();
  36. }
  37.  
  38. len1 = strlen(ch1);
  39. len2 = strlen(ch2);
  40. int i,j;
  41. bool flag = true,flag1 = true;
  42. char flag_ch;
  43. for(i = ,j = ; i < len1&& j < len2; )
  44. {
  45. if(ch1[i] == ch2[j])
  46. {
  47. i++;
  48. j++;
  49. }
  50. else
  51. {
  52. bool judge_x = judge(ch2[j],ch1[i]);
  53.  
  54. if(judge_x)
  55. {
  56. i++;
  57. j++;
  58. }
  59. else
  60. {
  61. j++;
  62. }
  63. }
  64. }
  65.  
  66. if(i < len1) flag = false;
  67.  
  68. if(flag)
  69. printf("Case #%d: happy",x++);
  70. else
  71. printf("Case #%d: unhappy",x++);
  72. printf("\n");
  73. }
  74. return ;
  75. }
  76.  
  77. bool judge(char a,char b)
  78. {
  79. for(int i = ; i < m; i++)
  80. {
  81. if(ch[i][] == a && ch[i][] == b)
  82. return true;
  83. }
  84. return false;
  85. }

hdu 4545 魔法串 2013金山西山居创意游戏程序挑战赛——初赛(1)的更多相关文章

  1. hdu 4545 魔法串

    http://acm.hdu.edu.cn/showproblem.php?pid=4545 #include <cstdio> #include <cstring> #inc ...

  2. hdu----(4545)魔法串(LCS)

    魔法串 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...

  3. 魔法串(hud4545)

    魔法串 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...

  4. 人人,金山西山居,腾讯互娱,微信,网易游戏offer及面经

    转自:http://www.itmian4.com/forum.php?mod=viewthread&tid=3985 首先感谢师兄在两年前发的贴([天道酬勤] 腾讯.百度.网易游戏.华为Of ...

  5. qboimathtest1 t1 魔法串

    题目 小 N 最近在沉迷数学问题. 对于一个数字串 S,如果可以将它划分成两个数字 A.B,满足: 1. S=AB. 2. A.B 均不包含前导 0. 3. B 是 A 的倍数,且B / A是完全立方 ...

  6. 确定两串乱序同构 牛客网 程序员面试金典 C++ Python

    确定两串乱序同构 牛客网 程序员面试金典 C++ Python 题目描述 给定两个字符串,请编写程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串.这里规定大小写为不同字符,且考虑字符串中 ...

  7. HDU 4545 (模拟) 魔法串

    题目链接 Problem Description 小明和他的好朋友小西在玩一个新的游戏,由小西给出一个由小写字母构成的字符串,小明给出另一个比小西更长的字符串,也由小写字母组成,如果能通过魔法转换使小 ...

  8. hdu 2197 本原串

    http://acm.hdu.edu.cn/showproblem.php?pid=2197 长度为n的01串有2的n次方个,再减去不符合要求的.不符合要求的字符串就是长度为n的约数的字符串. 递归处 ...

  9. HDU 4731 Minimum palindrome 2013 ACM/ICPC 成都网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731 题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小 ...

随机推荐

  1. 在PreparedStatement中设置空值

    在PreparedStatement中设置空值 分类: Work&amp Study java2009-09-10 09:56 922人阅读 评论(0) 收藏 举报 nulltypes数据库 ...

  2. 在Linux下如何用Shell脚本读写XML?现有一个config.xml(转)

    在Linux下如何用Shell脚本读写XML?现有一个config.xml <?xml version="1.0" encoding="UTF-8"?&g ...

  3. jquery 自动调整图片大小

    <script type="text/javascript"> $(document).ready(function(){ $('#cons img').each(fu ...

  4. Android ORM SQL Top 5

    If you are developing an Android application, you will likely need to store data somewhere. You may ...

  5. 周末苦逼码代码,为css3的强大所颤抖了

    周末小哥我看完了几个星期没追的行尸走肉和生活大爆炸(感谢大A站!),感觉生活真的好空虚,没想到我现在居然会对游戏失去了兴趣!!!代码的魔力真的是无法用语言形容...(我真假...)百无聊赖,在电脑上装 ...

  6. Sencha Touch 之 Ext.ComponentManager.get方法使用

    HTML代码: <!doctype html> <html> <head> <meta charset="utf-8"> <t ...

  7. c/c++:内存泄露和野指针的概念

    内存泄漏 用动态存储分配函数动态开辟的空间,在使用完毕后未释放,结果导致一直占据该内存单元.直到程序结束.即所谓内存泄漏.    注意:内存泄漏是指堆内存的泄漏. 简单的说就是申请了一块内存空间,使用 ...

  8. Python核心编程笔记--unicode编码

    #定义编码方式,与物理文件. code='utf-8'file='D:/utf8.txt' #把编码后的字符写入文件. hello_out =u'hello world'bytes_out =hell ...

  9. JS中String的反转函数

    利用prototype封住reverse方法: (求更简便的方法: String.prototype.reverse=function () { var str=""; for(v ...

  10. android样式跟主题

    简单说类似与自定义控件,只不过自定义控件针对的是view 而样式与主题针对的是属性.元素 在TexvView中引入样式 layout.xml <?xml version="1.0&qu ...