码迷,mamicode.com
首页 > 其他好文 > 详细

2333

时间:2015-08-21 13:24:04      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

/************************************************
* Author        :Running_Time
* Created Time  :2015-8-20 15:29:43
* File Name     :I.cpp
 ************************************************/

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;

#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
char s[MAXN], t[MAXN];

bool judge(void)    {
    int lens = strlen (s + 1);
    int lent = strlen (t + 1);
    if (lens > lent || s[1] != t[1])    return false;
    int i, j;
    for (j=2; j<=lent; ++j) {
        if (t[j] != t[1])   break;
    }
    for (i=1; i<j; ++i) {
        if (s[i] != t[i])   return false;
    }
    while (i <= lens)    {
        while (j <= lent && s[i] != t[j])   ++j;
        if (j > lent)   return false;
        i++;    j++;
    }
    return true;
}

int main(void)    {     //HDOJ 5414 CRB and String
    int T;  scanf ("%d", &T);
    while (T--) {
        scanf ("%s%s", s + 1, t + 1);
        puts (judge () ? "Yes" : "No");
    }

    return 0;
}
  
  

  

2333

标签:

原文地址:http://www.cnblogs.com/Running-Time/p/4747499.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!