摘要: 伸展树 多值版 #include<bits/stdc++.h> using namespace std; template<class T> inline bool read(T &x){ x=0;register char c=getchar();register bool f=0; while( 阅读全文
posted @ 2020-12-19 22:48 肆之月 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 树剖版lca 树剖自带lca #include<bits/stdc++.h> using namespace std; template<class T>inline bool read(T &x){ x=0;register char c=getchar(); while(!isdigit(c)) 阅读全文
posted @ 2020-12-19 22:47 肆之月 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 树链剖分(点) 解决: 将两个节点之间的简单路径上的点的权值加上v 求两个节点之间的简单路径上的点的权值之和 以某一节点为根节点的子树内所有的点的权值加上v 求某一节点为根节点的子树内所有的点的权值之和 思想: 将数划分成若干链,用线段树或者树状数组对这些链进行操作 重儿子:对于非叶子节点x,以x的 阅读全文
posted @ 2020-12-19 22:45 肆之月 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 解决图中: 任意两节点(可以不连通)找到x<->y路径中边权的最小的最大值,反之亦然(也可以用树剖写) 给定起点,经过的路径边权有某限制下的(如小于等于某值)点权第k小(大),需要主席树。 对于1: 看着像二分。。 对原图边权排序,生成树是直接并查集merge x,y两个节点,重构树的话会新生成一个 阅读全文
posted @ 2020-12-19 22:39 肆之月 阅读(67) 评论(0) 推荐(0) 编辑
摘要: P3084 [USACO13OPEN]照片Photo 农夫约翰决定给站在一条线上的N(1 ⇐ N ⇐ 200,000)头奶牛制作一张全家福照片,N头奶牛编号1到N。 于是约翰拍摄了M(1 ⇐ M ⇐ 100,000)张照片,每张照片都覆盖了连续一段奶牛:第i张照片中包含了编号a_i 到 b_i的奶牛 阅读全文
posted @ 2020-12-18 17:23 肆之月 阅读(295) 评论(0) 推荐(0) 编辑
摘要: P2467 [SDOI2010]地精部落 题目描述 传说很久以前,大地上居住着一种神秘的生物:地精。 地精喜欢住在连绵不绝的山脉中。具体地说,一座长度为N的山脉H可分为从左到右的N段,每段有一个独一无二的高度Hi,其中Hi是1到N之间的正整数。 如果一段山脉比所有与它相邻的山脉都高,则这段山脉是一个 阅读全文
posted @ 2020-12-18 17:21 肆之月 阅读(62) 评论(0) 推荐(0) 编辑
摘要: Lights inside 3D Grid You are given a 3D grid, which has dimensions X, Y and Z. Each of the X x Y x Z cells contains a light. Initially all lights are 阅读全文
posted @ 2020-12-18 17:19 肆之月 阅读(81) 评论(0) 推荐(0) 编辑
摘要: Discovering Gold You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. In 阅读全文
posted @ 2020-12-18 17:18 肆之月 阅读(82) 评论(0) 推荐(0) 编辑
摘要: A Dangerous Maze You are in a maze; seeing n doors in front of you in beginning. You can choose any door you like. The probability for choosing a door 阅读全文
posted @ 2020-12-18 17:17 肆之月 阅读(117) 评论(0) 推荐(0) 编辑
摘要: String painter Problem Description There are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a pow 阅读全文
posted @ 2020-12-18 17:16 肆之月 阅读(87) 评论(0) 推荐(0) 编辑