zoukankan      html  css  js  c++  java
  • poj 1936 All in All

    Description

    You 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 into the 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.

    Input

    The 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.

    Output

    For 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
    
     1 #include<stdio.h>
     2 #include<string.h>
     3 #define MAX 100005
     4 char str1[MAX],str2[MAX];
     5 int main()
     6 {
     7     int i,j;
     8     int len1,len2;
     9     while(~scanf("%s %s",str1,str2))
    10     {
    11         len1=strlen(str1);
    12         len2=strlen(str2);
    13         j=0;
    14         for(i=0;i<len2;i++)
    15         {
    16             if(str2[i]==str1[j])j++;
    17         }
    18         if(j==len1)printf("Yes
    ");
    19         else printf("No
    ");
    20     }return 0;
    21 }
  • 相关阅读:
    虚函数
    类的继承
    析构
    构造
    枚举类型
    c++中的静态类型 static
    c++中的类
    sizeof和strlen的区别
    剑指36 二叉搜索书与双向链表
    剑指35 复杂链表的复制
  • 原文地址:https://www.cnblogs.com/wlc297984368/p/3267152.html
Copyright © 2011-2022 走看看