欢迎访问我的个人网站==》 jiashubing.cn

随笔分类 -  OJ_ZOJ

摘要:To the MaxTime Limit:2 Seconds Memory Limit:65536 KBProblemGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. In 阅读全文
posted @ 2013-08-03 15:56 贾树丙 阅读(325) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=76题目大意:在一个DNA上,给定许多基因的起始位置和结束位置,求出这条链上最多同时存在多少基因?并依次输出选择基因的序列号。Sample Input6340 500220 470100 300880 943525 556612 7763705 773124 337453 6650Sample Output3 1 5 6 42 3 1分析:有两种思路。1.最长上升子序列+路径打印;2.贪心法1: 1 //dp[i] = max{0,dp[j]}+1,j 6 # inc 阅读全文
posted @ 2013-08-03 15:38 贾树丙 阅读(413) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=25题目大意:机器运送n个木条,每个木条有一个长度和重量。运送第一根木条需要1分钟的准备时间,接下来如果后一根木条的长度和重量都大于等于前一根木条,则不需要准备时间,否则需要1分钟的准备时间,求运完所有木条最少时间。 比如有5根木条,长度和重量分别是(4,9), (5,2), (2,1), (3,5), (1,4),则需要2分钟就可运完第1分钟运(1,4), (3,5), (4,9);第2分钟运 (2,1), (5,2)分析:快速排序加贪心。首先按照木条长度从小到大排 阅读全文
posted @ 2013-08-02 15:19 贾树丙 阅读(611) 评论(0) 推荐(1) 编辑
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=13题目大意:说的是有三种不同的装备,分别是头盔,盔甲,战靴需要运输,每种装备拥有不同的重量,体积,以及防御能力.当三种装备按照一定的数量规定组合成套装时,套装可以发挥处更强的攻击能力.然后有n个运输车,每个车能够运送的重量和体积有限制,现在问如何给这个n个运输车分配运送任务(即每个运输队运多少头盔,多少盔甲,多少战靴) 可以获得总的防御值最大。输入描述:第一行是运输车的数量n。接下来是第1行是每个头盔的重量w1、体积s1、防御能力d1;第2行是每个盔甲的重量w2、体 阅读全文
posted @ 2013-07-30 02:03 贾树丙 阅读(871) 评论(0) 推荐(0) 编辑
摘要:Knight MovesTime Limit:2 Seconds Memory Limit:65536 KBA friend of you is doing research on theTraveling Knight Problem (TKP)where you are to find the shortest closed tour of knight moves that visits each square of a given set ofnsquares on a chessboard exactly once. He thinks that the most difficult 阅读全文
posted @ 2013-07-25 01:15 贾树丙 阅读(732) 评论(0) 推荐(0) 编辑
摘要:又是类似骑士拯救公主,不过这个是朋友拯救天使的故事。。。不同的是,天使有多个朋友,而骑士一般单枪匹马比较帅~求到达天使的最短时间,杀死一个护卫1 units time , 走一个格子 1 unit time 。SO,杀死一个护卫到达那个格子 2units time。第一反应是广搜,就搜咧 = =。。WA了,交hdu上 AC了,hdu数据真弱啊。。。想了想,想通了,因为一般广搜的话必须都是1个时间才能搜,才能保证这个BFS树是等距离向外伸展的,而这个不是等距离的,所以需要一些处理。1、我的方法是,找到天使后,把时间比下大小,最后输出最小的。需要优化,只这么做的话,会TLE的,如果走过一个格子,这 阅读全文
posted @ 2013-07-22 18:18 贾树丙 阅读(284) 评论(0) 推荐(0) 编辑
摘要:Exploring PyramidsArchaeologists have discovered a new set of hidden caves in one of the Egyptian pyramids. The decryption of ancient hieroglyphs on the walls nearby showed that the caves structure is as follows. There arencaves in a pyramid, connected by narrow passages, one of the caves is connect 阅读全文
posted @ 2013-07-18 14:04 贾树丙 阅读(304) 评论(0) 推荐(0) 编辑
摘要:JugsTime Limit:2 Seconds Memory Limit:65536 KB Special JudgeIn the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug with exactly 4 gallons. This proble 阅读全文
posted @ 2013-06-15 19:20 贾树丙 阅读(335) 评论(0) 推荐(0) 编辑
摘要:The GameTime Limit:2 Seconds Memory Limit:65536 KBOne morning, you wake up and think: ``I am such a good programmer. Why not make some money?'' So you decide to write a computer game.The game takes place on a rectangular board consisting of w * h squares. Each square might or might not conta 阅读全文
posted @ 2013-06-10 21:06 贾树丙 阅读(376) 评论(0) 推荐(0) 编辑
摘要:AtlantisTime Limit:2 Seconds Memory Limit:65536 KBThere 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 describe different regions of Atlantis. Your friend Bill has to 阅读全文
posted @ 2013-06-09 11:19 贾树丙 阅读(296) 评论(0) 推荐(0) 编辑
摘要:Dreisam EquationsTime Limit:10 Seconds Memory Limit:32768 KB Special JudgeDuring excavations in the Dreisamwuste, a desert on some far away and probably uncivilized planet, sheets of paper containing mysterious symbols had been found. After a long investigation, the project scientists have concluded 阅读全文
posted @ 2013-06-09 10:26 贾树丙 阅读(707) 评论(0) 推荐(0) 编辑
摘要:TransmittersTime Limit:2 Seconds Memory Limit:65536 KBIn a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at least that they don't conflict. One way of accomplishing this is to restrict a transmitter's 阅读全文
posted @ 2013-04-22 16:05 贾树丙 阅读(242) 评论(0) 推荐(0) 编辑
摘要:Exchange CardsTime Limit:2 Seconds Memory Limit:65536 KBAs a basketball fan, Mike is also fond of collecting basketball player cards. But as a student, he can not always get the money to buy new cards, so sometimes he will exchange with his friends for cards he likes. Of course, different cards have 阅读全文
posted @ 2013-04-08 17:32 贾树丙 阅读(266) 评论(0) 推荐(0) 编辑
摘要:Counting TrianglesTime Limit:2 Seconds Memory Limit:65536 KBGiven an equilateral triangle with n the length of its side, program to count how many triangles in it.InputThe length n (n 2 int n; 3 int f[501]; 4 void init(){ 5 int i,j; 6 f[0]=0; 7 for(i=1;i<501;i++) 8 f[i]=f[i-1]+i... 阅读全文
posted @ 2013-04-08 17:28 贾树丙 阅读(403) 评论(0) 推荐(0) 编辑
摘要:Multiplication PuzzleTime Limit:2 Seconds Memory Limit:65536 KBThe multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and scores the number of points equal to the product of the number on the card taken 阅读全文
posted @ 2013-04-08 17:08 贾树丙 阅读(255) 评论(0) 推荐(0) 编辑
摘要:Largest Rectangle in a HistogramTime Limit:2 Seconds Memory Limit:65536 KBA 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 shows the histogram that consist 阅读全文
posted @ 2013-04-08 17:07 贾树丙 阅读(335) 评论(0) 推荐(0) 编辑
摘要:Conquer a New RegionTime Limit:5 Seconds Memory Limit:32768 KBThe wheel of the history rolling forward, our king conquered a new region in a distant continent.There are N towns (numbered from 1 to N) in this region connected by several roads. It's confirmed that there is exact one route between 阅读全文
posted @ 2013-04-08 17:00 贾树丙 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Human Gene FunctionsTime Limit:2 Seconds Memory Limit:65536 KBIt is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their 阅读全文
posted @ 2013-04-08 16:56 贾树丙 阅读(397) 评论(0) 推荐(0) 编辑
摘要:Unimodal Palindromic DecompositionsTime Limit:2 Seconds Memory Limit:65536 KBA sequence of positive integers is Palindromic if it reads the same forward and backward. For example:23 11 15 1 37 37 1 15 11 231 1 2 3 4 7 7 10 7 7 4 3 2 1 1A Palindromic sequence is Unimodal Palindromic if the values do 阅读全文
posted @ 2013-04-08 16:44 贾树丙 阅读(658) 评论(0) 推荐(0) 编辑
摘要:FatMouse and CheeseTime Limit:10 Seconds Memory Limit:32768 KBFatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 # includeusing namespace std;int map[105][105];int vis[105][105];int n,k;bool judge(int x, 阅读全文
posted @ 2013-04-08 15:09 贾树丙 阅读(315) 评论(0) 推荐(0) 编辑