<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[fcbruce]]></title><description><![CDATA[——The code will never betray me.]]></description><link>https://blog.csdn.net/u012965890</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; u012965890]]></copyright><item><title><![CDATA[POJ 1625 Censored!(AC自动机，DP)]]></title><link>https://blog.csdn.net/u012965890/article/details/41313601</link><guid>https://blog.csdn.net/u012965890/article/details/41313601</guid><author>u012965890</author><pubDate>Thu, 20 Nov 2014 15:19:12 +0800</pubDate><description><![CDATA[题意：
给出一n种字符的字典，有k个禁用的单词，问能组成多少个不同的长度为m的合法字符串。
分析：
构建出AC自动机后在里面走m步有不经过单词结点有多少种方案，用dp[i][j]表示走了i步到第j个结点的方案数，根据计数原理可得状态转移方程:dp[i][j]=sum(dp[i][last_j]),其中last_j表示能走到j结点的前趋们，j不为单词结点。要注意此题要用到高精度，而且要用unsigned char存储。]]></description><category></category></item><item><title><![CDATA[HDU 2825 Wireless Password (AC自动机，DP)]]></title><link>https://blog.csdn.net/u012965890/article/details/41309811</link><guid>https://blog.csdn.net/u012965890/article/details/41309811</guid><author>u012965890</author><pubDate>Thu, 20 Nov 2014 11:19:33 +0800</pubDate><description><![CDATA[题意：
给出m个模式串，要求构造一长度为n的文本串，至少包括k种模式串，求有多少种可能的模式串。
分析：
m个模式串构建AC自动机，然后要在这AC自动机中走n步，至少经过k个单词结点。因为m<=10,显然可以用状压表示已经有哪几个单词结点。用dp[i][j][k]表示走了i步到AC自动机中的第j个结点，单词状态为k，由计数原理可推出状态转移方程：dp[i][j][k]=sum(dp[i-1][last_j][last_k]),last_j表示可以抵达第j个结点的上一个结点，last_k表示上一步的状态;因为]]></description><category></category></item><item><title><![CDATA[SPOJ 962 Intergalactic Map (网络最大流)]]></title><link>https://blog.csdn.net/u012965890/article/details/41287707</link><guid>https://blog.csdn.net/u012965890/article/details/41287707</guid><author>u012965890</author><pubDate>Wed, 19 Nov 2014 20:42:07 +0800</pubDate><description><![CDATA[题意：
给出一张无向图，要求从1先走到2，再从2走到3，且每个点至多经过一次，问是否可能。
分析：
每个点至多经过一次，显然往网络流上靠，非常明显的拆点。但是要求从1走到2，再从2走到3，显然不太好处理。因为每个点最多经过一次，所以从1走到2的路径与2走到3的路径显然是完全不同的两条路径，而且还是无向图，那么不妨考虑从2出发找两条不同的路径分别走到1和3。这样建图就呼之欲出了：s->2，容量为2;1->t,3->t容量均为1，图中所有边容量均为1，在此图中跑最大流即可。要注意的是输入中不在区间[1,n]内的]]></description><category></category></item><item><title><![CDATA[POJ 3691 & HDU 2457 DNA repair (AC自动机，DP)]]></title><link>https://blog.csdn.net/u012965890/article/details/41244965</link><guid>https://blog.csdn.net/u012965890/article/details/41244965</guid><author>u012965890</author><pubDate>Tue, 18 Nov 2014 12:14:07 +0800</pubDate><description><![CDATA[题意：
给出N个模式串和一个文本串，问最少修改文本串中多少个字母使得文本串中不包含模式串。
分析：
N个模式串构建AC自动机，然后文本串在AC自动机中走，其中单词结点不可达。
用dp[i][j]表示文本串第i个字母转移到AC自动机第j个结点最少修改字母的个数，状态转移方程为dp[i][j]=min(dp[i][j],dp[i-1][last]+add)，last表示j的前趋，add为当前点是否修改。由于第i个只和第i-1个有关，所以可以使用滚动数组来优化空间。]]></description><category></category></item><item><title><![CDATA[HDU 4057 Rescue the Rabbit (AC自动机+DP)]]></title><link>https://blog.csdn.net/u012965890/article/details/41125153</link><guid>https://blog.csdn.net/u012965890/article/details/41125153</guid><author>u012965890</author><pubDate>Fri, 14 Nov 2014 22:01:58 +0800</pubDate><description><![CDATA[http://acm.hdu.edu.cn/showproblem.php?pid=4057

Rescue the Rabbit
Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1482    Accepted Submis]]></description><category></category></item><item><title><![CDATA[HDU 1978 How many ways (DP,计数)]]></title><link>https://blog.csdn.net/u012965890/article/details/40616969</link><guid>https://blog.csdn.net/u012965890/article/details/40616969</guid><author>u012965890</author><pubDate>Thu, 30 Oct 2014 11:27:08 +0800</pubDate><description><![CDATA[http://acm.hdu.edu.cn/showproblem.php?pid=1978

