zoukankan      html  css  js  c++  java
  • POJ--1936 All in All(水题,暴力即可)

    All in All
    Time Limit: 1000MS Memory Limit: 30000K
    Total Submissions: 30543 Accepted: 12723
    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

    #include <iostream>
    #include <string.h>
    #include <algorithm>
    #include <math.h>
    #include <stdlib.h>
    
    using namespace std;
    #define MAX 100000
    char a[MAX+5];
    char b[MAX+5];
    int main()
    {
        int pos;
        bool res;
        while(scanf("%s%s",&a,&b)!=EOF)
        {
            pos=-1;
            res=true;
            int tag;
            int len1=strlen(a);
            int len2=strlen(b);
            for(int i=0;i<len1;i++)
            {
                tag=0;
                for(int j=0;j<len2;j++)
                {
                    if(a[i]==b[j])
                    {
                        if(j>pos)
                        {
                           tag=1;
                           pos=j;
                           break;
                        }
                    }
                }
                if(tag==0)
                    res=false;
            }
            if(res==true)
                printf("Yes
    ");
            else
                printf("No
    ");
        }
    }
  • 相关阅读:
    kubernetes入门(03)kubernetes的基本概念
    洛谷P3245 [HNOI2016]大数(莫队)
    洛谷P4462 [CQOI2018]异或序列(莫队)
    cf997C. Sky Full of Stars(组合数 容斥)
    cf1121F. Compress String(后缀自动机)
    洛谷P4704 太极剑(乱搞)
    洛谷P4926 [1007]倍杀测量者(差分约束)
    洛谷P4590 [TJOI2018]游园会(状压dp LCS)
    洛谷P4588 [TJOI2018]数学计算(线段树)
    洛谷P4592 [TJOI2018]异或(可持久化01Trie)
  • 原文地址:https://www.cnblogs.com/dacc123/p/8228828.html
Copyright © 2011-2022 走看看