上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 57 下一页

2016年2月7日

【HDOJ】1914 The Stable Marriage Problem

摘要: 稳定婚姻问题,Gale-Shapley算法可解。 1 /* 1914 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #include <queue> 7 #include <s 阅读全文

posted @ 2016-02-07 00:24 Bombe 阅读(175) 评论(0) 推荐(0) 编辑

2016年2月6日

【HDOJ】3601 Coach Yehr’s punishment

摘要: RMQ+dp+二分。最好还是离散化一下再处理,通过dp求得每个位置的上一次出现的位置pre数组,从而求得不重复的长度len。然后RMQ可以预处理区间的最大值,pre是个单调非递减数列。每次查询时,二分可以找到超过l的位置。注意这个位置k可能超过r。因此最大值为max(k-l, RMQ(k, r) & 阅读全文

posted @ 2016-02-06 22:17 Bombe 阅读(239) 评论(0) 推荐(0) 编辑

【HDOJ】4601 Letter Tree

摘要: 挺有意思的一道题,思路肯定是将图转化为Trie树,这样可以求得字典序。然后,按照trie的层次求解。一直wa的原因在于将树转化为线性数据结构时要从原树遍历,从trie遍历就会wa。不同结点可能映射为trie上的同一结点,如1->2 (a) 1->3(a) 2->4(b), 这是trie的结构是RT- 阅读全文

posted @ 2016-02-06 15:56 Bombe 阅读(162) 评论(0) 推荐(0) 编辑

2016年2月5日

【HDOJ】3686 Traffic Real Time Query System

摘要: 这题做了几个小时,基本思路肯定是求两点路径中的割点数目,思路是tarjan缩点,然后以割点和连通块作为新节点见图。转化为lca求解。结合点——双连通分量与LCA。 1 /* 3686 */ 2 #include <iostream> 3 #include <sstream> 4 #include < 阅读全文

posted @ 2016-02-05 22:34 Bombe 阅读(397) 评论(0) 推荐(0) 编辑

【HDOJ】5296 Annoying problem

摘要: LCA+RMQ。挺不错的一道题目。 思路是如何通过LCA维护费用。当加入新的点u是,费用增量为dis[u]-dis[lca(u, lower_u)] - dis[lca(u, greater_u)] + dis[lca(lower_u, greater_u)]。若beg[u]大于当前最大值或小于最小 阅读全文

posted @ 2016-02-05 12:11 Bombe 阅读(310) 评论(0) 推荐(0) 编辑

【HDOJ】3553 Just a String

摘要: 后缀数组加二分可解。 1 /* 3553 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #include <queue> 7 #include <set> 8 #include 阅读全文

posted @ 2016-02-05 00:55 Bombe 阅读(148) 评论(0) 推荐(0) 编辑

2016年2月4日

【HDOJ】4426 Palindromic Substring

摘要: 综合性很强的一道题目,结合manacher,后缀数组,哈希,RMQ,二分可解。基本思路是通过manacher可以找到所有可能的回文串,哈希去重,后缀数组二分找数目。最后暴力求解。需要注意kth需要为__int64。 1 /* 4426 */ 2 #include <iostream> 3 #incl 阅读全文

posted @ 2016-02-04 23:13 Bombe 阅读(300) 评论(0) 推荐(0) 编辑

【HDOJ】4029 Distinct Sub-matrix

摘要: 思路是枚举矩阵列数,然后将字符矩阵转换成字符串,通过字符数组求不同子串数目。最后,减去不成立的情况。使用特殊字符分割可能的组合。 1 /* 4029 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #includ 阅读全文

posted @ 2016-02-04 12:29 Bombe 阅读(193) 评论(0) 推荐(0) 编辑

【HDOJ】3948 The Number of Palindromes

摘要: 后缀数组求不重复回文子串数目。注意dp数组。 1 /* 3948 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #include <queue> 7 #include <set 阅读全文

posted @ 2016-02-04 00:22 Bombe 阅读(256) 评论(0) 推荐(0) 编辑

2016年2月3日

【HDOJ】4691 Front compression

摘要: 后缀数组基础题目,dc3解。 1 /* 4691 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #include <queue> 7 #include <set> 8 #inc 阅读全文

posted @ 2016-02-03 22:24 Bombe 阅读(208) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 57 下一页

导航