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,并且字典数最小 ...
随机推荐
- CentOS6.4中安装Python-Pip 以及Phyton gevent
一.安装Phyton-pip 首先要安装 Setuptools wget --no-check-certificate https://pypi.python.org/packages/2.6/s/s ...
- NSThread 的用法
一.线程的注意点: 1.不要同时开太多的线程(最多不要超过5条,其中包括主线程) 2.线程概念 2.1.主线程:UI 线程,显示.刷新 UI 界面,处理 UI 控件的事件 2.2.子线程:后台线程,异 ...
- Idea facet
idea错误:this inspection controls whether the persistence ql queries are error-checked 在project struct ...
- Python核心编程读笔 9: 异常
第10章 异常一.异常1 检测和处理异常 (1)try-except语句 try: try_suite #监控这里的异常 except Exception[, reason]: except_suit ...
- hdu4507
数位dp,终于守得云开见月明了.建议初学者先试试两道比较简单的hdu2089,hdu3555. 鸣谢:http://blog.csdn.net/acm_cxlove/article/details/8 ...
- NULL、空指针,’\0’,0的去区别
http://blog.csdn.net/bailyzheng/article/details/7677628参考该博客 NULL是空指针常量.
- Oracle学习之start with...connect by子句的用法
转自:http://www.blogjava.net/xzclog/archive/2010/03/05/314642.html,多谢博主分享 Oracle中start with…connect by ...
- Linux学习之nfs实例
在对exports文件进行了正确的配置后,就可以启动NFS服务器了. 1.启动NFS服务器 为了使NFS服务器能正常工作,需要启动portmap和nfs两个服务,并且portmap一定要先于nfs启动 ...
- Linux Mysql 总结
一:Error Code: . Access denied for user 'root'@'%' to database ① mysql -u root -p 进入到mysql中 ②SELECT h ...
- src 和 href 的区别
因为理解不深,到写外部加载Javascript文件或者css文件的时候总是需要去找个例子,这样可不好.现在总结下 href 属性规定被链接文档的位置(URL). href是hyperrefresh的缩 ...