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. 【Python】PYTHON九九乘法表

    python2.7 for i in range(1,10):  for j in range(1,i+1):    print j,'x',i,'=',j*i,'\t',  print '\n'pr ...

  2. Codeforces Round #268 (Div. 1) 468D Tree(杜教题+树的重心+线段树+set)

    题目大意 给出一棵树,边上有权值,要求给出一个1到n的排列p,使得sigma d(i, pi)最大,且p的字典序尽量小. d(u, v)为树上两点u和v的距离 题解:一开始没看出来p需要每个数都不同, ...

  3. BZOJ2818 GCD 【莫比乌斯反演】

    2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MB Submit: 6826 Solved: 3013 [Submit][Status][Discuss ...

  4. The NPF driver isn't running

    转自:http://blog.csdn.net/zhangkaihang/article/details/7470239 今天安装Wireshark软件时出现了如下图所示的错误,就搜索了一下解决方法, ...

  5. Sass、Ruby、Nodejs、gulp

    1.Sass文件就是普通的文本文件,不过其文件后缀名有两种,一种为“.sass”:另一种为“.scss”.我们一般用“.scss”就好,至于这两种文件扩展名的区别在于“.sass”是Sass语言文件的 ...

  6. Windows下使用批处理实现启动关闭mysql_DOS/BAT

    cls @echo off :设置窗口字体颜色 color 0a :设置窗口标题 TITLE MySQL管理程序 by ThinkVenus call :checkAdmin goto menu :菜 ...

  7. Codeforces Round #301 解题报告

    感觉这次的题目顺序很不合理啊... A. Combination Lock   Scrooge McDuck keeps his most treasured savings in a home sa ...

  8. 01-modal Demo示例程序源代码

    源代码下载链接:01-modal.zip37.8 KB // MJAppDelegate.h // //  MJAppDelegate.h //  01-modal // //  Created by ...

  9. npm install 报node-sass错误

    Node Sass could not -bit with Node.js .x Found bindings for the following environments: - OS X -bit ...

  10. linux下使用wget下载整个网站

    linux下可以用wget下载整个网站,而且网站链接中包含utf-8编码的中文也能正确处理. 简要方法记录如下: wget --restrict-file-name=ascii -m -c -nv - ...