自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Vmorish

—— Anything is possible

  • 博客(159)
  • 收藏
  • 关注

原创 HYSBZ - 2243 [SDOI2011]染色(树链剖分)

HYSBZ - 2243 [SDOI2011]染色(树链剖分)Description给定一棵有n个节点的无根树和m个操作,操作有2类:1、将节点a到节点b路径上所有点都染成颜色c;2、询问节点a到节点b路径上的颜色段数量(连续相同颜色被认为是同一段),如“112221”由3段组成:“11”、“222”和“1”。请你写一个程序依次完成这m个操作。Input第一行包含2个整数n和m,分别表示节点数和操作数;第二行包含n个正整数表示n个节点的初始颜色下面 行每行包含两个整数x和y,表示x和y

2017-09-03 09:11:31 273

原创 HDU - 4128 Running relay(贪心+凸包+三分)

HDU - 4128 Running relay(贪心+凸包+三分)Problem DescriptionThe school track-and-field team is taking a running relay race. There are n (2<=n<=104) members in the team. In order to let everybody participate in the race, each member should run at least d (0<=d<

2017-08-31 19:30:55 482

原创 ZOJ - 3806 Incircle and Circumcircle(计算几何+二分)

ZOJ - 3806 Incircle and Circumcircle(计算几何+二分)A triangle is one the basic shapes in geometry. It's a polygon with three vertices and three sides which are line segments. A triangle with vertices A, B, C is denoted ΔABC. And its three sides, BC, CA, AB are

2017-08-30 08:59:24 262

原创 HYSBZ - 1036 树的统计Count(树链剖分)

HYSBZ - 1036 树的统计Count(树链剖分)Description  一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v: 询问从点u到点v的路径上的节点的最大权值 III. QSUM u v: 询问从点u到点v的路径上的节点的权值和 注意:从点u到点v的路径上的节点包括u和v本身Input  输入的第一行为一个整数n,表示节点的个数。接下

2017-08-29 09:19:50 287

原创 POJ - 3237 Tree(树链剖分)

POJ - 3237 Tree(树链剖分)DescriptionYou are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edges are numbered 1 through N − 1. Each edge is associated with a weight. Then you are to execute a series of instructions on the tree.

2017-08-28 19:27:11 304

原创 FZU - 2082 过路费(树链剖分)

FZU - 2082 过路费(树链剖分) Problem Description有n座城市,由n-1条路相连通,使得任意两座城市之间可达。每条路有过路费,要交过路费才能通过。每条路的过路费经常会更新,现问你,当前情况下,从城市a到城市b最少要花多少过路费。 Input有多组样例,每组样例第一行输入两个正整数n,m(2 <= n<=50000,1<=m <= 50000),接下来n-1行,每行3个正整数a b c,(1 <= a,b <= n , a != b , 1 <= c <= 100000

2017-08-28 10:19:55 275

原创 POJ - 2763 Housewife Wind(树链剖分)

POJ - 2763 Housewife Wind(树链剖分)DescriptionAfter their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirectional roads.

2017-08-24 10:09:37 218

原创 HDU - 3966 Aragorn's Story(树链剖分)

HDU - 3966 Aragorn's Story(树链剖分)Problem DescriptionOur protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps out o

2017-08-23 15:35:16 234

原创 HDU - 6162 Ch’s gift(树链剖分)

HDU - 6162 Ch’s gift(树链剖分)Problem DescriptionMr. Cui is working off-campus and he misses his girl friend very much. After a whole night tossing and turning, he decides to get to his girl friend's city and of course, with well-chosen gifts. He knows neith

2017-08-23 10:03:35 326

原创 SPOJ - QTREE Query on a tree(树链剖分)

SPOJ - QTREE Query on a treeYou are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.We will ask you to perfrom some instructions of the following form:CHANGE i ti : change the cost of the i-th edge t

2017-08-20 20:37:54 237

原创 HDU - 6152 Friend-Graph(= =)

HDU - 6152 Friend-GraphProblem DescriptionIt is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team.In a team with n members,if there are three or more members are no

2017-08-19 19:47:44 303

原创 HDU - 6133 Army Formations(启发式合并+树状数组)

HDU - 6133 Army Formations(启发式合并+树状数组)多校2017第八场Problem Description> Stormtroopers were the assault/policing troops of the Galactic Empire. Dissenting citizens referred to them as bucketheads, a derogatory nickname inspired by the bucket-shaped helmets o

2017-08-18 16:38:36 549

原创 POJ - 1296 Intersecting Lines(计算几何)

点我看题题意:给出两条直线,判断这两条直线的关系,即问是否相交,如果相交求出交点,如果不相交,那么他们是相离还是重合?分析:首先去判断直线P1P2和Q1Q2和是否平行,判断直线平行可以利用叉乘。如果(P2-P1)×(Q2-Q1)== 0的话,那么两直线平行;得到直线平行,就要看是否重合了。判断重合就相当于判断一条直线上的点是否存在于另一条直线上,假设这里我们看P1是否在Q1Q2

2017-08-16 17:04:44 289

原创 POJ - 3304 Segments(计算几何)

POJ - 3304 Segments(计算几何)DescriptionGiven n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one point in common.Input

2017-08-16 15:33:53 254

原创 POJ - 2398 Toy Storage(计算几何)

POJ - 2398 Toy Storage(计算几何)DescriptionMom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his pa

2017-08-15 18:52:34 235

原创 POJ - 2318 TOYS(计算几何)

POJ - 2318 TOYS(计算几何)DescriptionCalculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box

2017-08-15 08:50:00 218

原创 POJ - 2442 Sequence(优先队列/堆)

POJ - 2442 Sequence(优先队列/堆)DescriptionGiven m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers. It's clear that we may get n ^ m this kind of sequences. Then we can calcu

2017-08-13 21:01:29 336

原创 (2017多校6)1002/hdu-6097 Mindis(计算几何)

(2017多校6)1002/hdu-6097 Mindis(计算几何)Problem DescriptionThe center coordinate of the circle C is O, the coordinate of O is (0,0) , and the radius is r.P and Q are two points not outside the circle, and PO = QO.You need to find a point D on the circle, wh

2017-08-11 16:05:56 563

原创 POJ - 2155 Matrix(二维线段树)

POJ - 2155 Matrix(二维线段树)DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given

2017-08-09 19:38:14 406

原创 HDU - 4267 A Simple Problem with Integers(线段树)

HDU - 4267 A Simple Problem with Integers(线段树)Problem DescriptionLet 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

2017-08-09 15:47:07 334

原创 HDU - 1542 Atlantis(线段树扫描线求矩形并的面积)

HDU - 1542 Atlantis(线段树扫描线求矩形并的面积)线段树求矩形面积详解Problem DescriptionThere 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 des

2017-08-09 11:46:00 622

原创 ZOJ - 3574 Under Attack II(计算几何 归并排序)

ZOJ - 3574 Under Attack II(计算几何 归并排序)Because of the sucessfully calculation in Under Attack I, Doctor is awarded with Courage Cross and promoted to lieutenant. But the war seems to end in never, now Doctor has a new order to help anti-aircraft troops calc

2017-08-07 09:25:32 267

原创 HDU - 4911 Inversion(归并排序求逆序数)

HDU - 4911 Inversion(归并排序求逆序数)Problem Descriptionbobo has a sequence a1,a2,…,an. He is allowed to swap two adjacent numbers for no more than k times.Find the minimum number of inversions after his swaps.Note: The number of inversions is the number o

2017-08-06 23:35:16 357

原创 POJ - 1804 Brainman(归并排序求逆序数)

POJ - 1804 Brainman(归并排序求逆序数)DescriptionBackground Raymond Babbitt drives his brother Charlie mad. Recently Raymond counted 246 toothpicks spilled all over the floor in an instant just by glancing at them. And he can even count Poker cards. Charlie wou

2017-08-06 20:39:39 311

原创 HDU - 1671 Phone List(字典树)

HDU - 1671 Phone List(字典树)Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:1. Emergency 9112. Alice 97 625 9993. B

2017-08-06 09:56:21 270

原创 HDU - 1298 T9(字典树+dfs)

HDU - 1298 T9(字典树+dfs)Problem DescriptionA while ago it was quite cumbersome to create a message for the Short Message Service (SMS) on a mobile phone. This was because you only have nine keys and the alphabet has more than nine letters, so most characte

2017-08-06 08:23:09 281

原创 ACdream - 1063 平衡树(01字典树)

ACdream - 1063 平衡树(01字典树)Problem Description神奇的cxlove有一颗平衡树,其树之神奇无法用语言来描述 OrzOrz。 这棵树支持3种操作: 1、加入一个数到树中,维护平衡树的合法性; 2、给一个数X,用O(1)的时间求出来树中的数Y使得 Y ^ X 最大(异或操作, Pascal 写作 xor , 0 ^ 0 = 0 , 1 ^ 1 = 0 , 0 ^ 1 = 1 , 1 ^ 0 = 1 , 2 ^ 3 = 1) 3、给一个数X,用O(1)的时间求出来树中

2017-08-04 15:19:38 270

原创 (2017多校4)1004/hdu-6070 Dirt Ratio(二分 + 线段树)

(2017多校4)1004/hdu-6070 Dirt Ratio(二分 + 线段树)Problem DescriptionIn ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the following way. First let's ignore all the problems the team didn't pass, assume the team passed X problems during the con

2017-08-04 10:44:59 262

原创 CSU - 1115 最短的名字(字典树)

CSU - 1115 最短的名字(字典树)Description在一个奇怪的村子中,很多人的名字都很长,比如aaaaa, bbb and abababab。名字这么长,叫全名显然起来很不方便。所以村民之间一般只叫名字的前缀。比如叫'aaaaa'的时候可以只叫'aaa',因为没有第二个人名字的前三个字母是'aaa'。不过你不能叫'a',因为有两个人的名字都以'a'开头。村里的人都很聪明,他们总是用最短的称呼叫人。输入保证村里不会有一个人的名字是另外一个人名字的前缀(作为推论,任意两个人的名字都不会相同)

2017-08-03 10:23:06 357

原创 HDU - 1075 What Are You Talking About(字典树)

HDU - 1075 What Are You Talking About(字典树)Problem DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatiu

2017-08-02 17:05:13 303

原创 HDU - 1251 统计难题(字典树)

HDU - 1251 统计难题(字典树)Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:本题只有一组测试数据,处理

2017-08-01 21:15:57 297

原创 POJ - 2777 Count Color(线段树 成段更新 区间查询)

POJ 2777 Count Color(线段树 成段更新 区间查询)DescriptionChosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. There is a very long board with length L centimeter, L is a pos

2017-08-01 08:49:32 302

原创 POJ - 3667 Hotel(线段树 区间合并 区间查询)

POJ 3667 Hotel(线段树 区间合并 区间查询)The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bullmoose Hotel on famed Cumb

2017-07-31 21:06:17 264

原创 HDU - 1394 Minimum Inversion Number(线段树 单点更新 区间查询)

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 first m >= 0

2017-07-31 17:08:19 196

原创 HDU - 2795 Billboard(线段树 单点更新 最值问题)

HDU - 2795 Billboard(线段树 单点更新 最值问题)Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest

2017-07-31 16:53:33 306

原创 POJ - 3017 Cut the Sequence(单调队列+dp)

点我看题题意:给一个长度为n的序列a,一个数m,序列a可以被拆分为几段连续的子序列,每段子序列的和不得大于m,求这些子序列最大值的最小和.分析:dp辣鸡对于这种简单dp也还是很无奈啊,还是强着自己去看了.设dp[i]为前i个数分成子序列后的最大值的最小和,dp[i]=max(dp[i],dp[j]+a[q[j]]),其中q为单调递减队列,再YY一下就好.参考代码:#includ

2017-07-30 19:32:18 268

原创 HDU - 1873 看病要排队 (优先队列)

点我看题题意:看病排队,首先根据病情的轻重缓急来医治,严重的先治,病情相同的情况下,先来的先治,根据输入输出病人的id.分析:就是一个优先队列进队出队的问题,关键在于优先队列的重载小于号.参考代码:#include#include#include#include#include#includeusing namespace std;int n;struct Nod

2017-07-30 09:04:19 357

原创 (2017多校2)1011/hdu-6055 Regular polygon(计算几何)

点我看题题意:给你n个整数点(这个条件超级重要),rang 求能组成多少个正多边形.分析:由整数点组成的正多边形只能是正方形,可以画个图看看,发现怎么也找不到除了正四边形以外的其他形状.然后对于每一条边,分别找出它左右两边能与他形成正方形的另外两个点,然后看看这两个点是否存在.最后的答案要除以一个4,因为对于每一个正方形来说,你都通过四个边找了它四次.参考代码:#include#

2017-07-28 08:40:22 372

原创 (2017多校2)1003/hdu-6047 Maximum Sequence(单调队列/优先队列)

点我看题题意:分别给出两个序列a和b,根据规则ai≤max{aj-j│bk≤j官方题解:预处理:a_i -= i ,易证明从最小的b开始选每次选最大的一定可以使结果最大。 证明思路:如果条件改为a_i<=max{a_j-j|b_k<=j<=n},那么b的顺序与最后的结果无关。条件改回来后,由于每次要计算一个数的最大值时都有a_(n+1)...a_(i-1)在范围中,所以每次只需让a_i

2017-07-27 20:02:28 620

原创 Balala Power(贪心)

hduoj好像挂了,就不给链接了哇...题意:给n个字符串,然后每个字母可以转化为其他的25个小写字母,字母a-z依次表示0-25,其中不同的两字母不能转化为相同的字母,让求转化后的字符串的总和最大.分析:根据每个字母对应所在位置的权值贪心...(看了标程才完全理清思路)参考代码:#include#include#include#include#includeusing

2017-07-26 10:48:05 428

空空如也

空空如也

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

TA关注的人

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