自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(36)
  • 收藏
  • 关注

原创 UVA - 12295 最短路+递推

有一个n*n的矩阵,要求从(1,1)到(n,n)的最短路数量,路径的权值是所经过元素的和,且路径与对角线对称。由于路径是对称的,可以先预处理将右下角的元素加到左上角,那么就只用计算(1,1)到对角线的最短路数量了,计算最短路可以用dijkstra,要计算数量只需要在dijkstra的过程中递推一下就好了。#include<cstdio>#include<vector&...

2020-04-02 18:30:50 348

原创 FZU - 2205

有n个点,要求连最多的双向边使图中不存在任意三个点直接连接可以考虑将n个点分为两个集合,分别有a,b个点,则n=a+b,相同集合的点不连接,不同集合的点全连接,则边数c=a*b,根据均值不等式可以知道当n为偶数时a=b=n/2,c最大,当n为奇数时a=n/2,b=n/2+1,c最大。#include<cstdio>#include<vector>#includ...

2020-04-01 22:59:59 280

转载 欧拉降幂公式与证明

欧拉降幂公式与证明转载自D-Tesla欧拉降幂公式AK≡AK%ϕ(m)+ϕ(m)( mod m)  K>ϕ(m)A^K\equiv A^{K \%\phi(m) +\phi(m)}(\ mod\ m)\qquad \; K > \phi(m)AK≡AK%ϕ(m)+ϕ(m)( mod m)K>ϕ(m)证明今天在牛客多校的群里看一个数...

2019-12-09 15:19:53 624

原创 二分图匹配总结

二分图匹配关键在于如何建图哪些问题可以用二分图匹配:题目中明确给出了两两关系,寻找满足关系最大组数。 题目没给出明确的关系,但可以寻找内在的关系建立二分图求解。哪些关系可以建立二分图求解:题目明确给出两组顶点以及之间的关系HDU - 1083 题目给出一组顶点以及之间的关系,且满足二分图的特性HDU - 2444 二维坐标轴中的行和列匹配 HDU - 1045 插入...

2019-12-04 14:03:06 328

原创 二分图最小点覆盖=最大匹配数 证明

在二分图中,我们可以把最小点覆盖理解为去掉图中尽可能少的点使得图中的边数为零。P1为需要去掉的点的集合,P2为不需要去掉的点的集合,点u属于集合P1,点v属于集合P2。P2中必定不存在边,否则与使得边数为零的思想矛盾。对于任意的u必定存在至少一条边使得u与P2相连,因为如果没有任何边使得u与P2相连,我们就没必要去掉u,与尽可能少的去掉点的思想矛盾。我们将图中的点两两配对,配对的关系可以分为三种情...

2019-12-03 21:38:03 561

原创 HDU - 2389 二分图HK算法(记个模板)

推荐博客:https://blog.csdn.net/qq_43202683/article/details/89113604You’re giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It’s a warm, sunny eve...

2019-11-28 13:35:17 785

原创 Fire Net HDU - 1045 二分图匹配

Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.A blockhouse is a small castle t...

2019-11-25 16:18:01 241

原创 Restore Permutation CodeForces - 1208D

