解题报告
文章平均质量分 78
Hermit_Inwind
这个作者很懒,什么都没留下…
展开
-
CODEFORCES #339 div2 A
A. Link/Cut TreeProgrammer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.Unfortunatel原创 2016-01-15 21:33:06 · 420 阅读 · 0 评论 -
codeforces 798C 数学
题目链接大致题意是给出一个序列,有一种操作对序列中的数Vi 能够将Vi变为Vi-Vi+1,将Vi+1变为Vi+Vi+1。问最少进行多少次操作可以使序列的gcd大于1。显然对于序列初始的gcd>1的,结果为0对于初始gcd=1的情况需要做一些推导和证明。对一次操作后新的gcd值d显然可以整除Vi-Vi+1和Vi+Vi+1.。那么可以知道d可以整除(Vi-Vi+1+Vi原创 2017-04-22 11:19:27 · 368 阅读 · 0 评论 -
最小度限制生成树 POJ1639
今天了解了一下最小度限制生成树。这个问题的本质依旧是生成树,但是对于某个点的度给定限制。也就是连到该点上的边不能超过限制的数量limit。具体的解决过程和相关的证明可以看一下《最小生成树问题的扩展》这篇论文。这里简单讲一下解决问题的流程也方便我之后来复习。1,用除去和有限制的点相连的以外的边做最小生成树。这个时候可能不能保证所有点都连通,那么可能会出现几个连通块。如果连通块的数量超过了限制原创 2017-07-10 19:18:27 · 557 阅读 · 0 评论 -
HDU4751 二分图判断
http://acm.hdu.edu.cn/showproblem.php?pid=4751建图,染色判断是否为二分图#includeusing namespace std;const int maxn = 105;const int maxm = 2e4+100;struct Edge{ int to, nx;}e[maxm];int head[maxn]原创 2017-07-10 19:39:38 · 312 阅读 · 0 评论 -
HDU1166敌兵布阵 分块解法,分块练习
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1166线段树,树状数组的模板题。用来入门分块。#includeusing namespace std;const int N = 5e4+10;int block;int n;int arr[N], sum[N];void update(int pos, int va原创 2017-07-02 20:51:05 · 310 阅读 · 0 评论 -
CF501B STL
有n个修改操作,一些人会把原本的handle做修改,最后问有哪些handle被修改并输出这些handle的最终版本用map记录修改映射,vector记录最初的handle#include#define PB push_backusing namespace std;map mp;vector vec;int main(){ int n; string原创 2017-07-15 19:47:14 · 334 阅读 · 0 评论 -
CF697D 树形DP
题目链接:http://codeforces.com/contest/697/problem/D给出一颗树的描述,从根节点开始,以DFS序遍历。每次随机走向当前节点的儿子节点,没有子节点的时候就回溯。问遍历到树中每个点的期望步数。考虑某一层DFS,假设我们已经求出该层根节点Root的答案ans[Root]。求该层x节点的答案。对于其他的节点有1/2的概率会排在该节点前面,对ans[原创 2017-07-07 11:00:44 · 557 阅读 · 0 评论 -
POJ 3683 2-SAT 输出可行方案
http://poj.org/problem?id=36831,根据矛盾建边2,tarjan求scc判断可行性3,根据scc缩点建反向边4,拓扑排序,按顺序输出选择情况#include#include#include#include#include#includeusing namespace std;const int maxn = 2005原创 2017-08-01 18:34:36 · 382 阅读 · 0 评论 -
ZOJ3430 AC自动机
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3430先把base64编码转化为正常编码,然后AC自动机匹配参考了http://blog.csdn.net/gatevin/article/details/41214249的代码风格,感觉这个AC自动机比自己之前的好上不少#include原创 2017-08-02 13:47:41 · 363 阅读 · 0 评论 -
Codeforces 387E 树状数组
http://codeforces.com/problemset/problem/387/E记录每个数的下标,对数从小到大考虑。如果该数需要保留,那么就往set中插入该数的下标。否则可以查询出当前数左边和右边第一个比它小的数的下标,可以统计这个区间中已经删掉的数的数量,就可以计算出当前数的贡献。#includeusing namespace std;const int原创 2017-08-02 15:59:53 · 351 阅读 · 0 评论 -
虚树学习 codeforces613D
第一次接触虚树参考博客学习 http://blog.csdn.net/braketbn/article/details/50887470虚树是根据需要查询的点以及他们的lca重新构建的一颗树,链之间的信息整合压缩后保存在新的边上。然后这道题就是根据关键点和它们的lca构建虚树,然后做树上DP。针对当前访问的点是否为关键点进行分类处理。如果是关键点,如果其儿子节点的子树中存在原创 2017-07-26 18:46:47 · 299 阅读 · 0 评论 -
ZOJ2006 字符串最小表示
http://blog.csdn.net/zy691357966/article/details/39854359字符串最小表示 相关证明与模板字符串最小表示入门模板题#includeusing namespace std;const int maxn = 1e4+10;int Min(const char *str, int len){ int i,原创 2017-07-26 19:54:50 · 309 阅读 · 0 评论 -
POJ1417 True Liars (并查集+背包)
题目链接:http://poj.org/problem?id=1417大致题意:有两类人,好人和坏人,好人只会说真话,坏人只会说假话,有k组询问,p1个好人,p2个坏人。每组向a询问b是否为好人,得到答复yes或no。问通过已知询问是否能够判断出所有的好人。若不能输出"no",可以则输出代表好人的编号。在看了博客文章之后才有比较清晰的思路,感觉自己对综合性稍强的题目就已经没原创 2016-07-09 18:35:56 · 611 阅读 · 0 评论 -
CODEFORCES #339 div2 C
C. Peter and Snow BlowerPeter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regul原创 2016-01-17 00:59:17 · 376 阅读 · 0 评论 -
HDU 2062 Subset sequence
题目描述:DescriptionConsider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexi原创 2016-01-03 00:58:57 · 1305 阅读 · 0 评论 -
HDU 1709 The Balance
DescriptionNow you are asked to measure a dose of medicine with a balance and a number of weights. Certainly it is not always achievable. So you should find out the qualities which cannot be measure原创 2016-01-23 14:32:10 · 305 阅读 · 0 评论 -
POJ 1860 Currency Exchange
DescriptionSeveral currencyexchange points are working in our city. Let us suppose that each pointspecializes in two particular currencies and performs exchange operations onlywith these currencies.原创 2016-02-05 21:50:07 · 274 阅读 · 0 评论 -
POJ2488 A Knight's Journey
DescriptionBackground The knight is getting bored of seeing the same black and white squares againand again and has decided to make a journeyaround the world. Whenever a knight moves, it is tw原创 2016-01-31 15:34:56 · 271 阅读 · 0 评论 -
Codeforces #179(Div 2)C Greg and Array
题目链接:http://codeforces.com/contest/296/problem/C题意: 一个序列中有n个数,有m个操作,每个操作将从a到b的数加上d,接下来有k对数,每对由a,b组成,代表把从a到b的操作都执行一次。问将k对数代表的操作全部执行完后序列中的数各是多少。思路:初看觉得应该用线段树区间更新实现,但是要写两棵树,有些麻烦。但是对于每个操作只需要记录这个操作原创 2016-07-11 10:48:09 · 399 阅读 · 0 评论 -
HDU5726
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5726ST预处理区间GCD,由唯一分解定理可知,任意起点开始的区间GCD值最多只有logN个,所以可以枚举起点,依靠ST二分求gcd变化的位置求出某起点开始的区间GCD为某值的区间个数,然后用map映射。#include#include#include#include#include原创 2016-07-27 08:46:30 · 655 阅读 · 1 评论 -
HDU2852 KiKi's K-Number (线段树求数列K大)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2852大致题意:有三种操作:第一种:向容器中加入数字A。 第二种:从容器中删除数字A,若容器中不存在该数则输出"No Elment!"第三种:输入A,K;求容器中比A大的数中的第K个数,若不存在则输出"Not Find!"原创 2016-07-05 20:55:31 · 367 阅读 · 0 评论 -
POJ2001 字典树
题目链接:http://poj.org/problem?id=2001大致题意:给出若干行单词,最后给每个单词求出最短的且唯一的前缀。其中,单词本身作为前缀的,它的最短独立前缀为自己本身。思路:字典树模板题,字典树节点元素中存储以从根节点到该节点处的串为前缀的字符串的数量,然后查找的时候查找到前缀为1或者查完单词的时候所查询到的串即为该单词所求的最短独立前缀。#include原创 2016-07-19 19:42:20 · 375 阅读 · 0 评论 -
HDU1671 字典树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1671大致题意:T组询问,每组给出n个号码,如果该组中出现以其他串为前缀的串就输出“NO",否则输出”YES"。思路:字典树模板#include#include#includeusing namespace std;char str[10005];int n;st原创 2016-07-19 19:53:28 · 292 阅读 · 0 评论 -
HDU3410 Passing the Message (单调队列,线段树可解)
Passing the MessageTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 534 Accepted Submission(s): 333Problem DescriptionWhat a s原创 2016-07-06 16:43:26 · 424 阅读 · 0 评论 -
ZOJ 1729
字符串最小表示 模板#includeusing namespace std;const int maxn = 1e5+10;int MinRepresentation(const char *s, int len){ int i, j, k; i = k = 0; j = 1; while(i < len && j < len){ k原创 2017-07-26 20:13:02 · 326 阅读 · 0 评论