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 ...
随机推荐
- 系统运维|IIS的日志设置
摘要: 1.服务器告警,磁盘资源不足 2.检查发现是IIS日志没有清理并且设置有误.在E盘占用了200G的空间 3.原则上IIS日志不能放在C盘,避免C盘写满了导致操作系统异常 4.附上IIS日志按天 ...
- Django templates 模板的语法
MVC 以及 MTV MVC: M : model -->> 存取数据(模型) V: view -->> 信息的展示(视图) C: controller -->> ...
- 合并多个Excel文件
这条分享来自百度经验https://jingyan.baidu.com/article/e6c8503cb6ed7ee54e1a1811.html
- 解决jqueryeasyUI dialog 弹出窗体超出浏览器,导致不能关闭的bug
使用panel的onMove事件攻克了panel,dialog以及window组件在被拖动时,会超出浏览器边界而无法拖回的情况. 当窗体被拖出浏览器有边界时.$(document).width();会 ...
- Difference Between InnoDb and MyISAM(个人觉着是好文章,简单易懂,推荐看)
原文地址:http://acmeextension.com/difference-between-innodb-and-myisam/ MyISAM and InnoDB are the most c ...
- Spark DataSet 、DataFrame 一些使用示例
以前使用过DS和DF,最近使用Spark ML跑实验,再次用到简单复习一下. //案例数据 1,2,3 4,5,6 7,8,9 10,11,12 13,14,15 1,2,3 4,5,6 7,8,9 ...
- remove-duplicates-from-sorted-list (删除)
题意略: 思路:先造一个点它与所有点的值都不同,那么只要后面两个点的值相同就开始判断后面是不是也相同,最后将相同的拆下来就可以了. #include<iostream> #include& ...
- Opencv——相机标定
相机标定的目的:获取摄像机的内参和外参矩阵(同时也会得到每一幅标定图像的选择和平移矩阵),内参和外参系数可以对之后相机拍摄的图像就进行矫正,得到畸变相对很小的图像. 相机标定的输入:标定图像上所有内角 ...
- MongoDB数据库中更新与删除数据
MongoDB数据库中更新与删除数据 在MongoDB数据库中,可以使用Collection对象的update方法更新集合中的数据文档.使用方法如下所示: collection.update(sele ...
- flask 路由和视图
路由设置的俩种方式 @app.route('/xxx') def index(): return 'index' ------------------------------------------ ...