Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. Wait a minute… you realized that it isn’t as easy as you thought. Think about the virus killers. They’ll find your software…
Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others) Total Submission(s): 2302    Accepted Submission(s): 724 Problem Description Great! Your new software is almost finished! The only thing left to do is archiving a…
题意:给定n个文本串,m个病毒串,文本串重叠部分可以合并,但合并后不能含有病毒串,问所有文本串合并后最短多长. (2 <= n <= 10, 1 <= m <= 1000) 题解: 首先可以想出一个简单的位压DP : d[s][i] = min(d[ss][j] - 合并i.j的重叠部分长度) 问题就集中在了如何求出两个串x.y合并后的最短长度并且合并后不能包含病毒串. 引用一个题解:来自http://blog.csdn.net/woshi250hua/article/detail…
题目链接:hdu_3247_Resource Archiver 题意: 有n个资源串,m个病毒串,现在要将所有的资源串整合到一个串内,并且这个串不能包括病毒串,问最短的串长为多少 题解: 将资源串和病毒串都插入到AC自动机中,分别做好标记,然后用bfs求出0节点和所有资源串互相的最短距离,最后就是一个TSP的状态压缩DP. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=b;i++) using namespace std;…
题目链接:https://vjudge.net/problem/HDU-3247 Resource Archiver Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)Total Submission(s): 3228    Accepted Submission(s): 1052 Problem Description Great! Your new software i…
\(\quad\)Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. \(\quad\)Wait a minute- you realized that it isn't as easy as you thought. Think about the virus killers. They'll f…
链接 这题没想到怎么做,问了下p队长,大悟.. 先求出任意两串的在trie树上的最短距离,期间是不能走到不合法的地方,我是用spfa求得,在更新和加入节点时判断一下是不是合法位置. 求出最短距离之后,找出一条从0出发遍历所有串的最短距离,可以dp出,dp[i][j]表示当前状态以节点j串结尾的最短距离. 枚举一下最后结尾的为哪一个串时距离最短. #include <iostream> #include<cstdio> #include<cstring> #include…
题意:给定 n 个文本串,m个病毒串,文本串重叠部分可以合并,但合并后不能含有病毒串,问所有文本串合并后最短多长. 析:先把所有的文本串和病毒都插入到AC自动机上,不过标记不一样,可以给病毒标记-1,如果访问知道就知道不可行的,然后处理出两两串叠加的最小长度,这个要用bfs,在AC自动机上把这个处理出来,然后剩下的就是一个简单的DP了,dp[s][i] 表示状态为 s 时,i 串在后面,长度最短是多少. 代码如下: #pragma comment(linker, "/STACK:10240000…
Resource Archiver Time Limit: 10000MS   Memory Limit: 100000KB   64bit IO Format: %I64d & %I64u Description Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. Wait a minute… y…
Description Great! Your new software is almost finished! The only thing left to do is archiving all your n resource files into a big one. Wait a minute- you realized that it isn't as easy as you thought. Think about the virus killers. They'll find yo…