bzoj3942——2016——3——15
题目大意:
3942: [Usaco2015 Feb]Censoring
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 220 Solved: 115
[Submit][Status][Discuss]
Description
Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, so they have plenty of material to read while waiting around in the barn during milking sessions. Unfortunately, the latest issue contains a rather inappropriate article on how to cook the perfect steak, which FJ would rather his cows not see (clearly, the magazine is in need of better editorial oversight).
FJ has taken all of the text from the magazine to create the string S of length at most 10^6 characters. From this, he would like to remove occurrences of a substring T to censor the inappropriate content. To do this, Farmer John finds the _first_ occurrence of T in S and deletes it. He then repeats the process again, deleting the first occurrence of T again, continuing until there are no more occurrences of T in S. Note that the deletion of one occurrence might create a new occurrence of T that didn't exist before.
Please help FJ determine the final contents of S after censoring is complete
有一个S串和一个T串,长度均小于1,000,000,设当前串为U串,然后从前往后枚举S串一个字符一个字符往U串里添加,若U串后缀为T,则去掉这个后缀继续流程。
Input
Output
The string S after all deletions are complete. It is guaranteed that S will not become empty during the deletion process.
Sample Input
moo
Sample Output
#include<cstring>
#include<cstdio>
#include<cstring>
char t[],s[];
int m,n,top,i,fix;
int z[],next[],f[];
using namespace std;
int main()
{
scanf("%s%s",s+,t+);
m=strlen(s+); n=strlen(t+);
for (fix=,i=; i<=n; i++)
{
while (fix && t[fix+]!=t[i]) fix=next[fix];
if (t[fix+]==t[i]) fix++;
next[i]=fix;
}
for (int i=; i<=m; i++)
{
fix=f[z[top]];
while (fix && t[fix+]!=s[i]) fix=next[fix];
if (t[fix+]==s[i]) fix++; if (fix==n) top-=(n-);
else
f[i]=fix, z[++top]=i;
}
for (int i=; i<=top; i++) printf("%c",s[z[i]]);
}
bzoj3942——2016——3——15的更多相关文章
- 2016.8.15上午纪中初中部NOIP普及组比赛
2016.8.15上午纪中初中部NOIP普及组比赛 链接:https://jzoj.net/junior/#contest/home/1333 这次比赛不怎么好,因为这套题目我并不是很擅长. 可同学们 ...
- 2016.9.15初中部上午NOIP普及组比赛总结
2016.9.15初中部上午NOIP普及组比赛总结 2016.09.15[初中部 NOIP普及组 ]模拟赛 又翻车了!表示时超和空超很可恨! 进度 比赛:AC+0+0+20=120 改题:AC+80+ ...
- macbook pro 2016 2017 15寸 雷电3 外接显卡 epu 简单教程(不修改UEFI)
雷电3外接显卡效果还不错,但是除了akitio node 其他厂家并不会维护自己的固件来适配新机型,我自己买的mbp 2016 15''就出现了和AORUS Gaming Box 1070不兼容的问题 ...
- [位运算] [搜索] [递推优化] [计算几何] TEST 2016.7.15
NOIP2014 提高组模拟试题 第一试试题 题目概况: 中文题目名称 合理种植 排队 科技节 源程序文件名 plant.pas/.c/.cpp lineup.pas/.c/.cpp scifest. ...
- OneZero第四周第五次站立会议(2016.4.15)
1. 时间: 15:00--15:15 共计15分钟. 2. 成员: X 夏一鸣 * 组长 (博客:http://www.cnblogs.com/xiaym896/), G 郭又铭 (博客:http ...
- bzoj1355——2016——3——15
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1355 题目大意: 1355: [Baltic2009]Radio Transmission ...
- poj 3641 ——2016——3——15
传送门:http://poj.org/problem?id=3461 题目大意:给你两个字符串p和s,求出p在s中出现的次数. 题解:这一眼看过去就知道是KMP,作为模板来写是最好不过了.... 这道 ...
- 2016.07.15——istringstream测试
istringstream测试 1.istringstream strcin(str),字符串(str)可以包括多个单词,单词之间使用空格分开 #include "stdafx.h" ...
- 2016.5.15——leetcode:Number of 1 Bits ,
leetcode:Number of 1 Bits 代码均测试通过! 1.Number of 1 Bits 本题收获: 1.Hamming weight:即二进制中1的个数 2.n &= (n ...
随机推荐
- 手机端android/iPhone问题
iPhone: 不能自动播放音乐, 去除默认样式 input:-webkit-appearance: none;border-radius:0px; video播放自动默认全屏解决-webkit-pl ...
- RasterBandClass Class
Product Availability Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Description Th ...
- SPFA中 正逆邻接表的建立
正邻接表的建立: 先定义一个结构体: struct node { int r,v,w,next; }Map[]; 每输入一组数据 就通过Add函数加入到邻接表中,上图已经说得很明白了,结合着下面的代码 ...
- cmd 3389
1.2000系统 简要说一下如何进行DNS溢出攻击.我用的溢出利用程序是dns.exe,在CMD下运行它可以看到它的使用参数等信息.执行"dns -s IP"命令检测目标IP是否存 ...
- 可能是最简单的方式:利用Eclipse创建基于Maven的Web项目
1. 新建一个maven项目 2.在弹出框中选择创建一个简单项目 3. 然后输入参数,需要注意的是,在packagin中,选择war,web项目应该选择war 4. 点击finish后,基本项目结构就 ...
- Max Flow
Max Flow 题目描述 Farmer John has installed a new system of N−1 pipes to transport milk between the N st ...
- linux下查看cpu物理个数和逻辑个数 - chw1989的专栏 - 博客频道 - CSDN.NET
body { font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLi ...
- jQuery中的attr()和prop()使用
总结:除了checked.seleted这样的属性推荐用prop()外,其他的随意都可以. 原因如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML ...
- UIButton 关灯小实验
// 写在继承于UIViewController的子类中:创建单视图默认有ViewController类 // 实现:点击任何一颗UIButton,它四周的以及它自身都被变成红色,再点击就会变成原来的 ...
- Tengine TCP 负载均衡
tar jxvf jemalloc-3.5.1.tar.bz2 cd jemalloc-3.5.1 ./configure make && make install echo '/us ...