当前位置:网站首页>hdu4545 魔法串
hdu4545 魔法串
2022-08-05 10:56:00 【51CTO】
魔法串
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1846 Accepted Submission(s): 692
Problem Description
小明和他的好朋友小西在玩一个新的游戏,由小西给出一个由小写字母构成的字符串,小明给出另一个比小西更长的字符串,也由小写字母组成,如果能通过魔法转换使小明的串和小西的变成同一个,那么他们两个人都会很开心。这里魔法指的是小明的串可以任意删掉某个字符,或者把某些字符对照字符变化表变化。如:
小西的串是 abba;
小明的串是 addba;
字符变化表 d b (表示d能转换成b)。
那么小明可以通过删掉第一个d,然后将第二个d转换成b将串变成abba。
现在请你帮忙判断:他们能不能通过魔法转换使两个人的串变成一样呢?
Input
首先输入T,表示总共有T组测试数据(T <= 40)。
接下来共T组数据,每组数据第一行输入小西的字符串,第二行输入小明的字符串(数据保证字符串长度不超过1000,小明的串的长度大于等于小西的,且所有字符均为小写字母)。接着输入字母表,先输入m,表示有m个字符变换方式(m< = 100),接着m行每行输入两个小写字母,表示前一个可以变为后一个(但并不代表后一个能变成前一个)。
Output
对于每组数据,先输出Case数。
如果可以通过魔法转换使两个人的串变成一样,输出“happy”,
否则输出“unhappy”。
每组数据占一行,具体输出格式参见样例。
Sample Input
2 abba addba 1 d b a dd 0
Sample Output
Case #1: happy Case #2: unhappy
Recommend
liuyiding | We have carefully selected several similar problems for you
Statistic |
Submit |
Discuss |
Note
同学问我的。根据她的代码改的。
边栏推荐
- Http-Sumggling缓存漏洞分析
- Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
- [Android]如何使用RecycleView in Kotlin project
- 012_SSS_ Improving Diffusion Model Efficiency Through Patching
- 第四章:activiti RuntimeService设置获和取流程变量,及与taskService的区别,开始和完成任务时设置流程变量[通俗易懂]
- JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
- Chapter 4: In the activiti process, variable transmission and acquisition process variables, setting and acquiring multiple process variables, setting and acquiring local process variables "recommende
- 图像分割模型——segmentation_models_pytorch和albumentations 组合实现多类别分割
- Linux:记一次CentOS7安装MySQL8(博客合集)
- 反射修改jsessionid实现Session共享
猜你喜欢

SQL Outer Join Intersection, Union, Difference Query

linux下oracle常见操作以及日常积累知识点(函数、定时任务)

数据可视化(二)

RT - Thread record (a, RT, RT Thread version - Thread Studio development environment and cooperate CubeMX quick-and-dirty)

PCB layout must know: teach you to correctly lay out the circuit board of the op amp

Huawei's lightweight neural network architecture GhostNet has been upgraded again, and G-GhostNet (IJCV22) has shown its talents on the GPU

产品太多了,如何实现一次登录多产品互通?

Voice-based social software development - making the most of its value

sqlserver编写通用脚本实现获取一年前日期的方法

Opencv图像缩放和平移
随机推荐
How OpenHarmony Query Device Type
SMB + SMB2: Accessing shares return an error after prolonged idle period
L2-042 老板的作息表
5G NR 系统消息
STM32入门开发:编写XPT2046电阻触摸屏驱动(模拟SPI)
E-sports, convenience, efficiency, security, key words for OriginOS functions
【OpenCV】-仿射变换
Create a Dapp, why choose Polkadot?
.NET深入解析LINQ框架(六:LINQ执行表达式)
工程设备在线监测管理系统自动预警功能
反射修改jsessionid实现Session共享
第七章,activiti个人任务分配,动态指定和监听器指定任务委派人「建议收藏」
《分布式云最佳实践》分论坛,8 月 11 日深圳见
Data Middle Office Construction (10): Data Security Management
化繁为简!阿里新产亿级流量系统设计核心原理高级笔记(终极版)
阿里全新推出:微服务突击手册,把所有操作都写出来了PDF
Custom filters and interceptors implement ThreadLocal thread closure
How to choose coins and determine the corresponding strategy research
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
张朝阳对话俞敏洪:一边是手推物理公式,一边是古诗信手拈来