
HDOJ
文章平均质量分 74
深海沧澜夜未央
这个作者很懒,什么都没留下…
展开
-
HDU 6386 Age of Moyu BFS+优先队列
Problem DescriptionMr.Quin love fishes so much and Mr.Quin’s city has a nautical system,consisiting of N ports and M shipping lines. The ports are numbered 1 to N. Each line is occupied by a Weitian....原创 2018-08-13 18:52:51 · 380 阅读 · 0 评论 -
HDU - 1541 Stars 树状数组 单点更新(求比当前数字大的数字有多少个)
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and ...原创 2018-02-25 11:59:58 · 295 阅读 · 0 评论 -
HDU 1394 Minimum Inversion Number 树状数组 单点更新
The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, ..., an, if we move the fi...原创 2018-02-25 10:48:45 · 233 阅读 · 0 评论 -
HDU 1272 小希的迷宫 并查集 (判断任意2个点是否有且仅有一条路径可以相通)
Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希...原创 2018-02-18 11:42:32 · 394 阅读 · 0 评论 -
HDU 1233 还是畅通工程 并查集 (单向点连通)
Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)/2行...原创 2018-02-18 11:37:43 · 335 阅读 · 0 评论 -
HDU 1232 畅通工程 并查集模板题目
Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M;...原创 2018-02-18 11:33:45 · 227 阅读 · 0 评论 -
HDU 1698 Just a Hook 线段树区间更新(值进行覆盖)
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 Pudge w...原创 2018-02-08 09:36:57 · 215 阅读 · 0 评论 -
HDU 3038 How Many Answers Are Wrong 并查集 (判断区间值是否正确)
TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should ...原创 2018-02-14 11:17:18 · 336 阅读 · 0 评论 -
HDU 1213 How Many Tables 并查集 (统计树的个数)
Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, a...原创 2018-02-13 12:52:49 · 243 阅读 · 0 评论 -
HDU 1754 B I Hate It 线段树 单点更新 区间最大值 模板
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0学生ID编号分别从1编到N。 第二原创 2018-02-07 10:21:04 · 196 阅读 · 0 评论 -
HDU 1166 敌兵布阵 (线段树单点更新 区间查询)
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所...原创 2018-02-06 15:53:31 · 240 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第五场) G 送分啦-QAQ HDU 2516 斐波拉底博弈
题目描述 幼儿园开学了,为了让小盆友们能尽可能的多的享受假期。校长大人决定让小盆友分批到校,至于每批学生来多少人由一个小傻子和一个小仙女负责,两个人轮番负责,校长会在最后的时候去查看工作进度,小傻子不想被别人嘲笑自己傻,小仙女要证明自己比小傻子聪明。所以她们回去争抢安排最后一名小盆友。每次安排的小盆友至少为1,至多为上一次安排的2倍。小仙女抢到了先手的机会。第一次安排小盆友不能直接安排所有...原创 2018-02-26 09:28:57 · 318 阅读 · 0 评论 -
HDU 4027 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 battleships can be marked a value of end...原创 2018-02-09 11:18:54 · 217 阅读 · 0 评论 -
福州大学第十五届程序设计竞赛 E - 谁还不是个宝宝 FZU 2288 HDU 5701 中位数计数 暴力思维
洪尼玛有n个朋友,n个朋友排成一排,每个朋友都有一个自身的价值Ai,并且每个朋友自身的价值均不相同。现在每个朋友都能与他左右的若干个人组成一个区间,也可以他自己一个人组成一个区间。若这个区间的人数为奇数个,那么我们称其为“可行区间”。将一个 “可行区间”里所有朋友按价值排序后,中间的那个朋友就是这个“可行区间”里的“宝宝”。求每个朋友是多少个“可行区间”里的“宝宝”?Input多组测试数据。输入第...原创 2018-06-04 21:01:48 · 395 阅读 · 0 评论 -
HDU 1241 Oil Deposits DFS 水题 基础练习
Find a wayTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4360 Accepted Submission(s): 1466Problem DescriptionPass a year learning in Hangzho...原创 2018-06-30 10:42:22 · 332 阅读 · 0 评论 -
HDU - 1495 非常可乐 (互倒可乐 BFS+数论)
大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S>...原创 2018-06-30 11:02:44 · 532 阅读 · 0 评论 -
HDU 6324 Grab The Tree 异或
Problem DescriptionLittle Q and Little T are playing a game on a tree. There are n vertices on the tree, labeled by 1,2,...,n, connected by n−1 bidirectional edges. The i-th vertex has the value of w...原创 2018-08-01 21:00:11 · 303 阅读 · 0 评论 -
HDU 6343 Graph Theory Homework
Problem DescriptionThere is a complete graph containing n vertices, the weight of the i-th vertex is wi.The length of edge between vertex i and j (i≠j) is ⌊|wi−wj|−−−−−−−√⌋.Calculate the length of ...原创 2018-08-01 20:31:02 · 514 阅读 · 0 评论 -
HDU 6335 Nothing is Impossible 贪心
Problem Descriptionm students, including Kazari, will take an exam tomorrow.The paper consists of exactly n problems, the i-th problem contains ai correct answers and bi incorrect answers, i.e. the ...原创 2018-08-01 20:24:36 · 474 阅读 · 0 评论 -
HDU 6342 Expression in Memories 表达式填充
Kazari remembered that she had an expression s0 before.Definition of expression is given below in Backus–Naur form.<expression> ::= <number> | <expression> <operator> <num...原创 2018-08-01 20:19:18 · 246 阅读 · 0 评论 -
POJ 2054 /HDU 1055 Color a Tree(贪心+并查集)
Bob is very interested in the data structure of a tree. A tree is a directed graph in which a special node is singled out, called the "root" of the tree, and there is a unique path from the root to ea...原创 2018-07-27 15:46:36 · 318 阅读 · 1 评论 -
HDU 6299 Balanced Sequence 括号匹配 贪心
Problem DescriptionChiaki has n strings s1,s2,…,sn consisting of '(' and ')'. A string of this type is said to be balanced:+ if it is the empty string+ if A and B are balanced, AB is balanced,+ i...原创 2018-07-26 19:20:13 · 293 阅读 · 0 评论 -
HDU 1542 POJ 1151 Atlantis 线段树+离散化+扫描线 重叠矩阵面积和
There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe diff...原创 2018-07-20 17:13:16 · 309 阅读 · 0 评论 -
POJ1195:Mobile phones 二维树状数组 矩阵上点的区间和(查询更新均为二维)
DescriptionSuppose 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 * S matrix with the rows and ...原创 2018-07-19 12:24:10 · 277 阅读 · 0 评论 -
HDU - 1394 Minimum Inversion Number 求逆序数对 树状数组 (水题的理解)
The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence of numbers a1, a2, ..., an, if we move the ...原创 2018-07-17 17:17:49 · 235 阅读 · 0 评论 -
HDU - 4267 A Simple Problem with Integers 三维树状数组
Let A1, A2, ... , AN be N elements. You need to deal with two kinds of operations. One type of operation is to add a given number to a few numbers in a given interval. The other is to query the value ...原创 2018-07-17 16:48:46 · 178 阅读 · 0 评论 -
POJ 2481 Cows 树状数组 单点更新 (每个集合是几个集合的真子集)
DescriptionFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer ...原创 2018-07-17 16:44:06 · 233 阅读 · 0 评论 -
poj 2352 Stars 树状数组 单点更新
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher a...原创 2018-07-16 23:48:38 · 204 阅读 · 0 评论 -
HDU 1556 Color the ball 树状数组 区间更新
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a ...原创 2018-07-16 23:25:01 · 166 阅读 · 0 评论 -
HDU 2844 Coins 多重背包 (重量和价值相同)
Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a原创 2018-02-02 12:11:28 · 425 阅读 · 0 评论 -
HDU - 3466 Proud Merchants (01背包的变形 + 贪心)
Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud even if their n原创 2018-01-24 16:35:39 · 298 阅读 · 0 评论 -
HDU 1248 寒冰王座 (完全背包 水题)
Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说完他掏出那张N元的大钞递给地精商原创 2018-01-30 20:24:48 · 321 阅读 · 0 评论 -
HDU 4282 A very hard mathematic problem (涉及3个数字 用 枚举+二分)
Problem Description Haoren is very good at solving mathematic problems. Today he is working a problem like this: Find three positive integers X, Y and Z (X 1) that holds X^Z + Y^Z +原创 2017-01-31 11:24:10 · 478 阅读 · 0 评论 -
HDU 2199 Can you solve this equation(二分水题)
Problem DescriptionNow,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;Now please try your lucky. InputThe first line of the inp原创 2017-01-18 10:55:11 · 374 阅读 · 0 评论 -
HDU 4734 数位DP 小水
题目给了个f(x)的定义:F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1,Ai是十进制数位,然后给出a,b求区间[0,b]内满足f(i)常规想:这个f(x)计算就和数位计算是一样的,就是加了权值,所以dp[pos][sum],这状态是基本的。a是题目给定的,f(a)是变化的不过f(a)最大好像是4600的样子。如果要转载 2017-10-16 10:52:40 · 384 阅读 · 2 评论 -
HDU 3709 Balanced Number(数位DP)
题意:给定区间[a,b],求区间内平衡数的个数。所谓平衡数即有一位做平衡点,左右两边数字的力矩想等。思路:遍历每一位做为平衡点,进行搜索,sum保存数字乘以距离的和,若sum为0,则说明平衡。 要注意因为遍历了len次,所以0多加了len-1次。 还有个小技巧是当sum#include #include #include using namespace std;typede转载 2017-10-14 19:29:59 · 204 阅读 · 0 评论 -
HDU 1561 The more, The Better - 依赖背包+树形dp基础
题意: 给一个树形结构,问最多拿max个城市 ,能获得的最大价值多少,拿下面的一定要先拿上面的。解题思路:定义状态dp[i][j] : 当前i节点及其子树下最多选择j个城市的最大值为dp[i][j];我们考虑到特殊状态:i节点下没有孩子那么dp[i][2,3,4,5...]均为-1(因为多选总比少选好,并且选择完后城市总是有剩余)1. 判断当前节点P有没有孩子,如果有则令当转载 2017-10-22 17:14:36 · 223 阅读 · 0 评论 -
HDU 4407 Sum (容斥原理)
Problem DescriptionXXX is puzzled with the question below: 1, 2, 3, ..., n (1Operation 1: among the x-th number to the y-th number (inclusive), get the sum of the numbers which are co-prime with原创 2017-08-04 10:03:30 · 412 阅读 · 0 评论 -
HDU 2147 kiki's game (巴什博弈)
Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top ri原创 2017-08-06 17:25:55 · 232 阅读 · 0 评论 -
HDU 1517 A Multiplication Game (组合博弈 ceil函数向下取整数 模板)
Stan and Ollie play the game of multiplication by multiplying an integer p by one of the numbers 2 to 9. Stan always starts with p = 1, does his multiplication, then Ollie multiplies the number, then原创 2017-08-06 17:43:11 · 385 阅读 · 0 评论