HDU 1087:Super Jumping! Jumping! Jumping!(LIS)

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/wang_123_zy/article/details/81591839

Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 49436    Accepted Submission(s): 22871

Problem Description

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.

The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.


Input contains multiple test cases. Each test case is described in a line as follow:
N value_1 value_2 …value_N 
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.


For each case, print the maximum according to rules, and one line one case.

Sample Input

3 1 3 2
4 1 2 3 4
4 3 3 2 1

Sample Output






#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
const double E=exp(1);
const int maxn=1e6+10;
using namespace std;
int a[maxn];
int b[maxn];
int dp[maxn];
int main(int argc, char const *argv[])
	int n;
		for(int i=0;i<n;i++)
			// 对dp进行初始化
		int ans=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<i;j++)
				// 如果是递增的
					// 加起来和原本的作比较
			// 如果一开始不对dp初始化,要加上下面这一句
			// dp[i]=max(dp[i],a[i]);
	return 0;


Jumping the Queue


Problem DescriptionnThe beginning of a winter break near Spring Festival is always the beginning of a peak period of transportation. If you have ever tried to get a train ticket at that time, you must have witnessed the endless queues in front of every ticket box window. If a guy has seen his friend in a queue, then it is very much likely that this lucky guy might go straight to his friend and ask for a favor. This is called "jumping the queue". It is unfair to the rest of the people in the line, but, it is life. Your task is to write a program that simulates such a queue with people jumping in every now and then, assume that, if one in the queue has several friends asking for favors, he would arrange their requests in a queue of his own.n nnInputnThere will contain one or more test cases. Each test case begins with the number of groups n (1<= n <=1000). Then n group descriptions follow, each one consisting of the number of friends belonging to the group and those people's distinct names. A group is a friend group. People in one group are friend with each other. A name is a string of up to 4 characters chosen from A, B, ..., Z, a, b, ..., z. A group may consist of up to 1000 friends. You may assume that there is no one belong to two different groups. nFinally, a list of commands follows. There are three different kinds of commands: nn● ENQUEUE X - Mr. or Ms. X goes into the queue n● DEQUEUE - the first person gets the ticket and leave the queue n● STOP - end of test case nnThe input will be terminated by a value of 0 for n.n nnOutputnFor each test case, first print a line saying "Scenario #k", where k is the number of the test case. Then, for each DEQUEUE command, print the person who just gets a ticket on a single line. Print a blank line between two test cases, but no extra line at the end of output.n nnSample Inputn2n3 Ann Bob Joen3 Zoe Jim FatnENQUEUE AnnnENQUEUE ZoenENQUEUE BobnENQUEUE JimnENQUEUE JoenENQUEUE FatnDEQUEUEnDEQUEUEnDEQUEUEnDEQUEUEnDEQUEUEnDEQUEUEnSTOPn2n5 Anny Jack Jean Bill Janen6 Eva Mike Ron Sony Geo ZoronENQUEUE AnnynENQUEUE EvanENQUEUE JacknENQUEUE JeannENQUEUE BillnENQUEUE JanenDEQUEUEnDEQUEUEnENQUEUE MikenENQUEUE RonnDEQUEUEnDEQUEUEnDEQUEUEnDEQUEUEnSTOP n0n nnSample OutputnScenario #1 nAnnnBobnJoenZoenJimnFatnnScenario #2 nAnnynJacknJeannBillnJanenEva

Jumping Hands


Problem DescriptionnIn Shanghai, there are some famous clock towers built more than 100 years ago, such as the office building of Shanghai Customs, Xujiahui Church, etc. Every clock tower’s clock-face consists of three hands: an hour hand, a minute hand, and a second hand. The hands do not move smoothly as time passing. When a second passes, the hands jump to the next place clockwise: the second hand moves 1/60 ring, the minute hand moves 1/3600 ring and the hour hand moves 1/43200 ring.nnWe assume that every hand’s mass is evenly distributed, and its thickness can be ignored. In other words, every hand’s centre of gravity is at the middle position of the respective hand. Suppose p1, p2 and p3 are, respectively, the position of the centre of gravity of the hour hand, that of the minute hand, and that of the second hand. The position of all three hands’ centre of gravity, P, is the average of p1, p2 and p3 weighted by the hands’ mass.nnSuppose P1 and P2 are the positions of the three hands’ centre of gravity at the start time and at the end time, respectively. Your task is to calculate the length of the path from P1 to P2. That is, if P3 is the position of the three hands’ centre of gravity on the clock-face at a point of time between start time and end time, X is the length of the path from P1 to P3, and Y is the length of the path from P3 to P2, the length of the path from P1 to P2 is X+Y.n nnInputnInput consists of one or more lines, each line describing one data set. Each line begins with 6 integers: L1, L2, L3, M1, M2, M3, followed by start time and end time. L1, L2 and L3 indicate the lengths of hour hand, minute hand and second hand respectively, where 1≤L1

