自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Frade's Blog

我年轻,所以不惧世界的残酷。

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

原创 Redundant Paths(POJ3177)

Redundant PathsTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 15390 Accepted: 6476DescriptionIn order to get from one of the F (1 <= F <= 5,000) grazing fields (which are numbe

2017-07-12 09:40:00 367

原创 Tree Cutting(树的重心)

Tree CuttingAfter Farmer John realized that Bessie had installed a "tree-shaped" network among his N (1 <= N <= 10,000) barns at an incredible cost, he sued Bessie to mitigate his losses.Bessie, feelin

2017-06-13 20:12:19 721

原创 Choosing Capital for Treeland (树型DP)

Choosing Capital for TreelandThe country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the country. We know that if we don'

2017-06-13 16:14:28 586

原创 Godfather

GodfatherLast years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and decided to arrest the mafia leaders.Unfortunately, the str

2017-06-12 10:48:49 338

原创 Balancing Act

Balancing ActConsider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more trees. Define the balance of a node to be the

2017-06-12 08:50:10 949

原创 Park Visit(树型DP)

Park Visit Claire and her little friend, ykwd, are travelling in Shevchenko's Park! The park is beautiful - but large, indeed. N feature spots in the park are connected by exactly (N-1) undirected path

2017-06-12 08:07:03 540

原创 Cube Stacking

Cube StackingFarmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to pe

2017-05-16 11:43:25 342

原创 Babelfish

Babelfish题目描述:You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

2017-05-16 11:29:44 384

原创 Crazy Search

Crazy Search题目描述:Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number o

2017-05-15 21:15:52 408

原创 Web Navigation

Web Navigation题目描述:Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pa

2017-05-15 21:06:28 318

原创 Rails

Rails题目描述:There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was poss

2017-05-15 20:55:24 278

原创 Tanning Salon

Tanning Salon题目描述:Tan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will turn around and leave,

2017-05-15 20:47:55 365

原创 士兵队列训练问题

士兵队列训练问题题目描述: 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。Input本题有多个测试数据组,第一行为组数N,接着为

2017-05-15 20:44:42 997

原创 Cow Exhibition

Cow Exhibition题目描述:给你n只奶牛,每只奶牛有两个属性值,分别是聪明值S和有趣值F,并且这些值存在负数,我们需要选取k只牛使得他们的聪明值和兴趣值的和最大,并且要保证TS = S_1 + S_2 + S_3 + …… + S_n(也就是聪明值的和) >= 0, TF = F_1 + F_2 + F_3 + ……+ F_n(也就是有趣值的和) >= 0。这个时候再使得TS+TF最大。输

2017-05-07 09:36:56 541

原创 01背包(Bone Collector)

重新回顾一下背包问题,特来贴一篇博客。01背包问题01背包是背包问题的基础,基本上其他背包问题都是由他扩展而来,可以看出他的重要性。题目:有N件物品和一个容量为V的背包。放入第i件物品所消耗的空间是C,得到的价值是W_i,求解将那些物品装入背包可以使价值最大。分析:对于每一种物品我们只有选与不选两种状态,根据动态规划的一般解题思路,我们首先要确定阶段,状态,决策。阶段:前i件物品为一个阶段 状态:

2017-05-04 16:00:31 265

原创 非常可乐 bfs

非常可乐 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (正好装满一瓶) ,它们三个之间可以相互倒可乐 (都是没有刻度的,且 S==N+M,101>S

2017-04-18 16:20:07 1912

原创 胜利大逃亡(续)

胜利大逃亡(续) Ignatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)……这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx,sy)的位置,离开地牢的门在(ex,ey)的位置。Ignatius每分钟只能从一个坐标走到相邻四个坐标中的其中一个。魔王每t分钟回地牢视察一次,若发现Ig

2017-04-18 11:12:00 755

原创 N皇后问题

N皇后问题在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1

2017-04-16 15:53:45 604

原创 HDU 4474:Yet Another Multiple Problem

Yet Another Multiple Problem题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4474 Yet Another Multiple ProblemTime Limit: 40000/20000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total

2017-04-13 09:46:52 426

转载 C\C++代码规范

C\C++代码规范我也是在noip吧里发现的,举得写得真心不错,所以贴上来了。感谢elf465504453。发现N多人代码都不怎么规范,有的是旧标准的风格(MS被谭浩强带的),有的是Dev-C++的坏习惯。这些非常容易导致CE或RE,特发此帖。1.main函数类型与返回值,严重!!main函数一定要定义成int,不能用void,更不能用long(还没见过)。最后程序结束

2017-04-11 15:42:57 788

原创 Charm Bracelet

Charm BraceletBessie has gone to the mall’s jewelry store and spies a charm bracelet. Of course, she’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each ch

2017-04-10 15:10:42 327

原创 Knapsack Problem(完全背包)

Knapsack ProblemYou have N kinds of items that you want to put them into a knapsack. Item i has value vi and weight wi.You want to find a subset of items to put such that:The total value of the items i

2017-04-10 11:01:25 867

原创 0-1 Knapsack Problem

0-1 Knapsack ProblemYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.You want to find a subset of items to put such that:The total value of the items is as

2017-04-10 09:59:14 1868

