暴力匹配+一点判断

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
using namespace std; const int maxn=+;
char s[maxn];
char t[];
struct Seg
{
int l,r;
Seg(int a,int b){l=a;r=b;}
};
vector<Seg>v;
int L,R; bool CMP(int pos)
{
bool flag=; for(int i=;t[i];i++)
{
if(t[i]!=s[i+pos]) {flag=;break;}
}
return flag;
} int main()
{
scanf("%s",s);
scanf("%s",t);
v.clear(); int lens=strlen(s);
int lent=strlen(t); for(int i=;i<lens;i++)
{
if(CMP(i))
{
Seg seg(i,i+lent-);
v.push_back(seg);
}
}
int ans;
if(v.size()==) ans=;
else
{
ans=;
L=v[].l,R=v[].r;
for(int i=;i<v.size();i++)
{
if(v[i].l<=R) L=v[i].l;
else
{
ans++;
L=v[i].l;
R=v[i].r;
}
}
}
printf("%d\n",ans);
return ;
}

CodeForces 625B War of the Corporations的更多相关文章

  1. Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心

    B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long ...

  2. hiho 1015 KMP算法 && CF 625 B. War of the Corporations

    #1015 : KMP算法 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在 ...

  3. 【38.02%】【codeforces 625B】War of the Corporations

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  4. War of the Corporations CodeForces - 625B (greed)

    A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue the ...

  5. Codeforces Round #342 (Div. 2) B. War of the Corporations(贪心)

    传送门 Description A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Go ...

  6. Codeforces Round #342 (Div. 2)-B. War of the Corporations

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. CodeForces 625B 字符串模拟+思维

    题意 给出字符串a与b 可以将a中的单个字符改为# 问最少改多少次 a中就找不到b了 一开始想的是用strstr 因为如果找到 可以将strstr(a,b)-a+1改成# 即改首字母 用while循环 ...

  8. Codeforces - 625B 贪心

    求最小不重复匹配次数 改最后一个字符最划算 我当时怎么就没看出来.. #include<bits/stdc++.h> using namespace std; string S,T; in ...

  9. Codeforces 625B【KMP】

     题意就是一个串在另一个串出现几次,但是字符不能重复匹配, 比如aaaaaaa aaaa的答案是1 思路: 本来写了个暴力过的,然后觉得KMP改改就好了,就让队友打了一个: #include < ...

随机推荐

  1. 做.net的早晚会用到,并且网上还没有这方面的正确资料或几乎很少

    原文网址:http://www.cnblogs.com/langu/archive/2012/03/23/2413990.html 一直以来,找安装程序的msi源文件路径得到的都是“system32” ...

  2. Spring Boot 系列教程12-EasyPoi导出Excel下载

    Java操作excel框架 Java Excel俗称jxl,可以读取Excel文件的内容.创建新的Excel文件.更新已经存在的Excel文件,现在基本没有更新了 http://jxl.sourcef ...

  3. Qt 5.5 tr usage

    in .cpp file, wherever you want, wrap QString with a tr("somesz") rendering it ready to be ...

  4. UIGestureRecognizer 手势浅析

    目录[-] iOS开发中的手势体系——UIGestureRecognizer分析及其子类的使用 一.引言 二.手势的抽象类——UIGestureRecognizer 1.统一的初始化方法 2.手势状态 ...

  5. HTML5编程之旅系列一:HTML5 Geolocation 初探

    让我们假设这样一个场景,有一个web应用程序,它可以向用户提供附近不远处某商场的打折优惠信息.使用HTML5 Geolocation API(地理定位 API),可以请求用户共享他们的位置信息. HT ...

  6. 简单日历,纯js

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  7. Oracle Sql优化之报表和数据仓库运算

    1.行转列:有两种写法,一种是case when end写法,另一种写法是pivot(oracle 11g新增) select job, then sal end) as sal10, then sa ...

  8. C# 上传文件至远程服务器

    C# 上传文件至远程服务器(适用于桌面程序及web程序) 2009-12-30 19:21:28|  分类: C#|举报|字号 订阅     最近几天在玩桌面程序,在这里跟大家共享下如何将本地文件上传 ...

  9. Android系统权限及签名

    Android系统权限及签名   2015-03-23 19:13:33CSDN-chen52671-点击数:50     Android权限及签名 引子 现象:系统中的一个定制Service,服务是 ...

  10. zf-关于荆州图片链接和弹出页面问题

    target="_blank" 属性不能写在div 里 所以我在里面加了个a标签 这个属性的作用就是弹出一个新的页面,不会在原先的页面上换地址 如果 style 的加载图片卸载cs ...