【小小复习·大米饼】

(一)数位DP模板

·LIS的数位DP:

image

·含b进制数个数+数形结合的数位DP

image

·平衡数的数位DP:

image

(二)网络流问题

·Edmonds_Karp:(见书)·Dinic(见书)·ISAP(见书)·例题详见大米饼博客

(三)树链剖分

·基本操作小题:

一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成一些操作:

I. CHANGE u t : 把结点u的权值改为t

II. QMAX u v: 询问从点u到点v的路径上的节点的最大权值

III. QSUM u v: 询问从点u到点v的路径上的节点的权值和 注意:从点u到点v的路径上的节点包括u和v本身

image

image

·超棒LCA:

给出一个n个节点的有根树(编号为0到n-1,根节点为0)。一个点的深度定义为这个节点到根的距离+1。
设dep[i]表示点i的深度,LCA(i,j)表示i与j的最近公共祖先。
有q次询问,每次询问给出l r z,求sigma_{l<=i<=r}dep[LCA(i,z)]。
(即,求在[l,r]区间内的每个节点i与z的最近公共祖先的深度之和)

image

·区间转树结构

公元 2044 年,人类进入了宇宙纪元。L 国有 n 个星球,还有 n−1 条双向航道,每条航道建立在两个星球之间,这 n−1 条航道连通了L 国的所有星球。小 P 掌管一家物流公司,该公司有很多个运输计划,每个运输计划形如:有一艘物流飞船需要从 ui 号星球沿最快的宇航路径飞行到 vi 号星球去。显然,飞船驶过一条航道是需要时间的,对于航道 j,任意飞船驶过它所花费的时间为 tj,并且任意两艘飞船之间不会产生任何干扰。为了鼓励科技创新, L 国国王同意小 P 的物流公司参与 L 国的航道建设,即允许小P 把某一条航道改造成虫洞,飞船驶过虫洞不消耗时间。在虫洞的建设完成前小 P 的物流公司就预接了 m 个运输计划。在虫洞建设完成后,这 m 个运输计划会同时开始,所有飞船一起出发。当这 m 个运输计划都完成时,小 P 的物流公司的阶段性工作就完成了。如果小 P 可以自由选择将哪一条航道改造成虫洞, 试求出小 P 的物流公司完成阶段性工作所需要的最短时间是多少?

image

·哪里冒出来的博弈论Nim?

著名游戏设计师vfleaking,最近迷上了Nim.普通的Nim游戏为:两个人进行游戏,N堆石子,每回合可以取其中某一堆的任意多个,可以取完,但不可以不取.谁不能取谁输.这个游戏是有必胜策略的。于是vfleaking决定写一个玩Nim游戏的平台来坑玩家。
为了设计漂亮一点的初始局面,vfleaking用以下方式来找灵感:拿出很多石子,把它们聚成一堆一堆的,对每一堆编号1,2,3,4,...n,在堆与堆间连边,没有自环与重边,从任意堆到任意堆都只有唯一一条路径可到达。然后他不停地进行如下操作:
1.随机选两个堆v,u,询问若在v到u间的路径上的石子堆中玩Nim游戏,是否有必胜策略,如果有,vfleaking将会考虑将这些石子堆作为初始局面之一,用来坑玩家。
2.把堆v中的石子数变为k。

image

附:SG函数Nim游戏解题模型:

1.把原游戏分解成多个独立的子游戏,则原游戏的SG函数值是它的所有子游戏的SG函数值的异或。

即sg(G)=sg(G1)^sg(G2)^...^sg(Gn)。

2.分别考虑没一个子游戏,计算其SG值。SG值的计算方法:

1.可选步数为1~m的连续整数,直接取模即可,SG(x) = x % (m+1);

2.可选步数为任意步,SG(x) = x;

3.可选步数为一系列不连续的数,用模板计算。

(四)伸展树

      ·模板和例题均详见大米饼博客

(五)树状数组

·所有上升子序列

An increasing subsequence from a sequence A1, A2 ... An is defined by Ai1, Ai2 ... Aik, where the following properties hold

1. i1 < i2 < i3 < ... < ik and

2. Ai1 < Ai2 < Ai3 < ... < Aik

Now you are given a sequence, you have to find the number of all possible increasing subsequences.

image

·点修改区间查询

Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick. He keeps n sacks where he keeps this money. The sacks are numbered from 0 to n-1.Now each time he can he can do one of the three tasks.           1) Give all the money of the ith sack to the poor, leaving the sack empty.

                 2) Add new amount (given in input) in the ith sack.

                 3) Find the total amount of money from ith sack to jth sack.

Since he is not a programmer, he seeks your help.

image

·所有长度为K+1的上升子序列(DP)

由1到n,共n个数构成的序列中长为k + 1的上升子序列有多少个?

f[i][j]为长度为i的子序列中,末尾数以j结尾的个数.
那么容易有转移方程:
f[i][j]=∑(t=1...j−1)f[i−1][t]

image

·区间真子集个数

         给出N个区间,问这个区间是多少个区间的真子集。

image

·求逆序数(递推辅助)

image

(五)线段树

·简化的扫描线:求地平线上面积并

image

image

·扫描线,求面积并。

image

image

image

·扫描线,求周长并。

image

image

(六)主席树

·求某区间第K大数。

You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickly k-th order statistics in the array segment. That is, given an array a[1...n] of different integer numbers, your program must answer a series of questions Q(i, j, k) in the form: "What would be the k-th number in a[i...j] segment, if this segment was sorted?" For example, consider the array a = (1, 5, 2, 6, 3, 7, 4). Let the question be Q(2, 5, 3). The segment a[2...5] is (5, 2, 6, 3). If we sort this segment, we get (2, 3, 5, 6), the third number is 5, and therefore the answer to the question is 5.

image

·Kuerskal重构树+倍增+DFS序+主席树。

        在Bytemountains有N座山峰,每座山峰有他的高度h_i。有些山峰之间有双向道路相连,共M条路径,每条路径有一个困难值,这个值越大表示越难走,现在有Q组询问,每组询问询问从点v开始只经过困难值小于等于x的路径所能到达的山峰中第k高的山峰,如果无解输出-1。强制在线

image

image

image

image

(七)KMP算法

·模板题

image

(八)Aho-Corasick Automaton

·详见教材和代码仓库例题

模板:

image

image

image

(九)二分图匹配

·二分图判定+最大匹配

There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other. Now you are given all pairs of students who know each other. Your task is to divide the students into two groups so that any two students in the same group don't know each other.If this goal can be achieved, then arrange them into double rooms. Remember, only paris appearing in the previous given set can live in the same room, which means only known students can live in the same room. Calculate the maximum number of pairs that can be arranged into these double rooms.

image

(十)最短路应用

·次短路:

wpsFAD6.tmp

分析:

图解

(十一)Range Minimum/Maximum Query

image

(十一)最近公共祖先倍增算法

image

 

(十二)最小环判定(floyd改造)

image

(十三)一包组合数学问题

·详见蓝书

(十四)manacher

image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

阳光洒满这个城市,车辆穿梭鸟儿轻鸣……”————汪峰《最后一次见到你》

posted @ 2017-04-07 10:32  大米饼  阅读(661)  评论(1编辑  收藏  举报