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 ...
随机推荐
- opencart配置United States Postal Service快递
1.安装United States Postal Service 2.登录https://registration.shippingapis.com/,注册帐号,稍后会收到邮件 3.打开邮件,记下Us ...
- io scheduler
http://doctorlzr1988.blog.163.com/blog/static/50456520201051905236683/
- [转]android中解析后台返回的json字符串
普通形式的:服务器端返回的json数据格式如下: {"userbean":{"Uid":"100196","Showname&qu ...
- 用批处理文件删除n天前的文件
原文:http://blog.csdn.net/leehq/archive/2007/08/03/1723743.aspx 公司服务器用来备份数据的硬盘过段时间就会被备份文件占满,弄得我老是要登录到服 ...
- VHD容量调整的方法(保存原有vhd)
VHD容量调整的方法(保存原有vhd)特别对于RAMOS的VHD,调整VHD容量的办法:1.在WIN7或者7PE中,右击我的电脑→管理→磁盘管理,挂载原始VHD文件,然后新建一个VHD文件,初始化,格 ...
- mysql 本地操作
先把数据库传到根目录 再直接导入 没有50M限制root@b101 [/home/user/www]# mysql -uusername_007li -ppasswd -D dbname_li12d ...
- css hack总结
虽然说,现在讨论css hanck已经过时了,不过了解下还是好的. 各游览器常用兼容标记一览表: 标记 IE6 IE7 IE8 FF Opera Sarari [*+><] √ √ X X ...
- PAT (Advanced Level) 1012. The Best Rank (25)
简单排序题. 注意:分数相同的人排名相同. #include<iostream> #include<cstring> #include<cmath> #includ ...
- ssh密钥登录及远程执行命令
以192.168.1.104作为客户机 以192.168.1.103作为服务器 使用密钥登录 创建密钥对 在SSH客户机创建用户秘钥对 ssh-keygen -t rsa 之后全回车即可 将会在~/. ...
- 解决:IE中不能自动选择UTF-8编码的解决方法
IE中不能自动选择UTF-8编码的解决办法 在windows操作系统上使用IE作为浏览器时.常常会发生这样的问题:在浏览使用UTF-8编码的网页时,浏览器无法自动侦测(即没有设定“自动选择”编码格式时 ...