All in All(模拟)
2015-10-08 15:58
495 查看
C - All in AllTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d& %I64uSubmit Status Practice POJ1936Appoint description: System Crawler (2015-10-03)DescriptionYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted intothe original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string. Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s. InputThe input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The length of s and t will no more than 100000.OutputFor each test case output "Yes", if s is a subsequence of t,otherwise output "No".Sample Input
sequence subsequence person compression VERDI vivaVittorioEmanueleReDiItalia caseDoesMatter CaseDoesMatterSample Output
Yes No Yes No
AC代码:
#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>#include<vector>#include<cmath>using namespace std;#define T 100005#define inf 0x3f3f3f3f#define CRL(a) memset(a,inf,sizeof(a))typedef long long ll;int main(){/*freopen("input.txt","r",stdin);*/char s[T],t[T];int i,j,k;while(~scanf("%s%s",&s,&t)){for(i=0,k=0;t[i]&&s[k];++i){if(s[k]==t[i]){k++;}}if(s[k]=='\0')printf("Yes\n");elseprintf("No\n");}return 0;}
相关文章推荐
- Lua教程(七):数据结构详解
- 解析从源码分析常见的基于Array的数据结构动态扩容机制的详解
- C#数据结构揭秘一
- 数据结构之Treap详解
- JavaScript数据结构和算法之图和图算法
- Java数据结构及算法实例:冒泡排序 Bubble Sort
- Java数据结构及算法实例:插入排序 Insertion Sort
- Java数据结构及算法实例:考拉兹猜想 Collatz Conjecture
- java数据结构之java实现栈
- java数据结构之实现双向链表的示例
- Java数据结构及算法实例:选择排序 Selection Sort
- Java数据结构及算法实例:朴素字符匹配 Brute Force
- Java数据结构及算法实例:汉诺塔问题 Hanoi
- Java数据结构及算法实例:快速计算二进制数中1的个数(Fast Bit Counting)
- java数据结构和算法学习之汉诺塔示例
- Java数据结构及算法实例:三角数字
- Java数据结构之简单链表的定义与实现方法示例
- 数据结构之AVL树详解
- qqwry.dat的数据结构图文解释第1/2页
- JavaScript中数据结构与算法(五):经典KMP算法