zoukankan      html  css  js  c++  java
  • UVA10340 All in All

    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 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 Specification

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

    Output Specification

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

    Sample Input

    sequence subsequence
    person compression
    VERDI vivaVittorioEmanueleReDiItalia
    caseDoesMatter CaseDoesMatter

    Sample Output

    Yes
    No
    Yes
    No

    Source: ULM Local Contest

     题目大意:给定两个字符串,判断第一个字符串的是否是是第二个字符串的子串。
    View Code
     1 #include<stdio.h>
     2 #include<string.h>
     3 #define MAXN 1000000
     4 char s[MAXN],t[MAXN];
     5 int main(void)
     6 {
     7     long i,m;
     8     while(scanf("%s%s",t,s)!=EOF)
     9     {
    10         long len,ll,flag;
    11         len=strlen(t);
    12         ll=strlen(s);
    13         flag=1;
    14         m=0;
    15         for(i=0; i<len; i++)
    16         {
    17             while(t[i]!=s[m]&&m<ll) m++;
    18             if(m==ll)
    19             {
    20                 printf("No\n");
    21                 flag=0;
    22                 break;
    23             }
    24             m++;
    25 
    26         }
    27         if(flag)
    28             printf("Yes\n");
    29     }
    30     return 0;
    31 }
     
  • 相关阅读:
    回调函数实现类似QT中信号机制
    Qt Creator下载和安装(详细教程)
    对象池实现分析
    MongoDB Redis
    双重加锁
    开源项目
    进程创建
    WebAPI性能优化
    StatusCodePagesMiddleware中间件如何针对响应码呈现错误页面
    NET Core + Angular 2
  • 原文地址:https://www.cnblogs.com/zjbztianya/p/2946001.html
Copyright © 2011-2022 走看看