Hash练习题:【213E】 Two Permutations(线段树,hash)
来源:互联网 发布:安信通达信软件 编辑:程序博客网 时间:2024/06/01 10:34
文章出处: http://blog.csdn.net/ACM_cxlove?viewmode=contents
原题:http://codeforces.com/problemset/problem/213/E
尼玛,这是研究题解都研究了半天,巨弱啊
开始看成是连续的子串,然后就直接HASH枚举了一下,果断跪。
然后就想到可以不连续,然后就没啥想法了。
最终还是用线段树去维护一个HASH
按数字顺序,依次插入线段树,然后对整个区间求HASH。其实就是比较的是整个区间的相对顺序是否 和A串一致。
比如说A串中是1 3 2
那么将第二个串的1 2 3插入到线段树中后,如果其相对顺序也是1 3 2 那么HASH值肯定一样。
但是注意的是,如果继续插入4,肯定要把1删掉,那么这时候的HASH值是2,3,4的组合HASH。
可以发现每一权都加了1,那么这个预处理一下就可以了
HASH我还是习惯性地两次HASH,减少错误的可能性
0 0
- Hash练习题:【213E】 Two Permutations(线段树,hash)
- CF 213E Two Permutations(线段树,hash)
- CF 213E Two Permutations(线段树,hash)
- 【线段树+字符串hash】 codeforces 213E Two Permutations
- CodeForces 580 E.Kefa and Watch(hash+线段树)
- Codeforces 580E Kefa and Watch 线段树+双值Hash
- codeforces 321# E. Kefa and Watch (线段树+字符串hash)
- codeforces 580 E. Kefa and Watch (字符串hash + 线段树)
- Codeforces Round #321 (Div. 2)E 线段树+字符串hash
- codeforces 580 E. Kefa and Watch(hash+线段树)
- Codeforces 213E - Two Permutations
- 线段树+hash+codeforces213E
- 线段树 + 字符串Hash
- CODEFORCES ROUND #321 (DIV. 2) E.Kefa and Watch(线段树+hash)
- ural1989(字符串hash+线段树)
- hdu 3973(hash+线段树)
- Codeforces452F Permutation -- 线段树 + Hash
- Hash练习题:【POJ3349】
- 直流稳压电源1
- Redis集群_3.redis 主从自动切换Sentinel
- 红黑数实现
- springmvc中url-url-pattern /和/*的区别
- POJ 3262 - Protecting the Flowers(贪心)
- Hash练习题:【213E】 Two Permutations(线段树,hash)
- 《Little Runner》(四)——添加怪物
- Windows下启动ActiveMq端口被占用的解决办法
- 看我怎么玩转信誉卡,个人心得倾情贡献
- OC中类别、扩展、协议与委托
- IOS App提交到appStore Missing 64-bit support
- jdbc通用查询实例
- MTA统计功能接入指引
- 自行封装Jquery的ajax的form方法