hdu-5707-Combine String
题意:给你三个字符串,让你计算1 2 串和3 串是否匹配,就是3串可以分解为 1 2 串,字母顺序必须是按照1 2 串的字母前后顺序。
DP代码太深奥 看不太透,这个代码比较好理解一点:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<iostream>
#include<ctype.h>
#include<map>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
using namespace std;
map<char,int>ma,mc;
int main()
{
int i,j,k;
string a,b,c;
while(cin>>a>>b>>c)
{
ma.clear();
mc.clear();
int lea=a.size();
int leb=b.size();
int lec=c.size();
for(i=;i<lea;i++)
ma[a[i]]++;
for(i=;i<leb;i++)
ma[b[i]]++;
int x=;
int y=;
for(i=;i<lec;i++)
{
mc[c[i]]++;
if(x<lea&&c[i]==a[x])
x++;
if(y<leb&&c[i]==b[y])
y++; }
int fl=;
map<char,int>::iterator tt;
for(tt=mc.begin();tt!=mc.end();tt++)
{
if(mc[tt->first]!=ma[tt->first])
{
fl=;
break;
}
}
if(fl)
{
if(x==lea&&y==leb)
printf("Yes\n");
else
printf("No\n");
}
else
printf("No\n");
}
}
hdu-5707-Combine String的更多相关文章
- HDU 5707 Combine String(动态规划)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5707 题意: 给你三个字符串 S1, S2, S3, 让你判断 S3 是否恰好由字符串 S1 和 S2 ...
- HDU 5707 Combine String (DP,LCS变形)
题意:给定三个字符串,问你第三个是不是由第一个和第二个组成的. 析:当时比赛是没有做出来啊...一直WA,就是没有判断长度,第一个和第二个和是不是和第三个一样,这个忘记... 我们用d[i][j]表示 ...
- Combine String HDU - 5707 dp or 广搜
Combine String HDU - 5707 题目大意:给你三个串a,b,c,问a和b是不是恰好能组成c,也就是a,b是不是c的两个互补的子序列. 根据题意就可以知道对于c的第一个就应该是a第一 ...
- HDU 4054 Number String
HDU 4054 Number String 思路: 状态:dp[i][j]表示以j结尾i的排列 状态转移: 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][j-1] + ...
- 使用System.IO.Combine(string path1, string path2, string path3)四个参数的重载函数提示`System.IO.Path.Combine(string, string, string, string)' is inaccessible due to its protection level
今天用Unity5.5.1开发提取Assets目录的模块,使用时采用System.IO.Path.Combine(string, string, string, string)函数进行路径生成 明明是 ...
- hdu 5311 Hidden String
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Description Today is the 1st anniv ...
- hdu 5311 Hidden String (BestCoder 1st Anniversary ($))(深搜)
http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 5311 Hidden String (暴力)
题意:今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下 ...
- HDU 4668 Finding string (解析字符串 + KMP)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意:给出一个压缩后的串,以及一个模式串,问模式串 ...
- HDU 5694 BD String 迭代
BD String 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5694 Description Problem Description 众所周知, ...
随机推荐
- Django之MVC和MTV
一. MVC MVC 是一种使用 MVC(Model View Controller 模型-视图-控制器)设计创建 Web 应用程序的模式: Model(模型)表示应用程序核心(比如数据库记录列表). ...
- Python进阶【第十一篇】模块(下)之常用模块
内置模块是Python自带的功能,在使用内置模块相应的功能时,需要[先导入]再[使用] 一.time模块 在Python中,通常有这几种方式来表示时间: 时间戳(timestamp):通常来说,时间戳 ...
- USB开发库STSW-STM32121文件分析(转)
源: USB开发库STSW-STM32121文件分析
- IDEA之HttpServletRequest之报错解决方案
@Controller public class UserController { @RequestMapping("/selectUser") public String sel ...
- 2019/3/19 wen 运算符
- 01:CENTOS使用VIRTUALENV搭建独立的PYTHON环境-PYTHON虚拟环境
1.1 安装virtualenv环境 https://www.cnblogs.com/liuyansheng/p/6141197.html 1.安装virtualenv yum install pyt ...
- 【Python026--字典内键方法】
一,内键方法 1.fromkeys(...) 语法:dict1.fromkeys(s[,v]):s指的是字典的键值,[,v]指的是可选项(值),[,v]不填写的话默认为none #不填写第二个值,默认 ...
- spring启动后立即执行方法
1.方法所属的类继承InitializingBean接口. 2.重写afterPropertiesSet()方法. afterPropertiesSet方法会在bean被初始化时执行. 当bean的作 ...
- oracle数据库的一个表中,怎么设置字段的默认值
如果表已经存在,用如下方法设置默认值. alter table 表名 modify 字段名 default 默认值; 如test表中设置address字段为'浙江省',可用如下语句: alter ta ...
- 浅尝flutter中的http请求
import 'package:flutter/material.dart'; class News extends StatefulWidget { final String title,imgli ...