Oh, ah, ah ah, it's Wednesday today?
So, let's get a few more.
Address http://www.luogu.org/problem/show?pid=1006
Description of the paper-passing note
Obuchi and Xiao Xuan are good friends and classmates, they always have to talk about endless topics. A quality expansion activities, the class arranged to make a M-row N-column matrix, and Obuchi and small Xuan is arranged at both ends of the matrix diagonal, so they can not directly talk. Fortunately, they can communicate by passing a note. The note to pass through many students to the other hand, Obuchi sitting in the upper left corner of the matrix, coordinates (at a), the small Xuan sits in the bottom right corner of the matrix, coordinates (M,N). From the Obuchi to the small Xuan note can only be passed down or to the right, from the small Xuan to Obuchi note can only be passed up or to the left.
In the activity, Obuchi hope to send a note to the small Xuan, at the same time hope that the small Xuan to reply to him. Every classmate in the class can help them pass, but will only help them once, that is, if the person in the Obuchi hand to the small Xuan Note when help, then in the small Xuan handed to Obuchi when will not help. Vice versa.
There is one more thing to pay attention to, the class each classmate is willing to help a high degree of good and low (note: Obuchi and small Xuan's kindness degree is not defined, input with 0), you can use a 0-100 natural number to express, the greater the number of the more kindness. Obuchi and small Xuan hope as far as possible to find good-hearted students to help pass the note, that is, to find two ways to pass the path, so that the two path to the kindness of the students and the largest. Now, please help Obuchi and Xiao Xuan to find such two paths.
Input/output format
Input format:
The first line of the input file message.in has 2 integers m and n separated by spaces, indicating that there are m rows n columns (1<=m,n<=50) in the class.
The next M-line is a m*n matrix, and the integer in row J of the matrix indicates the kindness of the student sitting in row J of line I. Each row is separated by a space between n integers.
Output format:
The output file message.out a common line that contains an integer that represents the maximum value of the sum of the kindness of the student who is involved in passing the note back and forth on both paths.
Input and Output Sample input example # #:
3 30 3 92 8 55 7 0
Sample # # of output:
34
Description
Limit
30% of the data meet: 1<=m,n<=10
100% of the data meet: 1<=m,n<=50
NOIP 2008 Raising the third question of the group
------------------------------Split Line Bacteria tip you will have a train arriving in a minute (Hiu) Oh-----------------------------------
This question is used for dine ...
The classic question of motion rules, must do
It is probably to think of the note as from the same starting point, and then a two-dimensional combination of thinking is good (said a fart AH)
The code is not annotated (Hello!) )
#include <stdio.h>#include<stdlib.h>#include<string.h>#defineF (i,x,y) for (int (i) = (x);(i) <= (y);(i) + +)#defineMax (x, y) > (y)? (x):(y)intdp[Wuyi][Wuyi][Wuyi][Wuyi],lk[Wuyi][Wuyi];intMain () {intM,n; scanf ("%d%d",&m,&N); F (i,1, M) F (J,1, N) scanf ("%d",&Lk[i][j]); Memset (DP,0,sizeof(DP)); F (i,1, M) F (J,1, N) F (II,1, m) F (JJ,1, N) {DP[I][J][II][JJ]=max (dp[i][j][ii][jj],dp[i-1][j][ii-1][JJ]); DP[I][J][II][JJ]=max (dp[i][j][ii][jj],dp[i-1][j][ii][jj-1]); DP[I][J][II][JJ]=max (dp[i][j][ii][jj],dp[i][j-1][ii][jj-1]); DP[I][J][II][JJ]=max (dp[i][j][ii][jj],dp[i][j-1][ii-1][JJ]); DP[I][J][II][JJ]+=lk[i][j]+LK[II][JJ]; if(I==II&&J==JJ) dp[i][j][ii][jj]-=Lk[i][j]; } printf ("%d", Dp[m][n][m][n]); return 0;}
Then write the next one!
NOIP 2008 Improvement Group The third problem by rLq