Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching
#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的更多相关文章
- 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 ...
- 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 ...
- 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> ...
- 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) 记住前半部分贪心忘上走,后本部分贪心往右走 因为最后的路线 ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
考场上只做出了ABDE C都挂了... 题解: A 题解: 模拟 判断前面一段是否相同,后面一段是否相同,长度是否够(不能有重叠) Code: #include<stdio.h> #inc ...
- 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( ...
- 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 ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis
题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...
- 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 ...
随机推荐
- centos6.5下oracle11g开机自动启动方法一
转裁于 方法一 https://blog.csdn.net/wx5040257/article/details/77875690 方法二 https://blog.csdn.net/wx504025 ...
- CRM JS
注意事项:Xrm.Page中的方法使用的是实体.字段.关系的逻辑名称.窗体调试:contentIFrame.Xrm.Page.getControl("compositeControlPara ...
- 【PAT】B1052 卖个萌(20 分)
实在不想写这个题,好费劲,头疼,这是粘的柳婼的代码 ,等我有空再自己用c写吧 #include <iostream> #include <vector> using names ...
- Linux命令大全总结
目录方面的命令:ls,dir,cd,clear,mkdir ls 显示指定目录的文件和目录 ls -a 列出目录下的所有文件,包括以 . 开头的隐藏文件 ls -l 显示指定目录的详细列表 ls -R ...
- DevExpress gridcontrol gridView主从表折叠/展开显示
在使用报表的时候,有很多需要主从表一起显示,从表不需要另外弹窗显示明细,反而直接显示在主表下方.如图所示: 第一次做这个功能,主从表显示,从表列隐藏,从表单元格点击事件这三个功能点花费了很多时间,在网 ...
- React学习笔记_01
使用Facebook的create-react-app快速构建React开发环境 前言: create-react-app:来自Facebook官方的零配置命令行工具 create-react-app ...
- Spring Cloud Eureka 属性作用
配置参数 默认值 说明 服务注册中心配置 Bean类:org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean eu ...
- ucml 查询组件
查询视图组件通常用于通过某些字段来查询数据,在页面设计处选好需要查询的字段,并设置操作符等信息最后设计页面添加执行查询的按钮即可,页面效果同编辑视图组件. 具体操作示例: 1.添加一个新的查询组件VC ...
- logbak 配置相关
一.配置简单 1. 配置简单,易于上手,通过logback.xml文件进行配置,如果没有配置的话,执行默认配置 <configuration> <appender name=&quo ...
- vscode中iframe的使用
vscode中iframe由于某种原因不支持本地页面,比如<iframe src ="index.html" width="300" height=&qu ...