acm
acm题解。
Dreamoon5
Hello world!
展开
-
假期开始搞ACM了,就随手找个地方记录下吧T-T
第一篇博客就这么给了ACM, 之后把自己学到的算法和水到的题都记录下来吧, 坚持刷题!!原创 2018-08-08 16:26:33 · 124 阅读 · 0 评论 -
暑假训练 Collecting Bugs POJ - 2096 期望dp
题目描述:Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs i...原创 2018-10-05 21:32:03 · 161 阅读 · 0 评论 -
暑假训练 The Triangle Game (OpenJ_Bailian - 1574)
题目描述:In the triangle game you start off with six triangles numbered on each edge, as in the example above. You can slide and rotate the triangles so they form a hexagon, but the hexagon is only lega...原创 2018-09-23 00:26:08 · 321 阅读 · 0 评论 -
暑假训练 生日蛋糕 OpenJ_Bailian - 1190 (dfs+剪枝)
题目描述:7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要求Ri > Ri+1且Hi > Hi+1。由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积Q最小。原创 2018-09-23 01:56:35 · 193 阅读 · 0 评论 -
暑假训练 Greg and Graph CodeForces - 295B 最短路
题目描述:Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he...原创 2018-10-17 21:17:55 · 194 阅读 · 0 评论 -
暑假训练 Largest Rectangle in a Histogram HDU - 1506 dp
题目描述:A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left ...原创 2018-10-07 10:16:23 · 180 阅读 · 0 评论 -
暑假训练 City Game HDU - 1505 dp
题目描述:Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,factories and bu...原创 2018-10-07 14:13:03 · 126 阅读 · 0 评论 -
暑假训练 Common Subsequence HDU - 1159 dp求LCS
题目描述:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, …, xm> another sequence Z = <z1, z2, …, zk> is a su...原创 2018-10-07 15:05:22 · 117 阅读 · 0 评论 -
暑假训练 Piggy-Bank HDU - 1114 完全背包
题目描述:Before 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 behind is ...原创 2018-10-07 15:57:31 · 126 阅读 · 0 评论 -
暑假训练 Food Delivery ZOJ - 3469 区间dp
题目描述:When we are focusing on solving problems, we usually prefer to stay in front of computers rather than go out for lunch. At this time, we may call for food delivery.Suppose there are N people li...原创 2018-10-08 00:11:50 · 149 阅读 · 0 评论 -
暑假训练 Radar Installation POJ - 1328 贪心
题目描述:Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating o...原创 2018-10-08 18:15:39 · 124 阅读 · 0 评论 -
暑假训练 Skiing POJ - 3037 最短路
题目描述:Bessie and the rest of Farmer John’s cows are taking a trip this winter to go skiing. One day Bessie finds herself at the top left corner of an R (1 <= R <= 100) by C (1 <= C <= 100)...原创 2018-10-15 20:55:04 · 179 阅读 · 1 评论 -
暑假训练 Stall Reservations POJ - 3190 贪心
题目描述:Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A…B (1 <= A <= B <= 1,000,000), which includes both t...原创 2018-10-09 19:58:20 · 150 阅读 · 0 评论 -
暑假训练 Yogurt factory POJ - 2393 贪心
题目描述:The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will...原创 2018-10-09 20:52:23 · 257 阅读 · 0 评论 -
暑假训练 Protecting the Flowers POJ - 3262 贪心
题目描述:Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating his bea...原创 2018-10-10 08:59:15 · 105 阅读 · 0 评论 -
暑假训练 Multiplication Puzzle POJ - 1651 区间dp
在此做一个dp小结吧。背包问题已经说过了,虽然都是最简单的背包问题(太菜了)然后是:区间dp题目大意:一个数组两端数据不能取,每次取出数据所得分数为所取数据与相邻两个数据的乘积,求取出所有数字(不包括两端)后的最小分数。。。POJ - 1651#include&amp;lt;cstdio&amp;gt;#include&amp;lt;algorithm&amp;gt;#include&amp;lt;cstring原创 2018-10-05 21:27:41 · 122 阅读 · 0 评论 -
暑假训练 Cash Machine POJ - 1276 背包问题
题目描述:A Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denominations, say...原创 2018-10-04 16:24:26 · 98 阅读 · 0 评论 -
暑假训练 MPI Maelstrom POJ - 1502 最短路
题目描述: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 researc...原创 2018-10-11 19:34:14 · 246 阅读 · 0 评论 -
暑假训练 迷宫寻宝(bfs)
题目描述 洪尼玛今天准备去寻宝,在一个n*n (n行, n列)的迷宫中,存在着一个入口、一些墙壁以及一个宝藏。由于迷宫是四连通的,即在迷宫中的一个位置,只能走到与它直接相邻的其他四个位置(上、下、左、右)。现洪尼玛在迷宫的入口处,问他最少需要走几步才能拿到宝藏?若永远无法拿到宝藏,则输出-1。Input 多组测试数据。每组数据输入第一行为正整数n,表示迷宫大小。接下来n行,每行包括...原创 2018-09-17 01:10:32 · 1438 阅读 · 0 评论 -
暑假训练 HDU 2102 A计划(两层dfs)
题目描述: 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#...原创 2018-09-17 17:12:16 · 117 阅读 · 0 评论 -
暑假训练 HDU 2102 A计划(两层bfs)
题目描述: 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#...原创 2018-09-17 18:32:00 · 103 阅读 · 0 评论 -
暑假训练 Battle City (OpenJ_Bailian - 2312)bfs +优先队列
描述:Many of us had played the game “Battle city” in our childhood, and some people (like me) even often play it on computer now.What we are discussing is a simple edition of this game. Given a map t...原创 2018-09-23 12:34:01 · 257 阅读 · 0 评论 -
暑假训练 确定比赛名次 HDU - 1285 拓扑排序
描述:有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N...原创 2018-09-23 15:53:44 · 88 阅读 · 0 评论 -
暑假训练 Ordering Tasks UVA - 10305 拓扑排序
描述:John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed.InputThe input will consist of sever...原创 2018-09-23 15:58:22 · 100 阅读 · 0 评论 -
暑假训练 Reward HDU - 2647 拓扑排序
题目描述:Dandelion’s uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards to his workers. Now he has a trouble about how to distribute the rewards.The workers ...原创 2018-09-24 20:54:13 · 117 阅读 · 0 评论 -
暑假训练 Play on Words (UVA - 10129) 欧拉回路
题目描述:Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is ver...原创 2018-09-25 11:07:50 · 199 阅读 · 0 评论 -
暑假训练 最短路径问题 HDU - 3790 最短路基础
题目描述:给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点。n和m为0时输入结束。(1<n<=1000, 0<...原创 2018-10-11 12:03:05 · 242 阅读 · 0 评论 -
暑假训练 Choose the best route HDU - 2680 最短路
题目描述:One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route,...原创 2018-10-11 17:04:45 · 115 阅读 · 0 评论 -
暑假训练 The Necklace UVA - 10054 欧拉回路
题目描述:My little sister had a beautiful necklace made of colorful beads. Two successive beads in the necklace shared a common color at their meeting point. The figure below shows a segment of the neckl...原创 2018-09-26 23:50:28 · 170 阅读 · 0 评论 -
暑假训练 John's trip POJ - 1041 欧拉回路
题目描述:Little Johnny has got a new car. He decided to drive around the town to visit his friends. Johnny wanted to visit all his friends, but there was many of them. In each street he had one friend. H...原创 2018-09-27 00:04:28 · 193 阅读 · 0 评论 -
暑假训练 欧拉回路
欧拉回路这个专题的入门也差不多了,总结下吧。一般用可达矩阵来存储图,然后判断欧拉回路,首先判断出度和入度是否满足欧拉回路的要求(即入度等于出度,或欧拉通路仅有两点入度比出度大一,出度比入度大一)代码:int in[n];bool judge(){ for(int i = 0; i < n; i++) { if(in[i] % 2 != 0)retur...原创 2018-09-27 00:29:15 · 173 阅读 · 0 评论 -
暑假训练 Currency Exchange POJ - 1860 最短路
题目描述:Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. The...原创 2018-10-17 19:59:39 · 127 阅读 · 0 评论