2016搜索提高1010
来源:互联网 发布:我的淘宝订单 编辑:程序博客网 时间:2024/06/05 03:20
Zipper
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 93 Accepted Submission(s) : 40
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
For example, consider forming "tcraete" from "cat" and "tree":
String A: cat
String B: tree
String C: tcraete
As you can see, we can form the third string by alternating characters from the two strings. As a second example, consider forming "catrtee" from "cat" and "tree":
String A: cat
String B: tree
String C: catrtee
Finally, notice that it is impossible to form "cttaree" from "cat" and "tree".
Input
For each data set, the line of input consists of three strings, separated by a single space. All strings are composed of upper and lower case letters only. The length of the third string is always the sum of the lengths of the first two strings. The first two strings will have lengths between 1 and 200 characters, inclusive.
Output
Data set n: yes
if the third string can be formed from the first two, or
Data set n: no
if it cannot. Of course n should be replaced by the data set number. See the sample output below for an example.
Sample Input
3cat tree tcraetecat tree catrteecat tree cttaree
Sample Output
Data set 1: yesData set 2: yesData set 3: no
思路:直接暴力搜索即可,标记搜索的地方;
代码:
#include <iostream>#include <stdio.h>#include <string.h>#include <cmath>#include <queue>#include <stdlib.h>#include <set>#define pi acos(-1.0)using namespace std;char a[201],b[201],c[402];int m,n,k;int e[202][202];int dfs(int x,int y,int z){ if(z==k)return 1; if(e[x][y])return 0; e[x][y]=1; if(c[z]==a[x]&&dfs(x+1,y,z+1))return 1; if(c[z]==b[y]&&dfs(x,y+1,z+1))return 1; return 0;}int main(){ int t; cin>>t; int p=1; while(t--) { cin>>a>>b>>c; m=strlen(a); n=strlen(b); k=strlen(c); memset(e,0,sizeof(e)); printf("Data set %d: ",p); if(dfs(0,0,0)) { cout<<"yes"<<endl; } else cout<<"no"<<endl; p++; } return 0;}
- 2016搜索提高1010
- 2016搜索提高1017
- 2016搜索提高1003
- 2016搜索提高1008
- 2016搜索提高1001
- 2016搜索提高1004
- 提高搜索性能方式
- nutch 提高搜索精度
- nutch 提高搜索精度
- 提高solr的搜索速度
- 提高coreseek的搜索精度
- 提高solr的搜索速度
- Search Algorithm-搜索提高专题
- Android提高 - 浮动搜索框
- 颠倒关键词顺序提高网页搜索质量
- 如何提高和优化Lucene搜索速度
- 自定义评分器Similarity,提高搜索体验
- 自定义评分器Similarity,提高搜索体验
- React Native与OC之间通信那些事
- linu操作系统基础
- 刷清橙OJ--A1004.画长方形2
- 限制键盘只能按数字键、小键盘数字键、退格键
- Numpy 学习指南 学习笔记(一)
- 2016搜索提高1010
- spring最新版本下载地址
- 无法解析的外部符号 _WinMain@16
- 496. Next Greater Element I -- 栈
- 布署UEditor到Web项目中时报错:Uploader同时存在于……
- c/c++内存释放知识总结
- 关于点击按钮刷新问题
- 自修
- TP5路由问题