How many ways
Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3022    Accepted Submission(s]]></description><category></category></item><item><title><![CDATA[HDU 2870 Largest Submatrix (单调栈)]]></title><link>https://blog.csdn.net/u012965890/article/details/40462667</link><guid>https://blog.csdn.net/u012965890/article/details/40462667</guid><author>u012965890</author><pubDate>Sun, 26 Oct 2014 00:47:32 +0800</pubDate><description><![CDATA[http://acm.hdu.edu.cn/showproblem.php?pid=2870

Largest Submatrix
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1569    Accepted Submissi]]></description><category></category></item><item><title><![CDATA[HDU 5071 Chat(2014鞍山B，模拟)]]></title><link>https://blog.csdn.net/u012965890/article/details/40450917</link><guid>https://blog.csdn.net/u012965890/article/details/40450917</guid><author>u012965890</author><pubDate>Sat, 25 Oct 2014 11:11:38 +0800</pubDate><description><![CDATA[http://acm.hdu.edu.cn/showproblem.php?pid=5071

Chat
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 702    Accepted Submission(s): 163
]]></description><category></category></item><item><title><![CDATA[探寻C/C++中更快的大数(自然数集)模板]]></title><link>https://blog.csdn.net/u012965890/article/details/40432511</link><guid>https://blog.csdn.net/u012965890/article/details/40432511</guid><author>u012965890</author><pubDate>Fri, 24 Oct 2014 20:52:46 +0800</pubDate><description><![CDATA[本文系fcbruce个人原创整理，转载请注明出处http://blog.csdn.net/u012965890/article/details/40432511，谢谢！


我们知道在C/C++中int型可处理-2^31~2^31-1(32位及以上编译器)，long long型可处理-2^63~2^63-1的数据,这实际上是非常有限的，在很多情况下，我们往往会处理范围更大的数据。Java中有BigInteger类，python中想要多大就有多大（取决于内存），但是C/C++就显得有些乏力，这时候我们会]]></description><category></category></item><item><title><![CDATA[POJ 2762 Going from u to v or from v to u?(强联通，拓扑排序)]]></title><link>https://blog.csdn.net/u012965890/article/details/40077525</link><guid>https://blog.csdn.net/u012965890/article/details/40077525</guid><author>u012965890</author><pubDate>Tue, 14 Oct 2014 15:30:13 +0800</pubDate><description><![CDATA[http://poj.org/problem?id=2762






Going from u to v or from v to u?




Time Limit: 2000MS
 
Memory Limit: 65536K


Total Submissions: 14573
 
Accepted: 3849




Description]]></description><category></category></item><item><title><![CDATA[POJ 2186 Popular Cows (强联通)]]></title><link>https://blog.csdn.net/u012965890/article/details/40077307</link><guid>https://blog.csdn.net/u012965890/article/details/40077307</guid><author>u012965890</author><pubDate>Tue, 14 Oct 2014 15:20:03 +0800</pubDate><description><![CDATA[http://poj.org/problem?id=2186






Popular Cows




Time Limit: 2000MS
 
Memory Limit: 65536K


Total Submissions: 23819
 
Accepted: 9767




Description

