E. Compress Words

KMP

#include<bits/stdc++.h>
using namespace std;
int p[];
int len;
void getNext(char *s)
{
int i=,j=-;
p[]=-;
int n=strlen(s);
for(i; i<n;)
{
if(j==-||s[i]==s[j])
{
i++;
j++;
if(s[i]==s[j])
p[i]=p[j];
else p[i]=j; }
else
{
j=p[j]; } }
//return j;
}
int KMP(char *s,char *t)
{
int n=strlen(t); int i=max(,len-n),j=;
getNext(t);
for(i; i<len;)
{
while(s[i]!=t[j])
{
if(p[j]==)
{
j=;
break;
}
else j=p[j];
}
if(s[i]==t[j])
{
j++;
}
i++;
}
return j; }
char s[];
char t[];
int main()
{
int T;
scanf("%d",&T);
scanf("%s",s);
len=strlen(s);
T--;
for(int _=;_<T;_++){
scanf("%s",t);
int c=KMP(s,t);
//int n=strlen(s); int m=strlen(t);
int i=len-c;
for(int j=;j<m;j++){
s[i++]=t[j];
}s[i]='\0';
len+=m-c;
}
cout<<s<<'\n'; }

E. Compress Words的更多相关文章

  1. 压缩和解压文件:tar gzip bzip2 compress(转)

    tar[必要参数][选择参数][文件] 压缩:tar -czvf filename.tar.gz targetfile解压:tar -zxvf filename.tar.gz参数说明: -c 建立新的 ...

  2. apache.commons.compress 压缩,解压

    最近在一个前辈的指引下,开始研究apache.commons.都是网上找的,而且不会中文乱码,而且还可以在压缩包里面加一层文件夹 package my.test; import java.io.Buf ...

  3. Linux下的压缩和解压缩命令——compress/uncompress

    compress命令 compress命令使用"Lempress-Ziv"编码压缩数据文件.compress是个历史悠久的压缩程序,文件经它压缩后,其名称后面会多出".Z ...

  4. AIX 文件 打包 与 压缩 tar gzip compress 的使用

    今天在Aix用tar -cvf 备份,打成tar包,占有硬盘空间过大,没有压缩比, 尝试使用tar -zcvf  linux系统下可以用-z 命令 (z 用gzip来压缩/解压缩文件,加上该选项后可以 ...

  5. impdp导入报错ORA-14460: only one COMPRESS or NOCOMPRESS clause may be specified

    迁移环境 源:Solaris 10 + Oracle 11.2.0.3 目标:Solaris 10 + Oracle 11.2.0.1 导出命令: expdp user/pwd directory=j ...

  6. [CareerCup] 1.5 Compress String 压缩字符串

    1.5 Implement a method to perform basic string compression using the counts of repeated characters. ...

  7. Compress a Folder/Directory via Perl5

    Compress a Folder/Directory via Perl5 tested in Windows, Mac OS X, Ubuntu16.04 #!/usr/bin/perl #压缩指定 ...

  8. PLSQL_批量压缩表Table Compress(案例)

    2015-04-01 Created By BaoXinjian

  9. compress 表设置及索引设置

    -- 查看表大小 from user_segments where segment_name='TableName'; -- 查看表大小 size_m -- 2000.6796875 2211.695 ...

  10. Compress、tar、gzip、zcat、bzip2、bzcat、打包解压命令行

    讲解内容: Linux环境中,压缩文件案的扩展名大多是*.tar,*.tar.gz,*.tgz,*.gz,*.Z,*.bz2. *.z             compress程序亚索的文件: *.g ...

随机推荐

  1. 使用Object.create()实现继承 用 Object.create实现类式继承

    使用Object.create()实现继承:https://www.cnblogs.com/cuew1987/p/4075027.html 用 Object.create实现类式继承:https:// ...

  2. shell script简单笔记

    变量 shell script是一种脚本语言,变量的定义是通过 myName=HYB 这样的形式定义的. 当存在空格时,可以通过双引号或单引号将其变为字符串.双引号不进行转义,单引号将内容进行转义为一 ...

  3. 【WPS/Visio】WPS word无法复制或编辑Visio对象

    前言 Win10,WPS2019,Visio2016. 好像是有一次设置 .vsdx 的默认打开方式为Visio,之后每次在WPS里复制Visio对象,或双击编辑WPS word中以前的Visio对象 ...

  4. Rust学习笔记2

    继续继续... 转眼都开学啦... Building Blocks 2 building blocks里讲了一些关于Log structure storage的东西,这也是用于在硬盘上持久化KvSto ...

  5. DataTable中如何去除重复的项 (获得某个字段中的不重复项)

    就是获取DataTable中某一列的值,因为从数据库中检索数据时,按照2个字段进行分组,而要获得的那一列刚好在分组这两列中,所以该列的值必然有重复,于是就想到了去除重复,有了思路以后在网上看了一些方法 ...

  6. jQuery之操作样式的css方法

    注意点都在代码里 <style> div { width: 200px; height: 200px; background-color: pink; } </style> & ...

  7. 【问题解决方案】Linux中命令useradd与adduser的区别

    参考链接: useradd与adduser的区别 useradd与adduser:创建新的用户 CentOs: useradd与adduser是没有区别的 都是在创建用户,在home下自动创建目录,没 ...

  8. ioncube扩展的安装详细图文教程,适合所有新手

    有些程序在php环境下运行需要安装ionCube Loader的扩展支持,这里跳过介绍这些东西直接说一下怎么让你的主机环境支持这种扩展,顺利的让你的程序运行起来!这个教程适合用云服务器或者独立服务器的 ...

  9. 切入点表达式execution()

    用于描述方法 [掌握] 语法:execution(修饰符 返回值 包.类.方法名(参数) throws异常) 修饰符,一般省略 public                公共方法 *         ...

  10. 安信可ESP-12F(8266)模块烧录问题解决:示 :ESP8266 Chip stub error esp_stub_an

    模块:安信可ESP-12F, 8266模块 1. 供电电流大于500ma,网上买的串口工具供电电流都是不行的,要上主电源,或者外接电源. 2. 焊接在主板上的模块由于串口同时连接了MCU的串口,如果M ...