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

A. Single Wildcard Pattern Matching

题意就是匹配字符的题目,打比赛的时候没有看到只有一个" * ",然后就写挫了,被hack了,被hack的点就是判一下只有一个" * "。

代码:

 //A
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; const double PI=acos(-1.0);
const double eps=1e-;
const ll mod=1e9+;
const int inf=0x3f3f3f3f;
const int maxn=*1e5+;
const int maxm=+;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); char s[maxn],t[maxn]; int main()
{
int n,m;
scanf("%d%d",&n,&m);
scanf("%s%s",s,t);
int pos=-;
for(int i=;i<n;i++){
if(s[i]=='*'){
pos=i;
break;
}
}
if(pos==-){
if(n!=m)
cout<<"NO"<<endl;
else{
for(int i=;i<n;i++){
if(s[i]!=t[i]){
cout<<"NO"<<endl;
return ;
}
}
cout<<"YES"<<endl;
}
}
else{
if(m<n-){
cout<<"NO"<<endl;
return ;
}
for(int i=;i<pos;i++){
if(s[i]!=t[i]){
cout<<"NO"<<endl;
return ;
}
}
for(int i=n-,j=m-;i>pos;i--,j--){
if(s[i]!=t[j]){
cout<<"NO"<<endl;
return ;
}
}
cout<<"YES"<<endl;
}
}

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

  1. Codeforces 1023 D.Array Restoration-RMQ(ST)区间查询最值 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    D. Array Restoration 这题想一下就会发现是只要两个相同的数之间没有比它小的就可以,就是保存一下数第一次出现和最后一次出现的位置,然后查询一下这个区间就可以,如果有0的话就进行填充. ...

  2. Codeforces 1023 C.Bracket Subsequence-STL(vector) (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    C. Bracket Subsequence ... 代码: 1 //C 2 #include<iostream> 3 #include<cstdio> 4 #include& ...

  3. Codeforces 1023 B.Pair of Toys (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    B. Pair of Toys 智障题目(嘤嘤嘤~) 代码: 1 //B 2 #include<iostream> 3 #include<cstdio> 4 #include& ...

  4. 【CF1023A】Single Wildcard Pattern Matching(模拟)

    题意:给定两个串s与t,其中s可能有至多一个通配符*可以被当做任意长度与内容的串,问t能否与s匹配 n,m<=2e5 思路: #include<cstdio> #include< ...

  5. 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> ...

  6. 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 ...

  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 #470 (rated, Div. 2, based on VK Cup 2018 Round 1)A. Protect Sheep

    http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pastu ...

  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. RegExp & bug

    RegExp & bug translated bug // OK && tranlate `/` let new_obj_reg = new RegExp(`^(([^< ...

  2. Hibernate常用方法之_修改

    1.使用session的saveOrUpdate方法 public void updateUser(User user){ Session session = null; Transaction tr ...

  3. 51nod 1967路径定向(欧拉回路)

    题目大意:给出一个图,安排边的方向,使得入度等于出度的点数最多,并给出方案. 首先假设是个无向图,不妨认定偶点必定可以满足条件 我们还会发现,奇点的个数必定是偶数个 那么如果把奇点两两用辅助边连起来, ...

  4. Acunetix Web Vulnarability Scanner V10.5 详细中文手册

    目录: 0×00.什么是Acunetix Web Vulnarability Scanner ( What is AWVS?) 0×01.AWVS安装过程.主要文件介绍.界面简介.主要操作区域简介(I ...

  5. 树剖模板by fcdalao

    #include<bits/stdc++.h> using namespace std; ; *MX]; *MX]; int n,Index,fir[MX],fa[MX],dfn[MX], ...

  6. 【NOIP 模拟赛】Evensgn 剪树枝 树形dp

    由于树规做的少所以即使我考试想出来正确的状态也不会转移. 一般dp的转移不那么繁杂(除了插头.....),即使多那也是清晰明了的,而且按照树规的一般思路,我们是从下到上的,所以我们要尽量简洁地从儿子那 ...

  7. bzoj 5099 [POI2018]Pionek 计算几何 极角排序

    [POI2018]Pionek Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 269  Solved: 80[Submit][Status][Disc ...

  8. hive 动态分区(Dynamic Partition)异常处理

    Changing Hive Dynamic Partition Limits Symptoms: Hive enforces limits on the number of dynamic parti ...

  9. springboot部署多个vue项目

    在springboot下部署多个vue项目,只需要将vue打包成静态文件后,将其放在resources的静态文件夹下即可. 如下图:static目录下有三个vue的静态文件夹,分别为运营后台(admi ...

  10. Bzoj1313 [HAOI2008]下落的圆盘

    有 n 个圆盘从天而降,后面落下的可以盖住前面的.最后按掉下的顺序,在平面上依次测得每个圆盘的圆心和半径,问下落完成后从上往下看,整个图形的周长是多少,即你可以看到的圆盘的轮廓的圆盘的轮廓总长.例如下 ...