Censor

frog is now a editor to censor so-called sensitive words (敏感词).

She has a long text pp. Her job is relatively simple -- just to find the first occurence of sensitive word ww and remove it.

frog repeats over and over again. Help her do the tedious work.

Input

The input consists of multiple tests. For each test:

The first line contains 11 string ww. The second line contains 11string pp.

(1≤length of w,p≤5⋅1061≤length of w,p≤5⋅106, w,pw,p consists of only lowercase letter)

Output

For each test, write 11 string which denotes the censored text.

Sample Input

    abc
aaabcbc
b
bbb
abc
ab

Sample Output

    a

    ab

题目大意;就是每组测试数据输入两个字符串;问第二个字符串中把第一个字符串一样的删除,问最后面还剩下什么;并输出;注意字符串删除后还会形成一个新的字符串;
#include<cstdio>
#include<string.h>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<deque>
using namespace std;
#define ll unsigned long long//要用长整型
char a[];
char b[];
ll p[];
ll a131[];
deque<ll>s;
void init()
{//先打表以防超时
a131[]=;
for(ll i=;i<=;i++)
{
a131[i]=a131[i-]*;
}
}
int main()
{
init();
while(~scanf("%s",&a))
{
while(!s.empty()) s.pop_back();
memset(p,,sizeof(p));
scanf("%s",&b);
ll la=strlen(a);
ll lb=strlen(b);
ll ss=;
for(ll i=;i<la;i++)
{//对ss进行哈希
ss=(ss*+a[i]);
}
ll cnt=;
for(ll i=;i<lb;i++)
{
s.push_back(b[i]);
if(s.size()==)
{
p[cnt++]=b[i];
}
else
{
p[cnt]=(p[cnt-]*+b[i]);
cnt++;
}
if(s.size()>=la&&(p[cnt-]-(p[cnt-la-]*a131[la]))==ss)//选择la长度的哈希,要减去之前的
{//一旦发现哈希相同,删除相同字符串
for(ll j=;j<=la;j++)
{
cnt--;
s.pop_back();
}
}
}
while(!s.empty())
{
printf("%c",s.front());
s.pop_front();
}
printf("\n");
}
return ;
}
												

四川第七届 C Censor (字符串哈希)的更多相关文章

  1. 四川第七届 D Vertex Cover(二分图最小点覆盖,二分匹配模板)

    Vertex Cover frog has a graph with nn vertices v(1),v(2),…,v(n)v(1),v(2),…,v(n) and mm edges (v(a1), ...

  2. 四川第七届 I Travel(bfs)

    Travel The country frog lives in has nn towns which are conveniently numbered by 1,2,…,n1,2,…,n. Amo ...

  3. 四川第七届 E Rectangle

    Rectangle frog has a piece of paper divided into nn rows and mm columns. Today, she would like to dr ...

  4. 山东省第七届ACM省赛------Memory Leak

    Memory Leak Time Limit: 2000MS Memory limit: 131072K 题目描述 Memory Leak is a well-known kind of bug in ...

  5. 2016 "Bird Cup" ICPC7th@ahstu--“波导杯”安徽科技学院第七届程序设计大赛

    "波导杯"安徽科技学院第七届程序设计大赛 Contest - 2016 "Bird Cup" ICPC7th@ahstu Start time:  2016-0 ...

  6. 2016 "Bird Cup" ICPC7th@ahstu--“波导杯”安徽科技学院第七届程序设计大赛

    "波导杯"安徽科技学院第七届程序设计大赛 原文章网页 Contest - 2016 "Bird Cup" ICPC7th@ahstu Start time:   ...

  7. 山东省第七届ACM省赛------Reversed Words

    Reversed Words Time Limit: 2000MS Memory limit: 131072K 题目描述 Some aliens are learning English. They ...

  8. 山东省第七届ACM省赛------Triple Nim

    Triple Nim Time Limit: 2000MS Memory limit: 65536K 题目描述 Alice and Bob are always playing all kinds o ...

  9. 山东省第七届ACM省赛------The Binding of Isaac

    The Binding of Isaac Time Limit: 2000MS Memory limit: 65536K 题目描述 Ok, now I will introduce this game ...

随机推荐

  1. 【bzoj2423】最长公共子序列[HAOI2010](dp)

    题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2423 题目大意:求两个字符串的最长公共子序列长度和最长公共子序列个数. 这道题的话,对于 ...

  2. YARN中的失败分析

    YARN中的失败分析 对于在YARN中运行的MapReduce程序,需要考虑以下几种实体的失败任务.application master.节点管理器.资源管理器 1. 任务运行失败 任务运行失败类似于 ...

  3. EJS基本用法

    1.引入 <script src="/src/ejs_production.js"></script> 2.模板 <script id="c ...

  4. DelphiXE_Android

    1. http://download.csdn.net/detail/gx15941883020/8104761 2. http://bbs.2ccc.com/topic.asp?topicid=45 ...

  5. 安装rackspace private cloud --5 Deployment configuration

    运行Ansible playbooks之前,需要配置taget host Prerequisites . cp -r /opt/openstack-ansible/etc/openstack_depl ...

  6. 使用<s:property value="4"/>是报错

    报错的情况是 在jsp中引入标签 <%@ taglib uri="/struts-tags" prefix="s" %> 项目中也有ognl.jar ...

  7. Linq练习题

    1 . 查询 Student 表中的所有记录的 Sname . Ssex 和 Class 列. select sname,ssex,class from student Linq:     from ...

  8. vmware centos 连网方式

    1.自动获取IP地址 虚拟机使用桥接模式,相当于连接到物理机的网络里,物理机网络有DHCP服务器自动分配IP地址. #dhclient 自动获取ip地址命令 #ifconfig 查询系统里网卡信息,i ...

  9. Debian For ARM mysql-server install information

    /**************************************************************************** * Debian For ARM mysql ...

  10. myEclipse下Maven配置操作

    一.Maven 安装与配置 1.点击计算机属性里的高级系统设置,点开环境变量进行配置 2.检验配置是否成功 二.手动创建一个Maven项目,并编译运行成功 1.创建一个文件夹作为项目的根目录 2. 在 ...