uva
KIDGINBROOK
这个作者很懒,什么都没留下…
展开
-
uva 11019 Matrix Matcher 字符串哈希
题意:一个文本矩阵和一个模式矩阵,求模式矩阵在文本矩阵中出现次数。 二维哈希。 #include #include #include using namespace std; #define a 321 #define b 207 #define ull long long int n,m,x,y; ull h1[1100][1100],h2[1100][1100]; char T[11原创 2015-01-15 11:58:05 · 575 阅读 · 0 评论 -
uva 1104 chips challenge 费用流
题目大意:一个芯片可以看成由n*n的插槽组成,每个插槽有三种可能 1. 必须放置一个零件 2. 可以放一个零件也可以不放 3. 不能放置零件 要求 1. 第i行的零件要和第i列的零件一样多 2. 第i行的零件数不能超过总零件数的A / B (A, B为给定的) 求 最多可以放的零件数 - 必须放置的零件数 首先看如何满足第一个条件,假设知道了满足该条件的答案为第i行零件数为xi,那么把每行每列都...原创 2018-11-29 17:47:08 · 500 阅读 · 2 评论 -
uva 1674 Lightning Energy Report 树链剖分
题目大意:一棵树,每次操作使得u,v间的路径上所有点权重加w,问最后每个点的权重 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int maxn = 5e4 + 10; #define ...原创 2018-11-22 15:29:51 · 270 阅读 · 0 评论 -
uva 12161 Ironman Race in Treeland 点分治
题目大意:一棵节点数为n的树,每条边有一个长度l和一个花费d,求一条路径,使得路径的总花费小于给定的m,且总长度最大 还是点分治,将这个无根树转为有根树之后,一条路径要么完全在某一子树下,要么经过根,子树的问题可以递归解决, 现在看经过根的情况,按序处理每一棵子树v,通过dfs可以得到该子树v所有节点到根的路径长度和花费,然后需要得到子树v这个集合 每一个点和已处理过子树的集合u内每一个点两两组...原创 2018-11-21 17:13:17 · 317 阅读 · 0 评论 -
poj 1741 Tree 点分治
Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 30775 Accepted: 10301 Description Give a tree with n vertices,each edge has a length(positive integer less than 10...原创 2018-10-29 16:24:02 · 124 阅读 · 0 评论 -
uva 1329 Corporative Network && uva 1160 X-Plosives 并查集
A very big corporation is developing its corporative network. In the beginning each of the N enterprisesof the corporation, numerated from 1 to N, organized its own computing and telecommunication cen...原创 2018-09-10 11:46:13 · 263 阅读 · 0 评论 -
uva 12093 Protecting Zonk 树形dp
题目大意:有n个城市和n-1条路组成了一个树,现在有花费为c1的机器人A和花费为c2的机器人B,两种机器人都是无限量的,如果在城市u放置机器人A,此时与u连接的边都会被覆盖,如果在城市u放置机器人B,那么与u相连的边都会被覆盖,且与u相连的点所相连的边也会被覆盖,现问将所有道路都覆盖所需最小花费 dp[u][0] :以点u为根的子树下的边全部被覆盖,且没有向u节点上方覆盖 dp[u][原创 2017-11-22 13:46:47 · 512 阅读 · 0 评论 -
uva 11354 bond 倍增
n个城市通过m条无向边连接,回答q个询问,每个询问形式为s,t,要找到一条s到t的路使得这条路上的最大危险系数最小。 还是最小瓶颈路,可是要快速回答每次询问,先求出最小生成树,转化为有根树,即找到s到t的路径上的最大边,在这一过程中倍增查找。 预处理的复杂度为nlogn,每次查询为logn。 #include #include #include #include usin原创 2015-10-02 22:13:29 · 410 阅读 · 0 评论 -
uva 11396 Claw Decomposition 二分图判定
题意:给定一个无向图,每个顶点的度数都是3,问是否可以将它分解为爪,其中每条边必须属于一个爪,但一个顶点可以出现在多个爪中。 爪的中心点称为a类点,其他三个称为b类点,可以发现a点周围全是b点,b点周围全是a点,所以只要判定是否为二分图即可。 #include #include #include #include using namespace std; #define maxn 36原创 2015-02-16 18:05:10 · 445 阅读 · 0 评论 -
UVa 10887 - Concatenation of Languages 哈希
题意:将A集合的词与B集合中的词两两连接,求非重复的有多少个。 哈希,我直接用的map。 #include #include #include #include #include using namespace std; map mp; int cas,n,m; int sum=0; char s1[1600][15],s2[1600][15]; char c[30]; int m原创 2015-01-15 12:34:27 · 437 阅读 · 0 评论 -
uva 11525 Permutation 线段树
题目大意:给定n和k,输出1-k的所有置换按照字典序排列后的第n个置换,其中n由k个数Si给定 当i等于1的时候(k - 1)!就是后面k-1个数所有的置换的个数,然后前面乘si,所以第n个置换的第一个数字即si + 1,同理,可发现其实就是每次求第k大,然后删去该数字。 #include <cstdio> #include <algorithm> #includ...原创 2019-03-01 20:18:55 · 252 阅读 · 0 评论