# Memory Search Topics

Source: Internet
Author: User

HDOJ 1078 Topic Footprints

Test instructions

N*n matrix, starting from (0,0), each point has a value, each can only horizontal or vertical to go to the maximum of K lattice, the total number of lines required is strictly monocytogenes, and the total and maximum.

Code:

`1#include <cstdio>2#include <iostream>3#include <algorithm>4#include <cstring>5     #defineMem (A, B) memset (A,b,sizeof (a))6     #defineForp (i,n) for (int i=0;i<n;i++)7 8     Const intMAXN = the;9     intN, K;Ten     int_M[MAXN][MAXN]; One     intDP[MAXN][MAXN]; A     intdi[4][2] = {1,0,-1,0,0,1,0,-1}; -     //direction -     intDfsintXinty) { the         intMaxx =0; -         //record the current layer maximum value -         intxx, yy, ans; -         if(!Dp[x][y]) { + Forp (i,k) { -Forp (J,4){ +xx = x + di[j][0]* (i+1); Ayy = y + di[j][1]* (i+1); at                     if(XX >=0&& xx < n && yy >0&& yy < n && _m[xx][yy] >_m[x][y]) { -Ans = DFS (XX,YY);//value of Dp[xx][yy] -                         if(Ans >Maxx) -Maxx =ans; -                     } -                 } in             } -Dp[x][y] = Maxx +_m[x][y]; to         } +printf"%d%d%d\n", X,y,dp[x][y]); -         returnDp[x][y]; the     } *  \$     intMain () {Panax NotoginsengMem (_m,0); -          while(~SCANF ("%d%d",&n,&k)) { the             if(n = =-1&& k = =-1) +                  Break; A Forp (i,n) the Forp (j,n) +scanf"%d",&_m[i][j]); -             //data read-in \$MEM (DP,0); \$             intsum = DFS (0,0); -             //search starting from 0 o'clock -printf"%d\n", sum); the         } -}`

Memory Search Topics

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.