原创 E - The Triangle

E - The Triangle7 3 8 8 1 0 2 7 4 4 4 5 2 6 5Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the to

2017-04-09 12:06:49 309

原创 Edit Distance (Levenshtein Distance)

Edit Distance (Levenshtein Distance)Find the edit distance between given two words s1 and s2.The disntace is the minimum number of single-character edits required to change one word into the other. The

2017-04-09 11:55:01 356

原创 Longest Increasing Subsequence

Longest Increasing SubsequenceFor a given sequence A = {a0, a1, … , an-1}, find the length of the longest increasing subsequnece (LIS) in A.An increasing subsequence of A is defined by a subsequence {a

2017-04-07 16:23:48 304

原创 Longest Common Subsequence

Longest Common Subsequence最長共通部分列最長共通部分列問題 (Longest Common Subsequence problem: LCS)は、2つの与えられた列 X={x1,x2,...,xm}X = \{x_1, x_2, ..., x_m\} と Y={y1,y2,...,yn}Y = \{y_1, y_2, ..., y_n\} の最長共通部分列を求める問題です。

2017-04-07 15:35:52 339

原创 Max Sum(DP)

Given a sequence a11,a22,a33......ann, your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +

2017-04-06 10:07:47 352

原创 Advanced Fruits

Advanced Fruits The company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method

2017-04-06 09:57:24 909

原创 二分搜索

Binary SearchYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.Inp

2016-12-09 18:50:57 422

原创 线性搜索

Linear SearchYou are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S.Inp

2016-12-09 18:02:53 501

原创 Areas on the Cross-Section Diagram

Areas on the Cross-Section Diagram  Aizu - ALDS1_3_D Areas on the Cross-Section Diagram地域の治水対策として、洪水の被害状況をシミュレーションで仮想してみよう。 図のように $1 \times 1 (m^2)$ の区画からなる格子上に表された地域の模式断面図が与えられるので、地域にできる各

2016-12-09 10:04:48 967

原创 链表(裸题)

Doubly Linked List  Aizu - ALDS1_3_C Your task is to implement a double linked list. Write a program which performs the following operations: insert x: insert an element with key x into

2016-12-09 09:46:20 304

原创 队列(裸题)

Queue   Aizu - ALDS1_3_B For example, we have the following queue with the quantum of 100ms. A(150) - B(80) - C(200) - D(200)First, process A is handled for 100ms, then the process is moved

2016-12-09 09:40:03 251

原创 栈(裸题)

Stack    Aizu - ALDS1_3_AWrite a program which reads an expression in the Reverse Polish notation and prints the computational result.An expression in the Reverse Polish notation is calc

2016-12-09 09:32:09 479

原创 排序算法的稳定

其实排序算法的稳定很简单,就只是当每一个元素都有一个id的时候那么我们该怎么去处理大小相同的元素如果经过排序后元素大小相同的两个元素的原顺序发生了改变则称它为不稳定排序,反之则称为稳定排序。冒泡排序:稳定排序选择排序:不稳定排序下面是一个代码作为参考(随手写的,没优化过代码,别介意):#include #include using namespace std;const

2016-12-05 12:36:25 293

原创 排序(选择)

插入和冒泡的排序都写完了,现在再来搞一下选择排序喽。选则排序其实很简单,同样分成已排序部分和未排序部分。就只是不断的从未排序部分里将最小值或最大值选出,让他与未排序部分的第一个元素交换位置,重复操作。举个例子:A = {5,4,8,7,9,3,1};1.{5,4,8,7,9,3,1};     |________________|     2.{1|,4,8,7,9

2016-12-05 12:11:13 307

原创 排序(冒泡)

之前刚写完插入排序接下来写写冒泡排序冒泡排序就像水泡一样不断的上浮,从而达到排序的目的。冒泡排序和插入排序一样也是分成也排序部分和未排序部分。就是一个重复执行以下步骤的一个过程:从数组的末尾取一个元素开始依次的向前比较相邻的两个元素,如果大小关系相反则交换位置。举个例子:A = {5,3,2,4,1};1.{5,3,2,41};     5.{1|,5,3,24};   8

2016-12-05 11:49:45 274

原创 排序(插入)

最近打算重新把基础过一遍,先搞搞排序。插入排序:顾名思义,我们就是一次次的不断插入我们的数据以保证他的单调性。就像我们平时斗地主一样的,不断的从右边选出一张牌插到左边,保证每次左边的拍一定比它小就可以了。插入排序在排序过程中分为已排序部分和未排序部分,不断的从未排序部分拿出数字来向已排序部分插入。举个例子:A = {8,3,1,5,2,1};1.{8|,3,1,5,2,1}

2016-12-05 11:23:56 271

原创 P1908 逆序对

题意:题目描述猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏,现在他们喜欢玩统计。最近,TOM老猫查阅到一个人类称之为“逆序对”的东西,这东西是这样定义的:对于给定的一段正整数序列,逆序对就是序列中ai>aj且i输入输出格式输入格式:第一行,一个数n,表示序列中有n个数。第二行n个数,表示给定的序列。输出格式

2016-10-13 07:44:46 1183

空空如也

空空如也

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

TA关注的人

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