Every cow's dream]]></description><category></category></item><item><title><![CDATA[ZOJ 3826 Hierarchical Notation(2014 牡丹江 H，字符串模拟)]]></title><link>https://blog.csdn.net/u012965890/article/details/40019961</link><guid>https://blog.csdn.net/u012965890/article/details/40019961</guid><author>u012965890</author><pubDate>Sun, 12 Oct 2014 17:42:32 +0800</pubDate><description><![CDATA[题意：
模拟python的字典。给出一个字典，然后有1000个查询，输出对应的键值。
分析：
简单粗暴的字符串神烦模拟。因为打的网络同步赛，内存限制得很死，采用了离线操作。
抓住这几个关键的符号：‘{’ '}' ',' ':' 进行操作。具体见代码及注释，数据不是非常恶心。]]></description><category></category></item><item><title><![CDATA[UVALive 6485 Electric Car Rally (BFS,优先队列)]]></title><link>https://blog.csdn.net/u012965890/article/details/39855259</link><guid>https://blog.csdn.net/u012965890/article/details/39855259</guid><author>u012965890</author><pubDate>Tue, 07 Oct 2014 17:13:55 +0800</pubDate><description><![CDATA[题意：
给一张无向图，中午12：00从0点出发（充满电，支持240分钟的路程），在每个点都能充电，充2分钟的电能跑1分钟，每条路按分钟分为若干个时间段，每个时间段内通过这条路的时间为ti，问到达n-1号点最少要多少时间。
分析：
BFS+优先队列。按时间优先出队，要注意将电量的存储*2（当然有其他方法），因为如果充电时间为奇数，用int存会丢失0.5。其次是要跑两个周期（两天）。判重的话有很多方法，较普遍的是开两维，位置和剩余电量，我的方法是开一维松弛，将电量化为0（x.time-x.power）。要小心的]]></description><category></category></item><item><title><![CDATA[HDU 4786 Fibonacci Tree(生成树，YY乱搞)]]></title><link>https://blog.csdn.net/u012965890/article/details/39831383</link><guid>https://blog.csdn.net/u012965890/article/details/39831383</guid><author>u012965890</author><pubDate>Mon, 06 Oct 2014 20:34:57 +0800</pubDate><description><![CDATA[题意：
给出一个无向图，每条边都已染色（黑/白），问是否存在生成树，该生成树的白色边的数量是正的fibonacci数。
分析：
所给数据中黑边为0，白边为1，那么生成树的白边数量即为生成树的权和。
然后YY了一个做法：求其最小和最大生成树，如果在这个范围内存在fibonacci数则存在。
靠谱的证明方法一直没想出来，这里随便解释下：
对于任意一颗非最大生成树，一定可以取一条白边换一条黑边使其仍然是一颗树。]]></description><category></category></item><item><title><![CDATA[HDU 4781 Assignment For Princess(YY乱搞)]]></title><link>https://blog.csdn.net/u012965890/article/details/39831163</link><guid>https://blog.csdn.net/u012965890/article/details/39831163</guid><author>u012965890</author><pubDate>Mon, 06 Oct 2014 20:22:38 +0800</pubDate><description><![CDATA[题意：
要求构造一张n个点m条有向边的图，满足如下条件：
每对点间最多有一条边；
没有自环；
从任意一点出发，可以到达其他所有点；
m条边的权值为1,2,3,...,m，所有边的权值都不同；
从任意一点出发，最后要回到该点；
所有回路的权值和为3的倍数。
分析:
随便YY下就行了。
先构造1->2->3->4->...->n->1的环，边权依次为1,2,3,4,...,n;然后调整权值为n的边（当然也可已调整其他的边，这里只是为了方便），使得该环的权值和为3的倍数。然后按模3的余数对于剩下的边权分类，对于任]]></description><category></category></item><item><title><![CDATA[UVA 11488 Hyper Prefix Sets (Trie)]]></title><link>https://blog.csdn.net/u012965890/article/details/39783285</link><guid>https://blog.csdn.net/u012965890/article/details/39783285</guid><author>u012965890</author><pubDate>Sat, 04 Oct 2014 21:44:59 +0800</pubDate><description><![CDATA[题意：

给出N个字符串，要求选出若干个，使得选中的字符串的公共前缀长度与选中字符串的个数的乘积最大。

分析：

简单粗暴的Trie模板题。

对于Tire中的每一个结点添加两个信息：该结点的深度及该结点杯访问的次数，最后求出这两个信息的最大值就行了，边加入字符串边维护就行。]]></description><category></category></item><item><title><![CDATA[HDU 2896 病毒侵袭 (AC自动机)]]></title><link>https://blog.csdn.net/u012965890/article/details/39781941</link><guid>https://blog.csdn.net/u012965890/article/details/39781941</guid><author>u012965890</author><pubDate>Sat, 04 Oct 2014 20:14:19 +0800</pubDate><description><![CDATA[http://acm.hdu.edu.cn/showproblem.php?pid=2896

病毒侵袭
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 11796    Accepted Submission(s): 3067]]></description><category></category></item><item><title><![CDATA[UVA 10679 I love Strings!!!(AC自动机)]]></title><link>https://blog.csdn.net/u012965890/article/details/39781311</link><guid>https://blog.csdn.net/u012965890/article/details/39781311</guid><author>u012965890</author><pubDate>Sat, 04 Oct 2014 18:54:18 +0800</pubDate><description><![CDATA[http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1620





题意：
给出一个文本串和若干个模式串，问模式串是否在文本串中出现过。
分析：
简单粗暴的AC自动机模板题，要注意模式串可能有重复的情况。


/*
 *
 * Aut]]></description><category></category></item><item><title><![CDATA[AC自动机模板]]></title><link>https://blog.csdn.net/u012965890/article/details/39781287</link><guid>https://blog.csdn.net/u012965890/article/details/39781287</guid><author>u012965890</author><pubDate>Sat, 04 Oct 2014 18:45:50 +0800</pubDate><description><![CDATA[AC自动机，继承自Trie]]></description><category></category></item><item><title><![CDATA[Trie树模板]]></title><link>https://blog.csdn.net/u012965890/article/details/39779499</link><guid>https://blog.csdn.net/u012965890/article/details/39779499</guid><author>u012965890</author><pubDate>Sat, 04 Oct 2014 14:19:47 +0800</pubDate><description><![CDATA[Trie树，包括插入查找]]></description><category></category></item></channel></rss>