Jumping Hero


A software house has decided to create a computer game, where the hero must find its way from a start position to the end position, through a labyrinth. In the labyrinth, some cells contain magic fountains that can be used to get super-powers an infinite number of times. Whenever the hero enters a cell with a magic fountain, he gets super-powers.nnUsually, our hero moves in the labyrinth one cell left/right/up/down at a time (to an empty cell). With super-powers, the hero jumps to an empty cell N positions to the left/right/up/down. The super-power lasts for M jumps, and the hero can change its jumping direction after each jump. A jump is allowed if the end cell of the jump is within the map and it is not a wall �C thus, the hero can jump over walls. If the hero jumps to a cell with a new magic fountain, the hero gets the super-powers of the new magic fountain, and the remaining effect of the previous magic fountain is cancelled. If the hero jumps to the cell where he obtained its current super-powers, no effect occurs (i.e., the hero gets no additional super-powers). When the current super-power ends, the hero proceeds its normal one-cell movement. If, after getting super-powers in some fountain, the hero cannot move to any cell, he looses his super-powers and returns to his previous cell. To reach the end position, the hero must move to the end cell or finish one jump in the end cell.nnGiven the labyrinth map compute the minimum number of moves/jumps from the start position to the end position.nnInputnnA positive integer P in a single line followed by a sequence of P labyrinth maps. The first line of each labyrinth map contains two positive integers, L and C, separated by an empty space, with L the number of lines and C the number of columns in the map. L and C are both lesser than 300. The following L lines of the input contain C integers each that define the cells of the map (separated by a empty space). Each integer, i, must be interpreted as follows: i = 0 represents a wall; i = 1 represents an empty cell (where the hero can move into); i = M*10+N represents an empty cell with a magic fountain that makes the hero jump M times to the cell that is N positions to the left/right/up/down of the current cell. M ranges from 1 to 5 and N ranges from 2 to 6. The maximum number of magic fountains in a map is 5,000. The two last lines of the input define the coordinates of the start position and end position (coordinates consist of two integers, denoting the line and column respectively, starting from 0).nnOutputnnThe output consists of one single line that contains an integer with the minimum number of moves/jumps, from the start position to the end position. If it is impossible to reach the end position, the output should be a single line containing IMPOSSIBLE.nnSample Inputnn1n8 8n0 1 1 1 1 1 1 1n0 1 0 0 1 13 1 1n0 1 32 1 1 1 0 0n0 1 1 0 1 1 1 0n0 1 1 0 0 0 0 0n0 1 1 1 1 1 1 0n0 1 0 0 1 1 1 0n0 1 1 1 1 1 1 0n1 7n5 4nSample Outputnn14n

Jumping Frogs


DescriptionnnRecently, Lambert has been interested in a Flash game called Jumping Frogs. The game proceeds as follows. On r-by-c grid board, there n frogs each occupying a separate cell. In each move, a frog jumps in one of the eight rectilinear and diagonal directions, flies over a neighboring frog, and lands in an empty cell at a distance of two. The frog having been flown over is then removed from the board. The goal is to remove all but one frog.nnAfter a few attempts, Lambert finds the game too difficult for him. Therefore, he finds himself a slightly different version of the game, which allows a frog to jump to an empty cell at a distance of three without removing any other frogs from the board. To compensate such a reduction in difficulty, it is additionally required that an ending cell be specified by the player before the game starts. Upon completion of the game, the remaining frog is required to be in the ending cell. With relaxed rules of jumping, Lambert is now able to remove all but one frog. But sometimes he finds that he cannot place that remaining frog in the specified ending cell. Given a starting configuration of the game and the ending cell specified by Lambert, can you tell whether the game can be completed?nnInputnnThe input contains multiple test cases. Each test case begins with a line containing five positive integers n, r, c, x and y (n ≤ 10; 3 ≤ r, c ≤ 10; x ≤ r; y ≤ c). Lambert specifies the cell in the x-th row and y-th column as the ending cell. Then come n lines each containing a pair of positive integers xi and yi (xi ≤ r; yi ≤ c), indicating a frog in the cell in the xi-row and yi-column. The input ends once EOF is met.nnOutputnnFor each test case, output one line containing “Yes” if the game can be completed or “No” otherwise.nnSample Inputnn2 3 3 1 1n2 2n3 3n2 3 3 1 1n1 1n2 2nSample OutputnnYesnNo


  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他