![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
mumei314
这个作者很懒,什么都没留下…
展开
-
2019年12月河南农业大学邀请赛F题——幂求和
题意给你一个数列a1,a2,a3......an,数列所有值的初始值为0,有三种操作:操作1:将区间[l,r]中所有数加c操作2:将区间[l,r]中所有数变成c操作3:查询区间[l,r]中,的值最终答案对1e4+7取余就行了。题解:这个题有两个做法,一种是明显的用线段树维护就行,另一种就是用珂朵莉树,可以说是板子题了。其实正确做法是用线段树维护,珂朵莉树的做法可以...原创 2019-12-29 00:10:42 · 300 阅读 · 0 评论 -
Treasure Exploration ——最小路径覆盖(floyd求传递闭包)
题目链接:http://poj.org/problem?id=2594Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have s...原创 2019-07-22 08:47:37 · 153 阅读 · 0 评论 -
Antenna Placement——二分图匹配(最小边覆盖)
题目链接:http://poj.org/problem?id=3020The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they ...翻译 2019-07-21 20:39:50 · 293 阅读 · 0 评论 -
Oil Skimming ——二分图最大匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4185Thanks to a certain "green" resources company, there is a new profitable industry of oil skimming. There are large slicks of crude oil floating in ...原创 2019-07-21 18:43:51 · 312 阅读 · 1 评论 -
Rain on your Parade——二分图匹配Hopcroft-Karp算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2389You’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 evening, and a ...原创 2019-07-21 16:35:06 · 259 阅读 · 0 评论 -
Swap——二分图最大匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2819Given an N*N matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diagonal entr...原创 2019-07-21 15:09:02 · 174 阅读 · 0 评论 -
棋盘游戏——二分图最大匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1281小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。所以现在Gardon想让小希来解决...原创 2019-07-21 13:27:11 · 240 阅读 · 0 评论 -
Courses ——二分图最大匹配模板题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1083Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possi...原创 2019-07-21 13:10:14 · 161 阅读 · 0 评论 -
The Accomodation of Students——二分图最大匹配+染色判断二分图
原文链接:http://acm.hdu.edu.cn/showproblem.php?pid=2444There 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....原创 2019-07-21 06:29:52 · 170 阅读 · 0 评论 -
Fire Net ——二分图匹配(按照行和列来建图)
原文链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045Suppose 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 o...原创 2019-07-21 06:19:50 · 202 阅读 · 0 评论 -
最短路算法(floyd,基于邻接矩阵的Dijkstra,bellman_ford,spfa,基于优先队列的Dijkstra(时间优化))
Dijkstra算法首先介绍单源最短路问题,单源最单路最经典的算法就是Dijkstra算法。而该算法有两种实现,一种是用邻接矩阵实现,另一种是基于优先队列和邻接表的实现。先理解Dijkstra算法的思想,其实就是贪心思想,每次取未访问的节点中权值最小的点,然后遍历能到的其他未访问的点,进行松弛。该算法主要适用于单源正权图。下面给出Dijkstra基于邻接矩阵的伪代码清除所有点的标...原创 2019-06-04 13:51:23 · 349 阅读 · 0 评论 -
H - Cow Contest (最短路floyd算法)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is un...原创 2019-06-04 13:50:11 · 245 阅读 · 0 评论 -
G - MPI Maelstrom (最短路floyd算法)
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advi...原创 2019-06-04 13:48:07 · 192 阅读 · 0 评论 -
Strategic Game——二分图最大匹配(最小顶点覆盖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now h...原创 2019-07-21 20:59:53 · 262 阅读 · 0 评论 -
Air Raid——最小路径覆盖
题目链接:https://cn.vjudge.net/problem/HDU-1151Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersecti...原创 2019-07-21 21:11:58 · 288 阅读 · 0 评论 -
hdu1272——(经典)判断无向图是不是一棵树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,...原创 2019-08-18 22:03:54 · 1545 阅读 · 0 评论 -
poj1308——(经典)判断有向图是不是一棵树
题目链接:http://poj.org/problem?id=1308A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfy...原创 2019-08-18 21:52:14 · 3458 阅读 · 1 评论 -
A - Jungle Roads (最小生成树Prim算法和Kruskal算法)
The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly,...原创 2019-06-03 19:49:32 · 373 阅读 · 0 评论 -
Boke and Tsukkomi——一般图匹配+带花树算法
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4687A new season of Touhou M-1 Grand Prix is approaching. Girls in Gensokyo cannot wait for participating it. Before the registration, they have to deci...原创 2019-07-22 09:41:41 · 235 阅读 · 0 评论 -
Work Scheduling——一般图匹配+带花树算法
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1099There is a certain amount of night guards that are available to protect the local junkyard from possible junk robberies. These guards need t...原创 2019-07-22 09:40:39 · 279 阅读 · 0 评论 -
Tour ——二分图最大权完美匹配KM算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3488In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 30000) one-way roads connecting them. You are lucky enough to h...原创 2019-07-22 08:52:21 · 216 阅读 · 0 评论 -
奔小康赚大钱 ——二分图最优匹配(KM算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2255传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。另一方面,村长和另外...原创 2019-07-22 08:51:41 · 135 阅读 · 0 评论 -
Steady Cow Assignment ——二分图多重最大匹配+折半枚举
题目链接:http://poj.org/problem?id=3189Farmer John's N (1 <= N <= 1000) cows each reside in one of B (1 <= B <= 20) barns which, of course, have limited capacity. Some cows really like their...原创 2019-07-22 08:51:02 · 145 阅读 · 0 评论 -
Optimal Milking——二分图多重最大匹配+二分+floyd求最短路
题目链接:http://poj.org/problem?id=2112FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths runs a...原创 2019-07-22 08:50:04 · 124 阅读 · 0 评论 -
Jamie's Contact Groups ——(一对多)二分图多重最大匹配
题目链接:http://poj.org/problem?id=2289Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long th...原创 2019-07-22 08:49:06 · 1601 阅读 · 0 评论 -
Cat VS Dog——最大独立集
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3829The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the child's like...原创 2019-07-22 08:48:35 · 438 阅读 · 0 评论 -
最小生成树算法——Prim算法和Kruskal算法
Prim算法理解,可以看这篇文章https://blog.csdn.net/yeruby/article/details/38615045其实就是每次从当前树中外选取一个离树最近且不构成环的点,同时sum记录权值,然后把这个点加入树中,直到所有节点都被访问过,最小生成树生成成功,输出最小生成树的权值和。下面是Prim算法的板子,和最短路有点相似,也称为“加点法”。//最小生成树Pri...原创 2019-06-03 20:56:41 · 304 阅读 · 0 评论 -
H - Highways (最小生成树Kruskal算法和Prim算法)
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a numb...原创 2019-06-03 20:24:41 · 455 阅读 · 0 评论 -
G - Arctic Network (最小生成树Prim算法和Kruskal算法)
The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every o...原创 2019-06-03 20:19:25 · 215 阅读 · 0 评论 -
B - I Hate It
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000...原创 2019-04-29 17:49:51 · 153 阅读 · 0 评论 -
A - 敌兵布阵 (线段树基础)
#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<cstdio>#include<cstdlib>#include<vector>#include<map>#include<...原创 2019-04-29 17:34:27 · 348 阅读 · 0 评论 -
A - Til the Cows Come Home(spfa,Dijkstra,bellman_ford,DIjkastra优先队列的优化)
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b...原创 2019-05-04 18:04:14 · 201 阅读 · 0 评论 -
07-图4 哈利·波特的考试 (25 分)
哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠、老鼠变鱼的魔咒连起来念:hahahehe。现在哈利·波特的手里有一本教材,里面列出了所...原创 2019-05-03 23:38:36 · 81 阅读 · 0 评论 -
Count the Colors (线段树染色)
Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones.Your task is counting the segments of different colors you can see at last....原创 2019-04-24 00:06:43 · 448 阅读 · 1 评论 -
H - Can you answer these queries?
Can you answer these queries?A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battles...原创 2019-05-01 23:13:11 · 142 阅读 · 0 评论 -
D - Mayor's posters (离散化)
DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council...原创 2019-05-01 21:34:57 · 353 阅读 · 0 评论 -
05-树8 File Transfer (25 分)
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer ...原创 2019-04-17 23:23:21 · 743 阅读 · 0 评论 -
04-树6 Complete Binary Search Tree (30 分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. ...原创 2019-04-17 14:04:24 · 953 阅读 · 0 评论 -
03-树2 List Leaves (25 分)
Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one test case. For each case, the first line gives a ...原创 2019-04-16 18:35:44 · 189 阅读 · 0 评论 -
03-树2. List Leaves (25)
03-树3 Tree Traversals Again (25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered...原创 2019-04-16 18:32:34 · 90 阅读 · 0 评论