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>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"