传送门

我真是一个垃圾

模板题都不会做

模板题还要别人教

细节写法还要别人教

别人一分钟AC,教我算法还教我写法,最后写出来的别人算法还比我优秀一百倍

数据结构把脑子学傻了,看到题就想怎么用数据结构,半天做不来

别人1sAC,不是单调的么

纠结中间插啥子值,人家告诉我转为Int

最后还傻逼地写st表求lcp,人家直接单调队列

题读错了de半个晚上,还一直pe

mdzz,全世界都找不出第二个比我更蠢的人了

人家都线性代数学得风声水起了,我还在写傻逼题

全机房就我不会线性代数了

包括高一在内就我不知道FFT原理

啥子特征多项式,啥子特征值,

啥子啦普拉斯展开,啥子多项式求逆,啥子多项式取模,啥子多项式exp,啥子多点插值快速求值,别人信手拈来

就我一个傻逼连线性代数的门都没摸到

我tm连求导都求不陈展,微积分根本不知道是什么东西

数学烂得一塌糊涂

垃圾的一比

全机房最垃圾

心情不好,就想骂自己

我就tmd是一个世界无敌大傻逼

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=;
typedef long long LL;
typedef double db;
using namespace std;
int n,s[N],bl[N],r[N],lcp[N],len;
char ss[N]; template<typename T> void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} int sa[N],rak[N],h[N],st[N][];
void make_hight(int n) {
For(i,,n-) rak[sa[i]]=i;
for(int i=,k=;i<n;i++) {
if(!rak[i]) continue;
if(rak[i]==) {
int debug=;
}
if(k) k--;
int j=sa[rak[i]-];
while(s[i+k]==s[j+k]) k++;
h[rak[i]]=k;
st[rak[i]-][]=k;
}
For(j,,) For(i,,n-) if(i+(<<j)<n)
st[i][j]=min(st[i][j-],st[i+(<<j-)][j-]);
} int cmp(int a,int b,int y[],int k) {
int o1=a+k>=len?-:y[a+k];
int o2=b+k>=len?-:y[b+k];
return o1==o2&&y[a]==y[b];
} void make_sa(int n) {
static int c[N],t1[N],t2[N];
int m=,*x=t1,*y=t2,p;
For(i,,m-) c[i]=;
For(i,,n-) c[x[i]=s[i]]++;
For(i,,m-) c[i]+=c[i-];
Rep(i,n-,) sa[--c[x[i]]]=i;
for(int k=;k<=n;k<<=) {
p=;
For(i,n-k,n-) y[p++]=i;
For(i,,n-) if(sa[i]>=k) y[p++]=sa[i]-k;
For(i,,m-) c[i]=;
For(i,,n-) c[x[y[i]]]++;
For(i,,m-) c[i]+=c[i-];
Rep(i,n-,) sa[--c[x[y[i]]]]=y[i];
swap(x,y); x[sa[]]=; p=;
For(i,,n-)
x[sa[i]]=cmp(sa[i],sa[i-],y,k)?p-:p++;
m=p;
if(p>=n) break;
}
make_hight(n);
} int get_lcp(int i,int j) {
int k=;
for(k;i+(<<k)<=j;k++); if(k) k--;
return min(st[i][k],st[j-(<<k)][k]);
} int cnt[N],no[N],tot;
void solve() {
int ans=,pos=-; tot=;
while(pos+<len&&tot*<=n) {
pos++;
cnt[bl[sa[pos]]]++;
if(cnt[bl[sa[pos]]]==) tot++;
}
if(tot*<n) { puts("?"); return; }
lcp[]=get_lcp(,pos);
ans=lcp[];
For(i,,len-) {
no[i]=;
cnt[bl[sa[i-]]]--;
if(!cnt[bl[sa[i-]]]) tot--;
while(pos+<len&&tot*<=n) {
pos++;
cnt[bl[sa[pos]]]++;
if(cnt[bl[sa[pos]]]==) tot++;
}
if(tot*>=n) lcp[i]=get_lcp(i,pos);
else lcp[i]=;
ans=max(ans,lcp[i]);
if(lcp[i]==lcp[i-]&&h[i]>=lcp[i]) no[i]=;
}
if(!ans) { puts("?"); return; }
For(i,,len-) if(!no[i]&&lcp[i]==ans) {
For(j,sa[i],sa[i]+lcp[i]-)
printf("%c",'a'+s[j]);
puts("");
}
//puts("");
} //#define DEBUG
int main() {
#ifdef DEBUG
freopen("std.in","r",stdin);
//freopen(".out","w",stdout);
#endif
int id=,flag=;
for(;;) {
read(n);
if(!n) break;
len=; id=;
For(i,,n) {
scanf("%s",ss);
int tp=strlen(ss);
For(j,,tp-) { s[len++]=ss[j]-'a'; bl[len-]=i; }
s[len++]=++id;
}
For(i,,) cnt[i]=;
make_sa(len);
if(flag++) puts("");
solve();
}
return ;
}

