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

    All in All
    Time Limit: 1000MS   Memory Limit: 30000K
    Total Submissions: 27556   Accepted: 11286

    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 <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #define M 100005
     5 char s[M]={0},t[M]={0};
     6 using namespace std;
     7 int main()
     8 {
     9     while(scanf("%s %s",s,t)!=EOF){
    10         int i,j;
    11         i=j=0;
    12         while(s[i]&&t[j]){
    13             if(s[i]==t[j]){
    14                 i++;
    15                 j++;
    16             }
    17             else j++;
    18         }
    19         if(s[i])
    20             printf("No
    ");
    21         else printf("Yes
    ");
    22         memset(s,0,sizeof(s));
    23         memset(t,0,sizeof(t));
    24     }
    25     return 0;
    26 }
    View Code
  • 相关阅读:
    个人阅读作业
    软件工程基础/个人项目1
    个人阅读作业3
    个人阅读作业2
    代码复审
    软件工程:结对编程1
    个人阅读作业
    软工作业1:单词统计
    有关敏捷开发的一点感想[110617班 刘耀先]
    Pair Project: Elevator Scheduler [电梯调度算法的实现和测试][关于电梯调度算法的附加思考]:刘耀先-11061183,罗凡-11061174
  • 原文地址:https://www.cnblogs.com/ubuntu-kevin/p/3856030.html
Copyright © 2011-2022 走看看