UVa 10285 longest Run on a Snowboard "Memory Search"

Source: Internet
Author: User

Test instructions: As with the longest ski path,

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One #definemod=1e9+7; A using namespacestd; -  -typedefLong LongLL; the Const intmaxn= the; - intG[MAXN][MAXN],VIS[MAXN][MAXN],D[MAXN][MAXN]; - intdir[4][2]={-1,0,1,0,0,-1,0,1}; - intn,m; +  - intDfsintXinty) { +     if(D[x][y])returnD[x][y];//If this has already been searched, then return directly without repeating the calculation A     intans=0; at      for(intI=0;i<4; i++) {//Search in four directions -         intnx=x+dir[i][0]; -         intny=y+dir[i][1]; -         if(nx<1|| nx>n| | ny<1|| NY&GT;M)Continue;//Out of bounds -         if(g[x][y]>G[nx][ny]) -Ans=max (ans,1+DFS (Nx,ny)); in     } -      to     if(ans==0)returnd[x][y]=1; +     returnd[x][y]=ans;  - } the  * intMain () { $     intncase,r,c;Panax Notoginseng     CharS[MAXN]; -scanf"%d",&ncase); the      while(ncase--){ +Cin>>s; ACin>>n>>m; the      +      for(intI=1; i<=n;i++) -          for(intj=1; j<=m;j++) cin>>G[i][j]; $          $memset (D,0,sizeof(d)); -         inttmp=0; -                  the          for(intI=1; i<=n;i++){ -              for(intj=1; j<=m;j++)Wuyitmp=Max (Tmp,dfs (i,j)); the         }        -printf"%s:%d\n", s,tmp); Wu     } -     return 0;  About}
View Code

Alas = = self-knocks again = = run out is wrong, and according to the previous written

It's really a blast. = = If not later, you have to knock on the gas---go---go--go

UVa 10285 longest Run on a Snowboard "Memory Search"

Contact Us

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.