
图论
一条很咸的鱼
这个作者很懒,什么都没留下…
展开
-
虚树
将树压缩成若干个有用的点for(int i=0;i<k;++i){ int f=lca(stk[r],h[i]); while(r&&id[f]<id[stk[r-1]]){ g1.add(stk[r-1],stk[r],get(stk[r],stk[r-1])); --r; } if(f^stk[r])...原创 2020-01-07 14:21:17 · 213 阅读 · 0 评论 -
费用流
#include<bits/stdc++.h>using namespace std;char buf[1<<20],*_=buf,*__=buf;#define gc() (_==__&&(__=(_=buf)+fread(buf,1,1<<20,stdin),_==__)?EOF:*_++)#define TT template<...原创 2019-12-13 17:51:33 · 233 阅读 · 0 评论 -
Tarjan
Tarjan割点low[x]:x能到达的cnt最小的节点(包括x自身节点)对于x节点,存在dfs树上x的子节点y,low[y]>=low[x],即y能到达的最小编号节点是以x为根节点的子树,删除x之后,y与x的父节点不连通(特判根节点)void tarjan(int x){ low[x]=dfn[x]=++tarcnt; int flag=0; for(int...原创 2019-12-12 14:57:08 · 144 阅读 · 0 评论 -
树剖top数组
好像很少有关于top数组性质的博客。for(int i=top[x];fa[i];i=top[fa[i]])可以遍历所有子树中含有x节点的重链链头节点(或叶子节点),由于重链不超过log(n)个,所以这个循环复杂度是O(logN)的。设i是重链链头节点,f是i的父节点,则i是f的轻儿子。所以,如果有操作:对于x节点,他的所有儿子均加上不同的值,且这个值只与儿子节点自身和提供的值有关,那么...原创 2019-11-22 11:44:44 · 182 阅读 · 0 评论 -
cf-ronnd-600-F-Cheap Robot
Cheap RobotYou’re given a simple, undirected, connected, weighted graph with n nodes and m edges.Nodes are numbered from 1 to n. There are exactly k centrals (recharge points), which are nodes 1,2,…...原创 2019-11-18 19:30:03 · 194 阅读 · 0 评论 -
kruskal重构树
解决图中:任意两节点(可以不连通)找到x<->y路径中边权的最小值最大,反之亦然(也可以用树剖写)给定起点,经过的路径边权有某限制下的(如小于等于某值)点权第k小(大),需要主席树。对于1:看着像二分。。对原图边权排序,生成树是直接并查集merge x,y两个节点,重构树的话会新生成一个节点,并把原来的x与y的边断开,用边权当做新节点的点权。//ff[]是并查集for...原创 2019-11-01 16:03:36 · 119 阅读 · 0 评论 -
POJ 3249 DAG图最短路 toposort+dp
Test for JobMr.Dog was fired by his company. In order to support his family, he must find a new job as soon as possible. Nowadays, It’s hard to have a job, since there are swelling numbers of the une...原创 2019-10-10 15:43:46 · 242 阅读 · 0 评论 -
点集直径
MMSet2给定一棵n个节点的树,点编号为1…n。Q次询问,每次询问给定一个点集S,令,f(u)=maxv∈Sdist(u,v)f(u)=\max_{v\in S}dist(u,v)f(u)=maxv∈Sdist(u,v)你需要求出minu=1…nf(u)\min_{u=1\dots n}f(u)minu=1…nf(u)其中dist(u,v)表示树上路径(u,v)的边数。输入描述...原创 2019-10-08 22:24:10 · 832 阅读 · 0 评论 -
Superdoku 二分图匹配
SuperdokuAlice and Bob are big fans of math. In particular, they are very excited about playing games that are related to numbers. Whenever they see a puzzle like Sudoku, they cannot stop themselves ...原创 2019-07-31 23:43:55 · 165 阅读 · 0 评论 -
Dijkstra+二分查找
Telephone Lines 题目描述Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his fa...原创 2019-07-29 16:57:01 · 165 阅读 · 0 评论