Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0MS 1A水啊水~

Posted by 834208094 at 2013-06-05 14:37:46 on Problem 1936
#include <iostream>
#include<string>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
    //freopen("D:\\CPPProgram\\ACM\\in.txt", "r", stdin);
    char a[100100], b[100100];
    while(~scanf("%s %s", &a, &b))
    {
        int len1, len2;
        len1 = strlen(a);
        len2 = strlen(b);
        if(len1 > len2)
        {
            printf("No\n");
        }
        else if(len1 == len2)
        {
            if(strcmp(a, b) == 0)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else
        {
            int start = 0;
            int cnt = 0;
            int ju;
            for(int i=0; i<len1; i++)
            {
                ju = 0;
                for(int j=start; j<len2; j++)
                {
                    if(a[i] == b[j])
                    {
                        start = j+1;
                        cnt ++;
                        ju = 1;
                        break;
                    }
                }
                if(ju == 0)
                {
                    printf("No\n");
                    break;
                }
            }
            if(cnt == len1)
                printf("Yes\n");
        }
    }
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator