UVa 10340 - All in All

来源:互联网 发布:噪声测量软件 编辑:程序博客网 时间:2024/05/16 07:53

Problem E

All in All

Input: standard input

Output: standard output

Time Limit: 2 seconds

Memory Limit: 32 MB

You have devised a new encryption technique whichencodes a message by inserting between its characters randomly generatedstrings in a clever way. Because of pending patent issues we will not discussin detail how the strings are generated and inserted into the original message.To validate your method, however, it is necessary to write a program thatchecks if the message is really encoded in the final string.

Given two strings s and t, you haveto decide whether s is a subsequence oft, i.e. if you can removecharacters from t such that the concatenation of the remainingcharacters iss.

Input Specification

The input contains several testcases. Each isspecified by two strings s, t of alphanumeric ASCII characters separatedby whitespace. Input is terminated by EOF.

Output Specification

For each test case output, if s is asubsequence of t.

Sample Input

sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

SampleOutput

Yes
No
Yes
No

Source: ULM Local Contest

 
#include <stdio.h>#include <string.h>#include <math.h>char s1[1000000],s2[1000000];int main(){    int i,j,n,m,s,t;    int l1,l2;    while(scanf("%s %s",s1,s2)!=EOF)    {        l1=strlen(s1);        l2=strlen(s2);        for(i=0,j=0;j<=l2-1&&i<=l1-1;j++)        {            if(s2[j]==s1[i])            {                i++;            }        }        if(i==l1)        {            printf("Yes\n");        }else        {            printf("No\n");        }    }    return 0;}

原创粉丝点击