#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
char a[];
char b[];
int main()
{
int n,m;
int lena;
int lenb;
while(~scanf("%d%d",&n,&m))
{
scanf("%s",a);
scanf("%s",b);
char c[];
int lena=strlen(a);
int lenb=strlen(b);
if (lena>lenb+)
{
printf("NO\n");
}
else
{
int f=-;
for (int i=; i<lena; i++)
{
if (a[i]=='*')
{
f=i;
for (int j=i+; j<lena; j++)
{
c[j-i-]=a[j];
}
c[lena-i-]='\0';
break;
}
}
if (f==-){
if (!strcmp(a,b)){
printf("YES\n");
continue;
}else
{
printf("NO\n");
continue;
}
}
int lenc=strlen(c);
int flag=;
for(int i=;i<f;i++){
// cout<<a[i]<<" "<<b[i]<<endl;
if (a[i]!=b[i]){
flag=;
break;
}
}
for (int i=lenb-; i>=lenb-lenc; i--)
{
// cout<<b[i]<<" "<<c[i-lenb+lenc]<<endl;
if( b[i]!=c[i-lenb+lenc]){
flag=;
break;
}
} if (flag==)printf("YES\n");
else printf("NO\n");
}
}
return ;
}

Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching的更多相关文章

  1. E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...

  2. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-D- Array Restoration

    我们知道不满足的肯定是两边大中间小的,这样就用RMQ查询两个相同等值的区间内部最小值即可,注意边界条件 #include<bits/stdc++.h> #define x first #d ...

  3. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence

    #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...

  4. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) E. Down or Right

    从(1,1,n,n)每次只变一个坐标,进行询问. 如果问到对角线有距离限制, 再从(1,1,n/2,n/2)询问到(n/2,n/2,n,n) 记住前半部分贪心忘上走,后本部分贪心往右走 因为最后的路线 ...

  5. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    考场上只做出了ABDE C都挂了... 题解: A 题解: 模拟 判断前面一段是否相同,后面一段是否相同,长度是否够(不能有重叠) Code: #include<stdio.h> #inc ...

  6. D. Recovering BST Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    http://codeforces.com/contest/1025/problem/D 树 dp 优化 f[x][y][0]=f[x][z][1] & f[z+1][y][0] ( gcd( ...

  7. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) -B C(GCD,最长连续交替序列)

    B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input ...

  8. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis

    题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...

  9. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    A : A. Doggo Recoloring time limit per test 1 second memory limit per test 256 megabytes input stand ...

随机推荐

  1. Linux (Fedora 28) 如何查看 CPU 温度

    机器突然负载有点高,查看CPU 温度的方法: 1.yum install lm_sensors; 2.sensors-detect 3.sensors   这些需要机器具备相应的设备,如果在虚拟机运行 ...

  2. tkinter学习系列(四)之Button 控件

    目录 目录 前言 (一)基本用法和可选属性 ==1.基本用法== ==2.可选属性== (二)属性的具体实现和案例 ==1.常用属性== ==案例一== ==2.按钮里的图片== ==案例二== == ...

  3. Linux 小知识翻译 - 「Linux」和病毒

    据说,「Linux」系统上的病毒要远远少于Windows系统上病毒.从2种系统的普及度来看,这是很显然的, 「Linux」的使用人群很少,所以「Linux」上的病毒的扩散时,受害的范围也不大. 但是, ...

  4. 二: python基础数据类型(int,

    一.什么是数据类型?2018-12-20   20:57:3õ # (3) num = 0 while num < 10: num += 1 if num == 7: num += 1 # 7执 ...

  5. Unity3d自制字体

    这篇教学中会使用到BMFont 这个工具 准备好Unity5.3.2版本,其他版本会有异常 一.制作字体 下载链接: http://www.angelcode.com/products/bmfont/ ...

  6. 初探InnoDB MVCC源码实现

    1. 背景 本文基于MySQL InnoDB源码对InnoDB中非锁定一致性读是如何实现的作一些简单的探究. 2. 基本概念 2.1 隐藏字段 在经典之作<高性能MySQL>的1.4节中提 ...

  7. 网络编程_UDP协议_发送端与接收端

    创建UDP传输的发送端 : 1.建立udp的socket服务   2.将要发送的数据封装到数据包中   3.通过udp的socket服务 将数据包发送出去   4.关闭socket服务(因为调用了系统 ...

  8. BookStrap之模板继承

    模板继承 (extend) Django模版引擎中最强大也是最复杂的部分就是模版继承了.模版继承可以让您创建一个基本的“骨架”模版,它包含您站点中的全部元素,并且可以定义能够被子模版覆盖的 block ...

  9. Excel函数(不定期持续更新)

    1.COUNTIF函数 COUNTIF函数用来计算单元格区域内符合条件的单元格个数. COUNTIF函数只有两个参数 COUNTIF(单元格区域,计算的条件) 例如:计算上海市的数量

  10. 添加xmlns:android="http://schemas.android.com/apk/res/android"的意思

    http://www.cnblogs.com/lovely/archive/2013/01/17/2865192.html xmlns:android="http://schemas.and ...