#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. mac系统如何在当前目录下打开终端

    给大家推荐一个好用的终端工具 Go2Shell:https://itunes.apple.com/cn/app/go2shell/id445770608?mt=12 在没有这个工具之前 找了好多在当前 ...

  2. Java实现数据库的读写分离

    引言 1.读写分离:可以通过Spring提供的AbstractRoutingDataSource类,重写determineCurrentLookupKey方法,实现动态切换数据源的功能:读写分离可以有 ...

  3. Windows安装PostgreSQL11.1

    Windows安装PostgreSQL11.1 安装过程如下: 1.下载安装包postgresql-11.1-1-windows-x64.exe 2.点击下一步 3.选择安装位置,默认路径C:\Pro ...

  4. SQL 加载

    首先新建表 第一张表 order_info 第二张表 user_info 登录mysql mysql -u root -p 在开始加载数据之前配置编码 查看默认编码 show variables li ...

  5. Arduino IDE for ESP8266 项目(3)创建AP+STA

    官网API:http://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html STA (客户端)手机连接路由器 S1 *简 ...

  6. MP实战系列(四)之DAO讲解

    说到DAO不得不提一个开发名词"三层架构",所谓的三层架构是什么呢?简单的可以概括为数据访问层,业务逻辑层,界面层(又称表现层). 这也是我们Java开发常用的手段,经常有人将三层 ...

  7. MyBatis+Hibernate+JDBC对比分析

    MyBatis目前作为持久层,用的最多,因为它符合互联网开发的变动性,实际开发中需求总会有这样的,那样的变动,MyBatis虽然没有Hibernate那么全自动化,而且对于开发人员的sql能力要求比较 ...

  8. nargin与varargin的用法

    nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能.通常可以用它来设定一些默认值.如下例所示: 函数文件 examp.m function fout=examp(a,b, ...

  9. Android学习之基础知识五—创建自定义控件

    下面是控件和布局的继承关系: 从上面我们看到: 1.所有控件都是直接或间接继承View,所有的布局都是直接或间接继承ViewGroup 2.View是Android中最基本的UI组件,各种组件其实就是 ...

  10. NB-IoT协议及其PSM

    物联网技术发展趋势是LPWAN,其中尤其以NB-IoT和eMTC最为代表.NB-IoT和eMTC各有优劣,使用场景互有不同. 低功耗可以说是物联网技术的核心,本着关注低功耗的方向,适当了解NB IoT ...