An array of integersp1,p2,…,pnp1,p2,…,pnis called a permutation if it contains each number from11tonnexactly once. For example, the following arrays are permutations:[3,1,2],[1],[1,2,3,4,5][3,1...

2019-11-11 21:31:59 366 1

原创 Fansblog HDU - 6608

Farmer John keeps a website called ‘FansBlog’ .Everyday , there are many people visited this blog.One day, he find the visits has reached P , which is a prime number.He thinks it is a interesting fact...

2019-11-11 13:51:19 175

原创 约会安排 HDU 4553 双线段树+区间合并+区间索引

约会安排HDU 4553 https://vjudge.net/contest/293027#problem/L注意区间索引方法和Lazy标记的优先级  寒假来了,又到了小明和女神们约会的季节。  小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会。与此同时,也有很多基友找他开黑,由于数量实在过于巨大,怎么安...

2019-10-16 21:18:39 434

原创 Vases and Flowers 线段树+二分

Vases and FlowersAlice有N个花瓶(标号为0~N-1)。当她收到一些花时,她会随机的选择一个瓶子A,从它开始遍历A,A+1, A+2, ..., N-1号瓶子,遇到空瓶子就放一朵花进去,直到花朵放完或没有瓶子,剩下的花将被丢弃。有时,她也会清理标号从A到B的花瓶(A <= B).花瓶里的花会被丢弃。Input  第一行一个整数T,表示数据组数。 ...

2019-10-16 21:17:54 156

原创 多操作线段树

TransformationYuanfang is puzzled with the question below:There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to ea...

2019-10-16 21:17:05 136

原创 DP分析记录

一般DP只有两个维度,但有时要用到第三个维度(这里维度不是指维护的变量数量,而是指空间,层级,每层的种类),二维的DP只有空间,层级 ,而每层的种类为1。当每层的种类不为1时,也就是三维DP,这时每层要进行多次DP。三维DP例题:https://www.luogu.org/problem/P3961题目描述小A最近迷上了在上课时玩《黄金矿工》这款游戏。为了避免被老师发现,他必须小心翼翼...

2019-10-16 21:16:00 171

原创 数论模板

扩展gcd博客连接:https://blog.csdn.net/u012469987/article/details/39041797ll exgcd(ll a, ll b, ll &x, ll &y) { if(b == 0) { x = 1; y = 0; return a; } ll...

2019-10-16 21:04:53 160

原创 Super Mario HDU - 4417 主席树模板(二)

Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to...

2019-10-16 20:57:06 200

原创 Count on a tree SPOJ - COT 主席树+LCA

You are given a tree withNnodes. The tree nodes are numbered from1toN. Each node has an integer weight.We will ask you to perform the following operation:u v k: ask for the kth minimum weigh...

2019-10-09 19:12:43 231

原创 K-th Number POJ - 2104 主席树模板

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 quic...

2019-09-24 11:37:46 311

转载 欧拉函数的求法

欧拉函数公式:欧拉函数一般求法long long eular(long long n){ long long ans=n; for(int i=2;i*i<=n;++i) { if(n%i==0) { ans-=ans/i; while(n%i==0) ...

2019-08-01 18:31:49 883

原创 二维线段树

用于矩阵的快速修改和查询(修改和查询的时间复杂度都为logn,空间复杂度是(4*n)*(4*n))这里提供两种操作 单点修改+区间询查 区间修改+单点询查由于(单点修改+区间询查 )和(区间修改+单点询查)的sum数组意义不同,所以该代码无法实现(单点修改+单点询查)和(区间修改+区间询查)单点修改void changex(int kx,int l,int r){ ...

2019-07-30 16:57:31 293

原创 POJ - 1195 二维树状数组

C - Mobile phonesPOJ - 1195二维树状数组Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * ...

2019-07-30 16:57:03 196

原创 POJ - 3237 树链剖分

You are given a tree withNnodes. The tree’s nodes are numbered 1 throughNand its edges are numbered 1 throughN− 1. Each edge is associated with a weight. Then you are to execute a series of inst...

2019-07-30 16:53:10 289

原创 树链剖分模板 洛谷 P3384

题目描述如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作:操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z操作2: 格式: 2 x y 表示求树从x到y结点最短路径上所有节点的值之和操作3: 格式: 3 x z 表示将以x为根节点的子树内所有节点值都加上z操作4: 格式: 4 x 表示求以x为根节点的子树...

2019-07-26 10:31:11 200

原创 最小表示法 KMP 扩展KMP Manacher 模板

最小表示法+KMPString ProblemHDU - 3374Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings:Stri...

2019-07-23 17:04:39 229

原创 HDU - 2852 树状数组查询第k大的数

For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. Now Kiki meets a very similar problem, kiki wants to design a container, the container is to support t...

2019-06-01 09:27:28 361

原创 POJ - 3321 树状数组+dfs序

There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tree hasN...

2019-05-27 16:07:16 244

原创 树状数组

每次查询是求从查询节点开始(包括查询节点)自右向左层数尽可能低的点的权值的和,算过的点的根节点不再计算(也就是从查询节点开始,从右到左所有需要计算的点的权值和),得到的是前缀和。每次修改是修改以该点为子节点的所有节点的值。查询和修改都是以跳跃的形式进行的,时间复杂度都为logn。树状数组可以以nlogn的时间复杂度求序列的逆序对(本质:通过数组自身的有序加上循环操作时的有序,可以同...

2019-05-20 21:41:52 211

原创 HDU 1255 扫描线求面积+离散化

给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积.Input输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个矩形的左上角坐标和右下角坐标,矩形的上下边和X轴平行,左右边和Y轴平行.坐标的范...

2019-04-29 16:46:46 191

原创 HDU 1828 扫描线求周长

A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered b...

2019-04-29 10:14:31 348

原创 Assign the task dfs序+线段树

There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,that ...

2019-04-17 10:56:56 205

原创 Tunnel Warfare 线段树区间合并

H - Tunnel WarfareDuring the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels ...

2019-04-16 09:45:05 211

原创 线段树模板

In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pud...

2019-04-09 09:16:06 139

原创 H - Matrix Multiplication ZOJ - 2316

Let us consider undirected graph G =which has N vertices and M edges. Incidence matrix of this graph is N * M matrix A = {aij}, such that aijis 1 if i-th vertex is one of the ends of j-th edge and...

2019-04-08 21:40:51 182

原创 最短路问题总结

Floyd算法:可以求得每两点间的最短路,但时间复杂度较高,一般不用。例题:Cow Contest POJ3660N(1 ≤N≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better tha...

2019-04-04 16:41:48 319

原创 H - 栀子花开 FZU - 1921

H - 栀子花开FZU - 1921Time limit 1000 ms Memory limit 32768 kB这是一个栀子花开的季节,也是一个离别的季节,四年一千多个日日夜夜,那校园的角角落落,留下了我们沉思的身影;那上百次的成绩排名表,印证了我们深深浅浅不断进步的轨迹,但是这些进步都离不开老师的谆谆教诲。作为计算机系的学生,算法与数据结构是必修的主干课...

2019-04-03 11:38:53 395

原创 Drying POJ - 3104 二分

Drying POJ - 3104 二分 http://poj.org/problem?id=3104二分查找作用之一:查找结果,逆向求解。最让HSQ学长头疼的就是洗衣服了。洗完之后,每件衣服都有一定单位水分,在不使用烘干器的情况下,每件衣服每分钟自然流失1个单位水分,但如果使用了烘干机则每分钟流失K个单位水分。令人遗憾是HSQ所在的宿舍楼只有1台烘干机,而每...

2019-04-01 17:24:40 226

原创 G - NEW RDSP MODE I  NBUT - 1225

G - NEW RDSP MODE INBUT - 1225Time limit 1000 msMemory limit 131072 kBLittle A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mo...

2019-03-29 21:56:07 246

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除