POJ-2192-Polygon
来源:互联网 发布:sql游标的用法 编辑:程序博客网 时间:2024/06/09 16:57
题意:就是用前面两个字符串按照字符的顺序呢拼接成第三个字符串,如果可以输出yes,否则no.
从每个字符的第一个字母开始搜索,相同的字母,对应的下标都+1,看最后能不能找到最后一个
字符串的字母的下标。有一个剪枝就是在如果最后一个字符串的倒数第一个字母跟前面两个字符
串的字母都不样的时候直接输出no.
#include<stdio.h>#include<string.h>const int maxn=1001;char a[maxn],b[maxn],c[maxn];int c1,c2,c3;int dfs(int x,int y,int n){ if(n==c3) return 1; if(a[x]!=c[n]&&b[y]!=c[n]) return 0; if(a[x]==c[n]&&dfs(x+1,y,n+1)) return 1; if(b[y]==c[n]&&dfs(x,y+1,n+1)) return 1; return 0;}int main(){ int t,kj=1; scanf("%d",&t); while(t--) { scanf("%s%s%s",a,b,c); c1=strlen(a),c2=strlen(b),c3=strlen(c); printf("Data set %d: ",kj++); if(a[c1-1]!=c[c3-1]&&b[c2-1]!=c[c3-1]) { printf("no\n"); continue; } if(dfs(0,0,0)) printf("yes\n"); else printf("no\n"); } return 0;}
0 0
- POJ-2192-Polygon
- POJ 1179 Polygon
- POJ 1179 Polygon(DP)
- poj 2007 Scrambled Polygon
- poj 1179 Polygon
- POJ 1179 Polygon DP
- poj 2007 Scrambled Polygon
- DP_ poj 1179 Polygon
- poj 3850 Simple Polygon
- POJ 2007 Scrambled Polygon
- POJ 1179 Polygon dp
- POJ 2007 Scrambled Polygon
- POJ 1179 Polygon
- POJ 2007 Scrambled Polygon
- POJ 1179 Polygon (DP)
- poj 1179 Polygon
- POJ 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- hadoop实例
- 腾讯互娱旗下工作室一览
- 位运算
- linux-android移植开发
- maven 与jdk相关的报错 1.3……
- POJ-2192-Polygon
- requestWindowFeature使用详解
- ubuntu升级firefox
- 一键获取所有网址前面的小标志
- Android app 升级:android:versionCode和android:versionName
- Linux下MySQL 5.5.11源码编译安装笔记
- POJ 3278: Catch That Cow
- Day1 - A - Painting the sticks
- PHP学习实例—5(日历类的编写)