算法与ACM
文章平均质量分 77
sunny1996
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ2785 4 Values whose Sum is 0(二分的力量)
DescriptionThe SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0原创 2015-04-10 22:43:14 · 976 阅读 · 0 评论 -
ZOJ 1076 Gene Assembly (贪心求区间不相交问题)
Statement of the Problem With the large amount of genomic DNA sequence data being made available, it is becoming more important to find genes (parts of the genomic DNA which are responsible for原创 2015-03-22 21:17:42 · 606 阅读 · 0 评论 -
POJ 1088 滑雪 (二维最长上升子序列)
DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 7原创 2015-03-20 23:09:48 · 1521 阅读 · 2 评论 -
POJ1853 Cat (变形与记录路径的01背包)
DescriptionIn strong winds, sailboats tend to heel leeward (tilt away from the wind) like the one in the picture. Heeling is undesirable for at least two reasons. First, the effective sail area原创 2015-03-08 22:24:12 · 1118 阅读 · 0 评论 -
POJ2533 Longest Ordered Subsequence (最长上升子序列)
DescriptionA numeric sequence of ai is ordered ifa1 a2 < ... <aN. Let the subsequence of the given numeric sequence (a1,a2, ..., aN) be any sequence (ai1,ai2, ...,aiK), where 1 <=i1原创 2015-03-07 21:12:24 · 482 阅读 · 0 评论 -
POJ1384 Piggy-Bank (完全背包)
DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea原创 2015-03-07 20:58:20 · 405 阅读 · 0 评论 -
POJ3624 Charm Bracelet (01背包)
DescriptionBessie 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 theN (1 ≤ N ≤ 3,402) available charms原创 2015-03-07 20:32:47 · 409 阅读 · 0 评论 -
POJ1163 The Triangle(数字三角形) (动态规划初步)
Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a rou原创 2015-03-07 20:18:35 · 524 阅读 · 0 评论 -
DFS与BFS搜图模板总结
DFS:void dfs(坐标){ if (满足条件) { 结束处理; } else { 用for循环或其他手段实现点的移动(一滑到底,相邻格子,“日”字型。。。。。。) { if(将要移动的点满足合法条件(不撞墙,不出界。。。。。。))原创 2015-03-03 22:35:12 · 454 阅读 · 0 评论 -
UVA12108 Extraordinarily Tired Students(超级大模拟)
When a student is too tired, he can't help sleeping in class, even if his favorite teacher is right here in front of him. Imagine you have a class of extraordinarily tired students, how long do yo原创 2015-02-26 21:35:14 · 579 阅读 · 0 评论 -
POJ2243 Knight moves (BFS求最短路)
DescriptionA friend of you is doingresearch on the Traveling Knight Problem (TKP) where you are to find theshortest closed tour of knight moves that visits each square of a given set ofn s原创 2015-02-25 21:09:47 · 628 阅读 · 1 评论 -
POJ3009 Curling2.0 (DFS求最短路(已知最长的情况下))
On Planet MM-21, after theirOlympic games this year, curling is getting popular. But the rules are somewhatdifferent from ours. The game is played on an ice game board on which a squaremesh is marke原创 2015-02-25 21:03:57 · 585 阅读 · 0 评论 -
UVA572 POJ1562 oil deposits(DFS求连通块问题)
DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a原创 2015-02-25 18:15:56 · 587 阅读 · 0 评论 -
UVA202
Repeating Decimals The decimal expansion of the fraction 1/33 is Repeating Decimals" align="bottom" alt="tex2html_wrap_inline43" src="http://uva.onlinejudge.org/external/2/202img1.gif"> , wher原创 2015-02-04 16:39:01 · 820 阅读 · 0 评论 -
CCF模拟试题I’m stuck!
问题描述给定一个R行C列的地图,地图的每一个方格可能是'#', '+', '-', '|','.', 'S', 'T'七个字符中的一个,分别表示如下意思:'#': 任何时候玩家都不能移动到此方格;'+': 当玩家到达这一方格后,下一步可以向上下左右四个方向相邻的任意一个非'#'方格移动一格;'-': 当玩家到达这一方格后,下一步可以向左右两个方向相邻的一个非'#原创 2016-09-04 21:26:15 · 1165 阅读 · 0 评论 -
CCF模拟试题-最大的矩形
问题描述在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3。请找出能放在给定直方图里面积最大的矩形,它的边要与坐标轴平行。对于上面给出的例子,最大矩形如下图所示的阴影部分,面积是10。输入格式第一行包含一个整原创 2016-09-04 21:33:56 · 2109 阅读 · 0 评论 -
CF 523C (字符串处理)
DescriptionA Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he c原创 2015-03-22 21:34:06 · 485 阅读 · 0 评论 -
POJ2576 Tug of War (二维的01背包)
DescriptionA tug of war is to be arranged at the local office picnic. For the tug of war, the picnickers must be divided into two teams. Each person must be on one team or the other; the number原创 2015-03-22 21:47:44 · 1355 阅读 · 1 评论 -
POJ3984 迷宫问题 (BFS与路径记录)
Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的原创 2015-04-12 18:05:11 · 498 阅读 · 0 评论 -
POJ2484 A Funny Game (典型博弈论)
DescriptionAlice and Bob decide to play a funny game. At the beginning of the game they pick n(1 6) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins,原创 2015-04-12 18:15:45 · 686 阅读 · 0 评论 -
POJ3104 Drying (二分的力量2)
DescriptionIt is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to m原创 2015-04-12 21:52:41 · 1017 阅读 · 0 评论 -
POJ3061 Subsequence (追逐法)
DescriptionA sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal原创 2015-04-26 22:22:13 · 599 阅读 · 0 评论 -
POJ1258 Agri-Net(Prim求解最小生成树)
DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John原创 2015-05-09 21:57:12 · 423 阅读 · 0 评论 -
POJ1287 Networking (Kruskal与并查集求解最小生成树)
DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may c原创 2015-05-09 22:12:03 · 683 阅读 · 0 评论 -
POJ1094 Sorting It All Out (不仅仅是拓扑排序)
DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted seque原创 2015-05-09 22:31:05 · 453 阅读 · 0 评论 -
POJ2387 Til the Cows Come Home(dijkstra求图论最短路)
DescriptionBessie 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 s原创 2015-05-11 22:55:55 · 471 阅读 · 0 评论 -
找倍数(优先队列解法)
时限:1000ms 内存限制:10000K 总时限:3000ms描述对于每个输入的数字(如:2),则要求 给出一个由1,0构成的十进制整数,且该整数为输入数字的某个倍数,且是满足该条件的最小数(如2对应的10)。 输入数字n,n等于0时停止。 输出n的一个满足条件的最小倍数。 输入样例20 输出样例10 提示 来源原创 2016-04-23 11:56:47 · 917 阅读 · 0 评论 -
旅游预算(复杂深搜)
描述一个旅行社需要估算乘汽车从某城市到另一城市的最小费用,沿路有若干加油站,每个加油站收费不一定相同。旅游预算有如下规则: 若油箱的油过半,不停车加油,除非油箱中的油不可支持到下一站;每次加油时都加满;在一个加油站加油时,司机要花费2元买东西吃;司机不必为其他意外情况而准备额外的油;汽车开出时在起点加满油箱;计算精确到分(1元=100分)。编写程序估计实际行驶在某路线所需的最小费用。原创 2016-04-23 12:00:47 · 1159 阅读 · 0 评论 -
求图像的周长(深搜)
时限:1000ms 内存限制:10000K 总时限:3000ms描述给一个用 . 和X表示的图形,图形在上、下、左、右、左上、左下、右上、右下8个方向都被看作是连通的,并且图像中间不会出现空洞,求这个图形的边长。输入首先给出m、n、x、y四个正整数,下面给出m×n的图形,x、y表示点击的位置,全0表示结束。 输出点击的图形的周长。 输入样例2 2原创 2016-04-23 12:06:08 · 569 阅读 · 0 评论 -
字母转换(深搜)
时限:1000ms 内存限制:10000K 总时限:3000ms描述通过栈交换字母顺序。给定两个字符串,要求所有的进栈和出栈序列(i表示进栈,o表示出栈),使得字符串2在求得的进出栈序列的操作下,变成字符串1。输出结果需满足字典序。例如TROT 到 TORT:[i i i i o o o oi o i i o o i o] 输入给定两个字符串,第一个字符串原创 2016-04-23 12:08:38 · 506 阅读 · 0 评论 -
POJ2225 Asteroids! (三维的BFS求最短路)
Asteroids!Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3017 Accepted: 1138DescriptionYou're in space. You want to get home. There are asteroids原创 2015-04-04 23:46:50 · 548 阅读 · 0 评论 -
POJ1458 Common Subsequence (最长公共子序列)
DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a st原创 2015-03-28 22:33:53 · 488 阅读 · 0 评论 -
HDU2046 骨牌铺方格 (一道水题引发的思考)
Problem Description在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: Input输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0 Output对于每个测试实例,请输出铺放方案的总数,每个实原创 2015-03-22 22:08:02 · 464 阅读 · 0 评论 -
花生米三连发(动规)
1.时限:1000ms 内存限制:10000K 总时限:3000ms描述五一长假第二天,Tom和Jerry在仓库散步的时候又发现了一堆花生米(这个仓库还真奇怪)。这次Tom制定分花生米规则如下: 1、Tom和Jerry轮流从堆中取出k粒花生米吃掉,k可以是1,5,10中的任意一个数字; 2、为显示规则的公平性,Jerry可以选择先取或者后取。 J原创 2016-04-23 12:22:24 · 1013 阅读 · 3 评论
分享