poj3294Life Forms的更多相关文章

  1. POJ3294--Life Forms 后缀数组+二分答案 大于k个字符串的最长公共子串

                                                                              Life Forms Time Limit: 500 ...

  2. POJ3294Life Forms(广义后缀自动机)(后缀数组+二分+数状数组)

    You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial ...

  3. POJ-3294-Life Forms(后缀数组-不小于 k 个字符串中的最长子串)

    题意: 给定 n 个字符串,求出现在不小于 k 个字符串中的最长子串. 分析: 将 n 个字符串连起来,中间用不相同的且没有出现在字符串中的字符隔开,求后缀数组. 然后二分答案,将后缀分成若干组,判断 ...

  4. Wizard Framework:一个自己开发的基于Windows Forms的向导开发框架

    最近因项目需要,我自己设计开发了一个基于Windows Forms的向导开发框架,目前我已经将其开源,并发布了一个NuGet安装包.比较囧的一件事是,当我发布了NuGet安装包以后,发现原来已经有一个 ...

  5. xamarin.forms新建项目android编译错误

    vs2015 update3 新建的xamarin.forms项目中的android项目编译错误.提示缺少android_m2repository_r22.zip,96659D653BDE0FAEDB ...

  6. ASP.NET Forms 身份验证

    ASP.NET Forms 身份验证 在开发过程中,我们需要做的事情包括: 1. 在 web.config 中设置 Forms 身份验证相关参数.2. 创建登录页. 登录页中的操作包括: 1. 验证用 ...

  7. Xamarin.Forms 简介

    An Introduction to Xamarin.Forms 来源:http://developer.xamarin.com/guides/cross-platform/xamarin-forms ...

  8. C# 定时器 Timers.Timer Forms.Timer

    1.定义在System.Windows.Forms里 Windows.Forms里面的定时器比较简单,只要把工具箱中的Timer控件拖到窗体上,然后设置一下事件和间隔时间等属性就可以了 //启动定时器 ...

  9. Xamarin.Forms 免费电子书

    Xamarin Evolve 正在举行,现在已经放出2本免费的Xamarin.Forms 免费电子书,据现场的同学说这两天还有Xamarin.Forms 重磅消息发布: Creating Mobile ...

随机推荐

  1. Codeforces 1168A Increasing by Modulo

    题目链接:http://codeforces.com/problemset/problem/1168/A 题意:给一个数组,数组中元素范围为0~n,每次你可以选择若干元素进行(ai+1)%m的操作,问 ...

  2. Rabbit MQ 客户端 API 开发

    项目开始 第一步首先需要引入对应的 jar 包 <!-- https://mvnrepository.com/artifact/com.rabbitmq/amqp-client --> & ...

  3. vue中excal表格的导入和导出

    注意:vue中要实现表格的导入与导出,首先要install两个依赖, npm install -S file-saver xlsx  和  npm install -D script-loader.其 ...

  4. 2018今日头条湖北省赛【H】

    [题目链接]https://www.nowcoder.com/acm/contest/104/G 现场赛的H题,emmm...C++选手表示很伤心.高精度压四位板子WA四发. 题意很简单就是给你n个数 ...

  5. Ubuntu环境下Postgres源码文件编译安装步骤

    step1:官网下载postgres源码 URL:https://www.postgresql.org/ftp/source/ step2:解压源码文件 tar -zxvf postgresql-12 ...

  6. 关于js私钥加密公钥解密的问题

    博客荒废很久了,最近遇到一个问题,看网上的说明比较少,所以写下来给大家一个参考 一般来说rsa算法都是使用公钥加密,私钥解密,或者私钥签名,公钥验签.但总有特别的时候会想要用私钥加密,公钥解密,但是j ...

  7. mysql 06章_分组查询和链接查询

    一.分组查询 在进行查询时,通常需要按某个或某些字段进行一些统计,因此就需要使用分组查询,但分组后通常需要与聚合函数使用,分组才有意义. 语法:SELECT <字段列表|*> FROM 表 ...

  8. String str = new String("abc"),这段代码一共生成了几个String对象?为什么?

    String str = new String("abc")创建了俩个对象,首先为创建一个String对象"abc",然后在调用String类的构造方法时 pu ...

  9. HTML学习笔记 表单元素

    <form></form>代表表单 action:往什么地方提交 method:提交方式  get显示提交(不安全)  post隐视提交(安全) 提交内容:  name=输入的 ...

  10. redis和ehcache的区别,存储方式(各属于内存还是外存)

    ehcache属于内存存储,redis的缓存属于内存存储,redis的持久文件属于外存存储: redis是通过socket访问到缓存服务,效率比ecache低,比数据库要快很多,处理集群和分布式缓存方 ...