随笔分类 - 数据结构
摘要:枚举,每次增加点,删除点 }
阅读全文
摘要:先做拓扑排序,再bfs处理 }
阅读全文
摘要:先做一次dfs求得每个节点为根的子树在树状数组中编号的起始值和结束值,再树状数组做区间查询 与单点更新。 #include<cstdio>#include<iostream>#include<cstdlib>#include<cstring>#include<string>#include<algo
阅读全文
摘要:链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 2038: [2009国家集训队]小Z的袜子(hose) Description 作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法
阅读全文
摘要:#include #include #include #include #include using namespace std; #define num(x) x-'a'; #define MAX 1000000 struct Trie{ int next[26]; int count; int prefix;//记录以此为前缀串的数量 }tree[MAX]; ...
阅读全文
摘要:题目链接:http://poj.org/problem?id=2299 求逆序数的经典题,求逆序数可用树状数组,归并排序,线段树求解,本文给出树状数组,归并排序,线段树的解法。 归并排序: 树状数组: 线段树( 以HDU1394 Minimum Inversion Number为例):
阅读全文

浙公网安备 33010602011771号