hdu 1501 Zipper
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1501
思路:题目要求第三个串由前两个组成,且顺序不能够打乱,搜索大法好
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<vector>
#include<queue>
#include<iterator>
#include<vector>
#include<set>
#define dinf 0x3f3f3f3f
typedef long long ll; using namespace std; char str1[],str2[],str3[];
int flag,visit[][]; void dfs(int i,int j,int k)
{
if(str1[i]== && str2[j]== && str3[k]==)
{
flag=;
return;
}
if(str1[i]!=str2[j] && str1[i]!=str3[k])
return;
if(visit[i][j])
return;
visit[i][j]=;
if(str1[i]==str2[j])
dfs(i+,j+,k);
if(flag)
return;
if(str1[i]==str3[k])
dfs(i+,j,k+);
} int main()
{
int t;
scanf("%d",&t);
for(int i=;i<=t;i++)
{
scanf("%s %s %s",str2,str3,str1);
memset(visit,,sizeof(visit));
flag=;
dfs(,,);
printf("Data set %d: ",i);
if(flag)
printf("yes\n");
else
printf("no\n");
}
return ;
}
hdu 1501 Zipper的更多相关文章
- HDU 1501 Zipper 【DFS+剪枝】
HDU 1501 Zipper [DFS+剪枝] Problem Description Given three strings, you are to determine whether the t ...
- hdu 1501 Zipper dfs
题目链接: HDU - 1501 Given three strings, you are to determine whether the third string can be formed by ...
- HDU 1501 Zipper 动态规划经典
Zipper Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- HDU 1501 Zipper(DP,DFS)
意甲冠军 是否可以由串来推断a,b字符不改变其相对为了获取字符串的组合c 本题有两种解法 DP或者DFS 考虑DP 令d[i][j]表示是否能有a的前i个字符和b的前j个字符组合得到c的前i+j ...
- (step4.3.5)hdu 1501(Zipper——DFS)
题目大意:个字符串.此题是个非常经典的dfs题. 解题思路:DFS 代码如下:有详细的注释 /* * 1501_2.cpp * * Created on: 2013年8月17日 * Author: A ...
- HDU 1501 Zipper 字符串
题目大意:输入有一个T,表示有T组测试数据,然后输入三个字符串,问第三个字符串能否由第一个和第二个字符串拼接而来,拼接的规则是第一个和第二个字符串在新的字符串中的前后的相对的顺序不能改变,问第三个字符 ...
- HDU 1501 Zipper(DFS)
Problem Description Given three strings, you are to determine whether the third string can be formed ...
- hdu 1501 Zipper(DP)
题意: 给三个字符串str1.str2.str3 问str1和str2能否拼接成str3.(拼接的意思可以互相穿插) 能输出YES否则输出NO. 思路: 如果str3是由str1和str2拼接而成,s ...
- HDOJ 1501 Zipper 【简单DP】
HDOJ 1501 Zipper [简单DP] Problem Description Given three strings, you are to determine whether the th ...
随机推荐
- 【原创】相对完美的垂直居中popup(modal/dialog),无需监听window.resize事件
<table class="popup" style="position: absolute; background-color: black; border-ra ...
- Java链栈
package com.lxm.customDataStructure; public class LinkStack<T>{ class Node<T>{ T data; N ...
- 自创yum源
这里我们用U盘装完系统以后,我们要是使用yum命令的话,我们是装不上包的 这个时候我们装系统的时候 [root@kz-002 Packages]# df -h Filesystem Size Used ...
- Webpack--自学笔记
原文--http://webpack.github.io/docs/tutorials/getting-started/ 什么是webpack? webpack是一个模块打包器.webpack把模块( ...
- Mysql 查询练习
Mysql 查询练习 ---创建班级表 create table class( cid int auto_increment primary key, caption ) )engine=innodb ...
- Bzoj3144 [Hnoi2013]切糕
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1494 Solved: 818 Description Input 第一行是三个正整数P,Q,R,表 ...
- unsigned无符号、有符号类型的符号拓展
先看一段代码 #include <stdio.h> main(){ unsigned ; char b = a; printf("%d %d",a,b); ; } a输 ...
- .NET DateTime 显示格式
备注 format 参数应包含单个格式说明符 (请参阅 标准日期和时间格式字符串) 或自定义格式模式 (请参阅 Cadenas con formato de fecha y hora pers ...
- WinForm------GridControl添加底部合计框
1.在GridView属性中找到"OptionsView" => "ShowFooter" = true 2.打开编辑器,如图 . 3.获取统计数据(注意 ...
- js实现文本框中内容的放大显示
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...