摘要: DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。 阅读全文
posted @ 2012-03-15 12:46 'wind 阅读(141) 评论(0) 推荐(0)
摘要: 迷宫问题Time Limit:1000MSMemory Limit:65536KTotal Submissions:3850Accepted:2226Description定义一个二维数组: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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角 阅读全文
posted @ 2012-03-15 12:44 'wind 阅读(331) 评论(0) 推荐(0)
摘要: 要求: 输入行数为n列数为m的迷宫,用‘s’表示起点,‘#’表示墙头,输出起点到各点的最短路。sample input:5 5s#....#....#..........#..sample output:0 0 8 9 101 0 7 0 92 0 6 0 83 4 5 6 74 5 0 7 8code:View Code #include<stdio.h> #include<string.h> int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0}; int q[100000]; int maze[200][200]; int vis[200][2 阅读全文
posted @ 2012-03-15 12:36 'wind 阅读(264) 评论(0) 推荐(0)
摘要: DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting 阅读全文
posted @ 2012-03-15 12:35 'wind 阅读(193) 评论(0) 推荐(0)
摘要: Problem 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 grid that divides the land into numerous square plots. It then analyzes each plot separately, using s 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(174) 评论(0) 推荐(0)
摘要: Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.Write a program to count 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(254) 评论(0) 推荐(0)
摘要: View Code #include<stdio.h>#include<string.h>int id,jd,k,t,m,n,f[8]={0,0,1,-1,1,-1,0,0};char s[8][8];void dfs(int i,int j,int c){ int p,ii,jj; if(i==id&&j==jd) { if(c==k) t=1; return; } for(p=0;p<4;p++) { ii=i+f[p]; jj=j+f[p+4]; if(... 阅读全文
posted @ 2012-03-15 12:33 'wind 阅读(193) 评论(0) 推荐(0)
摘要: DescriptionLeyni是一个地址调查员,有一天在他调查的地方突然出现个泉眼。由于当地的地势不均匀,有高有低,他觉得如果这个泉眼不断的向外溶出水来,这意味着这里在不久的将来将会一个小湖。水往低处流,凡是比泉眼地势低或者等于的地方都会被水淹没,地势高的地方水不会越过。而且又因为泉水比较弱,当所有地势低的地方被淹没后,水位将不会上涨,一直定在跟泉眼一样的水位上。 由于Leyni已经调查过当地很久了,所以他手中有这里地势的详细数据。所有的地图都是一个矩形,并按照坐标系分成了一个个小方格,Leyni知道每个方格的具体高度。我们假定当水留到地图边界时,不会留出地图外,现在他想通过这些数据分析出, 阅读全文
posted @ 2012-03-15 12:30 'wind 阅读(354) 评论(0) 推荐(0)
摘要: Problem DescriptionDo you remember the box of Matryoshka dolls last week? Adam just got another box of dolls from Matryona. This time, the dolls have different shapes and sizes: some are skinny, some are fat, and some look as though they were attened. Specifically, doll i can be represented by three 阅读全文
posted @ 2012-03-15 01:00 'wind 阅读(236) 评论(0) 推荐(0)
摘要: Problem Description给你一个n*n的格子的棋盘,每个格子里面有一个非负数。从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。Input包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20)Output对于每个测试实例,输出可能取得的最大的和Sample Input375 15 21 75 15 28 34 70 5Sample Output188预备知识:点覆盖集:无向图G的一个点集,使得该图中所有边都至少有一个端点在该集合内。最小点权覆盖集:在带点权无向图G中,点权之和最小的覆盖集 阅读全文
posted @ 2012-03-15 00:59 'wind 阅读(237) 评论(0) 推荐(0)
摘要: DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the grid. Fortunately, Bessie has a powerful weapo 阅读全文
posted @ 2012-03-15 00:58 'wind 阅读(228) 评论(0) 推荐(0)
摘要: Problem DescriptionThere are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other.Now you are given all pairs of students who know each other. Your task is to 阅读全文
posted @ 2012-03-15 00:57 'wind 阅读(254) 评论(0) 推荐(0)
摘要: Problem DescriptionRPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑到经费问题,boss刘决定只让找到partner的人去坐过山车,其他的人,嘿嘿,就站在下面看着吧。聪明的Acmer,你可以帮忙算算最多有多少对组合可以坐上过山车吗 阅读全文
posted @ 2012-03-15 00:55 'wind 阅读(243) 评论(0) 推荐(0)
摘要: Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover 阅读全文
posted @ 2012-03-15 00:54 'wind 阅读(205) 评论(0) 推荐(0)
摘要: Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of input contains an integer T, denoting the number of test cases.For each test case, the first line contains two 阅读全文
posted @ 2012-03-15 00:52 'wind 阅读(230) 评论(0) 推荐(0)
摘要: Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of input contains an integer T, denoting the number of test cases.For each test case, the first line contains two 阅读全文
posted @ 2012-03-15 00:51 'wind 阅读(740) 评论(0) 推荐(0)
摘要: Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pudge wants to do some operations on the hook.Let us number the consecutive metallic stick 阅读全文
posted @ 2012-03-15 00:49 'wind 阅读(192) 评论(0) 推荐(0)
摘要: Problem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。当N = 0,输入结束。Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共 阅读全文
posted @ 2012-03-15 00:47 'wind 阅读(434) 评论(0) 推荐(0)
摘要: Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other important inf 阅读全文
posted @ 2012-03-15 00:45 'wind 阅读(197) 评论(0) 推荐(0)
摘要: Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given sequence of numbers a1, a2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we will obtain another sequence. 阅读全文
posted @ 2012-03-15 00:44 'wind 阅读(199) 评论(0) 推荐(0)
摘要: Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分别代表学生的数目和操作的数目。学生ID编号分别从1编到N。第二行包含N个整数,代表这N个学生的初始成绩,其中第i个数代表ID为i的学生的成绩。接下来有M行。每一行有一个 阅读全文
posted @ 2012-03-15 00:42 'wind 阅读(165) 评论(0) 推荐(0)
摘要: Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共有多少人,例如Derek问:“Tidy,马上汇报第3个营地到第10个营地共有多少人!”Tidy就要马上开始计算 阅读全文
posted @ 2012-03-15 00:41 'wind 阅读(178) 评论(0) 推荐(0)
摘要: DescriptionAn array of sizen≤ 106is given to you. There is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window moves rightwards by one position. Following is an example:The array is [13-1 阅读全文
posted @ 2012-03-15 00:34 'wind 阅读(197) 评论(0) 推荐(0)
摘要: DescriptionLeyni被人掳走,身在水深火热之中...小奈叶为了拯救Leyni,独自一人前往森林深处从静竹手中夺回昏迷中的Leyni。历经千辛万苦,小奈叶救出了Leyni,但是静竹为此极为恼怒,决定对他们发起最强烈的进攻。不过小奈叶有一个叫做能量保护圈的道具,可以保护他们。这个保护圈由n个小的小护盾围成一圈,从1到n编号。当某一块小护盾受到攻击的时候,小护盾就会抵消掉这次攻击,也就是说对这一块小护盾的攻击是无效攻击,从而保护圈里的人,不过小护盾在遭到一次攻击后,需要t秒进行冷却,在冷却期间受到的攻击都是有效攻击,此时他们就会遭到攻击, 即假设1秒时受到攻击并成功防御,到1+t秒时冷却 阅读全文
posted @ 2012-03-15 00:31 'wind 阅读(271) 评论(0) 推荐(0)
摘要: DescriptionTigers are enclosed in wire-net fencing at zoo.If they get out of the fencing, they may attack people.We use some lines to present the fencing as the picture following:Your task is to judge if a tiger in the fencing or not.In picture 1 the tiger is in the fencing.Note that enclosed fencin 阅读全文
posted @ 2012-03-15 00:29 'wind 阅读(229) 评论(0) 推荐(0)
摘要: Description一个封闭的多边形定义是被有限个线段包围。线段的相交点称作多边形的顶点,当你从多边形的一个顶点沿着线段行走时,最终你会回到出发点。凸多边形(convex)想必大家已经很熟悉了,下图给出了凸多边形和非凸多边形实例。这里讨论的是在平面坐标的封闭凸多边形,多变形的顶点一个顶点在原点(x=0,y=0).图2显示的那样。这样的图形有两种性质。第一种性质是多边形的顶点会在平面上少于等于三个象限,就如图二那样,第二向县里面没有多边形的点(x<0,y>0)。为了解释第二种性质,假设你沿着多边形旅行,从原点(0,0)出发遍历每个顶点一次,当你遍历到除原点(0,0)时候,从这一点画 阅读全文
posted @ 2012-03-15 00:28 'wind 阅读(326) 评论(0) 推荐(0)
摘要: DescriptionArcheologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are able to determine that the lower floor of the pyramid is constructed from a series of straightline walls, which intersect to f 阅读全文
posted @ 2012-03-15 00:27 'wind 阅读(184) 评论(0) 推荐(0)
摘要: DescriptionStan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he 阅读全文
posted @ 2012-03-15 00:25 'wind 阅读(220) 评论(0) 推荐(0)
摘要: DescriptionCalculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John is rebellious and obeys his parents by s 阅读全文
posted @ 2012-03-14 23:15 'wind 阅读(179) 评论(0) 推荐(0)
摘要: Problem DescriptionMany geometry(几何)problems were designed in the ACM/ICPC. And now, I also prepare a geometry problem for this final exam. According to the experience of many ACMers, geometry problems are always much trouble, but this problem is very easy, after all we are now attending an exam, no 阅读全文
posted @ 2012-03-14 23:14 'wind 阅读(251) 评论(0) 推荐(0)