URAL 1029】的更多相关文章

题目传送门 /* 题意:就是从上到下,找到最短路,输出路径 DP+路径:状态转移方程:dp[i][j] = min (dp[i-1][j], dp[i][j-1], dp[i][j+1]) + a[[i][j]; (类似数塔问题) 关键在记录路径,可以用pre[x][y] = -1/0/1/2 区分,DFS回溯输出 详细解释:http://www.cnblogs.com/staginner/archive/2012/05/02/2479658.html */ #include <cstdio>…
URAL 1029 思路: dp+记录路径 状态:dp[i][j]表示到(i,j)这个位置为止的最少花费 初始状态:dp[1][i]=a[1][i](1<=i<=m) 状态转移:dp[i][j]=a[i][j]+max(dp[i-1][j],dp[i][j-1],dp[i][j+1])(注意扫的方向不同) 数组记录上一次的坐标,最后递归输出 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #…
目录 Ural 1029 Ministry 题解 题意 题解 程序 Ural 1029 Ministry 题解 题意 给定一个\(n\times m(1\le n \le10,1\le m \le500)\)的矩阵,矩阵中的每个值都是一个小于等于\(10^9\)的正整数. 现在从第\(1\)行的任意位置开始,在第\(n\)行的任意位置结束.每次有\(3\)种移动选择(不能移动到矩阵外). 设当前位置为\((i,j)\) 移动到\((i+1,j)\) 移动到\((i,j-1)\) 移动到\((i,…
题目大意:M层N列的矩阵(各元素均为正整数),找出一个路径从第一层到达第M层,使得路径上的所有数的和是所有可达路径中最小的,每次上到下一层以后就不能再上去,依次输出路径上的各点在所在层的列数. KB     64bit IO Format:%I64d & %I64u 数据规模:1<=M<=100,1<=N<=500,路径上的数的总和不会超过10^9. 理论基础:无. 题目分析:用dp[i][j]表示到达第i层第j列元素的最小路径的值,用pre[i][j]存储dp[i][j]…
题意: n层楼,每层楼有m个房间.找出一个路径从第一层到达第M层,使得路径上的所有数的和是所有可达路径中最小的,每次上到下一层以后就不能再上去,依次输出路径上的各点在所在层的列数. 题解: 参考链接:传送门 dp[i][j]表示:在第i层楼,第j个房间所消耗的最小花费 dp[i][j]的最优值只能从dp[i-1][j]或者dp[i][j-1]或者dp[i][j+1]来得出,所以dp转移方程 1 for(LL i=2; i<=n; ++i) 2 { 3 for(LL j=1; j<=m; ++j…
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scientific Conference URAL 1353 Milliard Vasya's Function URAL 1260 Nudnik Photographer URAL 1012 K-based Numbers. Version 2 URAL 1073 Square Country URAL 1…
1075. Thread in a Space Time limit: 1.0 secondMemory limit: 64 MB There are three points in a 3-dimensional space: A, B and C. All the coordinates of the points are integer numbers with absolute values not greater than 1000. A solid ball with a cente…
又搞了一晚上OI,编了两道BZOJ和几道NOI题库,临走之前写两篇感想 noip越来越近了,韩大和clove爷已经开始停课虐我们了... 1029: [JSOI2007]建筑抢修 Time Limit: 4 Sec Memory Limit: 162 MB Submit: 3014 Solved: 1346 [Submit][Status][Discuss] Description 小刚在玩JSOI提供的一个称之为"建筑抢修"的电脑游戏:经过了一场激烈的战斗,T部落消灭了所有z部落的入…
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串中心位置,RMQ询问LCP = min (height[rank[l]+1] to height[rank[r]]),注意的是RMQ传入参数最好是后缀的位置,因为它们在树上的顺序未知,且左边还要+1. #include <cstdio> #include <algorithm> #in…
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and each orders a juice cocktail. It could be from 1 to 3 different juices in each cocktail. There are three juices in the bar: apple, banana and pineappl…
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best programmer in the world! Now he regularly takes part in various programming contests, attentively listens to problems analysis and upsolves problems. But…
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a prime number. However, Asya thinks an integer is interesting i…
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock band on Earth. Band decided to make the most awesome music video ever for their new single. In that music video Ilya will go through Manhattan standi…
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in process, manpower and supplies are coming to an end and the winter is as near as never before. The game of thrones is unpredictable so Daenerys and Stannis…
2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. According to a proverb, every man to his own taste. So the children value strawberries and raspberries differently. Let’s say that i-th child rates hi…
2066. Simple Expression Time limit: 1.0 secondMemory limit: 64 MB You probably know that Alex is a very serious mathematician and he likes to solve serious problems. This is another problem from Alex. You are given three nonnegative integers a, b, c.…
2065. Different Sums Time limit: 1.0 secondMemory limit: 64 MB Alex is a very serious mathematician and he likes to solve serious problems. For example, this problem. You are to construct an array of n integers in which the amount of different intege…
2064. Caterpillars Time limit: 3.0 secondMemory limit: 64 MB Young gardener didn’t visit his garden for a long time, and now it’s not very pleasant there: ncaterpillars have appeared on the ground. Kirill decided to use this opportunity to have some…
2063. Black and White Time limit: 1.0 secondMemory limit: 64 MB Let’s play a game. You are given a row of n balls, each ball is either black or white. Their positions in a row are numbered from 1 to n. You know the total number of balls n, but have n…
2062. Ambitious Experiment Time limit: 3.0 secondMemory limit: 128 MB During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity…
1255. Graveyard of the Cosa Nostra Time limit: 1.0 secondMemory limit: 64 MB There is a custom among the Ural Mafiosi — a big Mafioso’s coffin is to be carried by all his subordinates. The length of the coffin (in meters) equals to the number of the…
1252. Sorting the Tombstones Time limit: 1.0 secondMemory limit: 64 MB There is time to throw stones and there is time to sort stones… An old desolate cemetery is a long dismal row of nameless tombstones There are N tombstones of various shapes. The…
1251. Cemetery Manager Time limit: 1.0 secondMemory limit: 64 MB There is a tradition at the USU championships to call the most hard-to-solve problems coffins. But to distribute coffins is also a very difficult problem. Consider a cemetery with place…
1250. Sea Burial Time limit: 1.0 secondMemory limit: 64 MB There is Archipelago in the middle of a shoreless ocean. An ancient tribe of cannibals lives there. Shamans of this race have been communicating with gods and admonishing people for ages. The…
1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bitmap picture of a hard-to-reach region. According to the suggestions of scientists, this region is a cemetery of an extinct civilization. Indeed, the p…
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square Parliament has passed a law about a land. According to the law each citizen of th…
1072. Routing Time limit: 1.0 secondMemory limit: 64 MB There is a TCP/IP net of several computers. It means that: Each computer has one or more net interfaces. Each interface is identified by its IP-address and a subnet mask — these are two four-byt…
1071. Nikifor 2 Time limit: 1.0 secondMemory limit: 64 MB Nikifor has a number x. He doesn't need it. He needs a number y. Nikifor tries to obtain the required number by erasing some digits from x. But he is not lucky in the meanwhile. May be he is t…
1070. Local Time Time limit: 1.0 secondMemory limit: 64 MB Soon the USU team will go to Vancouver to participate in the final of the ACM International Collegiate Programming Contest. They will be to take four different planes (three changes on the wa…
1069. Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) with vertices is given (N ≥ 2). Vertices of the tree are numbered by the integers 1,…,N. A Prufer code for the tree is built as follows: a leaf…