Spoj8093 Sevenk Love Oimaster】的更多相关文章

Description Oimaster and sevenk love each other. But recently,sevenk heard that a girl named ChuYuXun was dating with oimaster.As a woman's nature, sevenk felt angry and began to check oimaster's online talk with ChuYuXun.     Oimaster talked with Ch…
题目链接 \(Description\) 给定n个模式串,多次询问一个串在多少个模式串中出现过.(字符集为26个小写字母) \(Solution\) 对每个询问串进行匹配最终会达到一个节点,我们需要得到这个节点所代表的子串出现在多少个模式串中. 建立广义后缀自动机.每次插入一个串,从root开始,对于SAM上每个节点维护cnt和bef,分别表示该节点代表的串出现在几个模式串中 和 该节点最近被哪个模式串更新过cnt. 对于bef[i]!=now的节点,++cnt[i],bef[i]=now:当模…
bzoj luogu 题面 给定n个模板串,以及m个查询串. 依次查询每一个查询串是多少个模板串的子串. sol 广义后缀自动机裸题? 先建出\(SAM\),然后记录一下每个节点分别在多少个模板串里出现过. 对于询问直接在\(SAM\)上跑匹配就行了. code #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> using namespace std; cons…
题目描述 题解: 对于所有n串建广义后缀自动机. (广义后缀自动机唯一区别就是每次将las附成1,并不需要在插入时特判) 建完后再建出parent树,然后用dfs序+树状数组搞区间不同种类. 其实就是HH的项链+广义后缀自动机.很水的.(虽然我调了半个晚上) 代码: #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #def…
Sevenk Love Oimaster bzoj-2780 Spoj-8093 题目大意:给定$n$个大串和$m$次询问,每次给出一个字符串$s$询问在多少个大串中出现过. 注释:$1\le n\le 10^4$,$1\le q\le 6\cdot 10^4$,$the\ total\ length\ of\ n\ strings\ \le 10^5$, $the\ total\ length\ of\ q\ question\ strings\le 3.6\times 10^5$. 想法:广…
全部串起来做SA, 在按字典序排序的后缀中, 包含每个询问串必定是1段连续的区间, 对每个询问串s二分+RMQ求出包含s的区间. 然后就是求区间的不同的数的个数(经典问题), sort queries + BIT 就行了.时间复杂度O(N log N). 速度垫底了QAQ 你们都会SAM.... ---------------------------------------------------------------------- #include<cmath> #include<c…
JZPGYZ - Sevenk Love Oimaster     Oimaster and sevenk love each other.       But recently,sevenk heard that a girl named ChuYuXun was dating with oimaster. As a woman's nature, sevenk felt angry and began to check oimaster's online talk with ChuYuXun…
SP8093 JZPGYZ - Sevenk Love Oimaster 题目大意 给定\(n(n\le 10000)\)个模板串,以及\(m(m\le 60000)\)个查询串(模板串总长\(\le 100000\),询问串总长\(\le 360000\)) 依次查询每一个查询串是多少个模板串的子串 先对模板串建广义SAM(每次新串las=1的那种) 然后考虑每个点都有一个所属的模板串,它可以对par树上到跟的那条链产生贡献,可以暴力加,据说均摊\(O(n\sqrt n)\),不清楚... 反…
[BZOJ2780][SPOJ]Sevenk Love Oimaster(后缀自动机) 题面 BZOJ 洛谷 题解 裸的广义后缀自动机??? 建立广义后缀自动机建立出来之后算一下每个节点被几个串给包括了 然后读入串直接匹配就好了 #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm&…
[BZOJ2780][Spoj]8093 Sevenk Love Oimaster Description Oimaster and sevenk love each other.     But recently,sevenk heard that a girl named ChuYuXun was dating with oimaster.As a woman's nature, sevenk felt angry and began to check oimaster's online t…