您的位置:首页 > 理论基础 > 数据结构算法

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 CaseDoesMatter
Sample 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;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  poj 数据结构