hdu 4545 魔法串 2013金山西山居创意游戏程序挑战赛——初赛(1)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4545
这题太坑了,小明的串可以任意删掉某个字符 这句话不知道大家是怎么理解的,我觉得应该是能够删除其中的一种字符,但是个数不限。
AC:直接模拟,相同或是能够转换得到就往后继续,不能就删除小明的,然后在判断。
坑死了。。。。。。。祭恋
- #include <cstdio>
- #include <cstring>
- #include <iostream>
- using namespace std;
- #define MAX 1005
- char ch[][];
- char ch1[MAX];
- char ch2[MAX];
- int m;
- bool judge(char a,char b);
- int main()
- {
- //freopen("1.txt","r",stdin);
- // freopen("1.txt","w",stdout);
- int t;
- int x = ;
- scanf("%d",&t);
- int len1,len2;
- while(t--)
- {
- scanf("%s%s",ch1,ch2);
- scanf("%d",&m);
- memset(ch,'',sizeof(ch));
- for(int i = ; i < m; i++)
- {
- getchar();
- ch[i][] = getchar();
- getchar();
- ch[i][] = getchar();
- }
- len1 = strlen(ch1);
- len2 = strlen(ch2);
- int i,j;
- bool flag = true,flag1 = true;
- char flag_ch;
- for(i = ,j = ; i < len1&& j < len2; )
- {
- if(ch1[i] == ch2[j])
- {
- i++;
- j++;
- }
- else
- {
- bool judge_x = judge(ch2[j],ch1[i]);
- if(judge_x)
- {
- i++;
- j++;
- }
- else
- {
- j++;
- }
- }
- }
- if(i < len1) flag = false;
- if(flag)
- printf("Case #%d: happy",x++);
- else
- printf("Case #%d: unhappy",x++);
- printf("\n");
- }
- return ;
- }
- bool judge(char a,char b)
- {
- for(int i = ; i < m; i++)
- {
- if(ch[i][] == a && ch[i][] == b)
- return true;
- }
- return false;
- }
hdu 4545 魔法串 2013金山西山居创意游戏程序挑战赛——初赛(1)的更多相关文章
- hdu 4545 魔法串
http://acm.hdu.edu.cn/showproblem.php?pid=4545 #include <cstdio> #include <cstring> #inc ...
- hdu----(4545)魔法串(LCS)
魔法串 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...
- 魔法串(hud4545)
魔法串 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...
- 人人,金山西山居,腾讯互娱,微信,网易游戏offer及面经
转自:http://www.itmian4.com/forum.php?mod=viewthread&tid=3985 首先感谢师兄在两年前发的贴([天道酬勤] 腾讯.百度.网易游戏.华为Of ...
- qboimathtest1 t1 魔法串
题目 小 N 最近在沉迷数学问题. 对于一个数字串 S,如果可以将它划分成两个数字 A.B,满足: 1. S=AB. 2. A.B 均不包含前导 0. 3. B 是 A 的倍数,且B / A是完全立方 ...
- 确定两串乱序同构 牛客网 程序员面试金典 C++ Python
确定两串乱序同构 牛客网 程序员面试金典 C++ Python 题目描述 给定两个字符串,请编写程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串.这里规定大小写为不同字符,且考虑字符串中 ...
- HDU 4545 (模拟) 魔法串
题目链接 Problem Description 小明和他的好朋友小西在玩一个新的游戏,由小西给出一个由小写字母构成的字符串,小明给出另一个比小西更长的字符串,也由小写字母组成,如果能通过魔法转换使小 ...
- hdu 2197 本原串
http://acm.hdu.edu.cn/showproblem.php?pid=2197 长度为n的01串有2的n次方个,再减去不符合要求的.不符合要求的字符串就是长度为n的约数的字符串. 递归处 ...
- HDU 4731 Minimum palindrome 2013 ACM/ICPC 成都网络赛
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4731 题解:规律题,我们可以发现当m大于等于3时,abcabcabc……这个串的回文为1,并且字典数最小 ...
随机推荐
- 在PreparedStatement中设置空值
在PreparedStatement中设置空值 分类: Work& Study java2009-09-10 09:56 922人阅读 评论(0) 收藏 举报 nulltypes数据库 ...
- 在Linux下如何用Shell脚本读写XML?现有一个config.xml(转)
在Linux下如何用Shell脚本读写XML?现有一个config.xml <?xml version="1.0" encoding="UTF-8"?&g ...
- jquery 自动调整图片大小
<script type="text/javascript"> $(document).ready(function(){ $('#cons img').each(fu ...
- Android ORM SQL Top 5
If you are developing an Android application, you will likely need to store data somewhere. You may ...
- 周末苦逼码代码,为css3的强大所颤抖了
周末小哥我看完了几个星期没追的行尸走肉和生活大爆炸(感谢大A站!),感觉生活真的好空虚,没想到我现在居然会对游戏失去了兴趣!!!代码的魔力真的是无法用语言形容...(我真假...)百无聊赖,在电脑上装 ...
- Sencha Touch 之 Ext.ComponentManager.get方法使用
HTML代码: <!doctype html> <html> <head> <meta charset="utf-8"> <t ...
- c/c++:内存泄露和野指针的概念
内存泄漏 用动态存储分配函数动态开辟的空间,在使用完毕后未释放,结果导致一直占据该内存单元.直到程序结束.即所谓内存泄漏. 注意:内存泄漏是指堆内存的泄漏. 简单的说就是申请了一块内存空间,使用 ...
- Python核心编程笔记--unicode编码
#定义编码方式,与物理文件. code='utf-8'file='D:/utf8.txt' #把编码后的字符写入文件. hello_out =u'hello world'bytes_out =hell ...
- JS中String的反转函数
利用prototype封住reverse方法: (求更简便的方法: String.prototype.reverse=function () { var str=""; for(v ...
- android样式跟主题
简单说类似与自定义控件,只不过自定义控件针对的是view 而样式与主题针对的是属性.元素 在TexvView中引入样式 layout.xml <?xml version="1.0&qu ...