1 5 5 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
25
import java.util.Arrays;
import java.util.Scanner;
public class NYOJ10_ieayoio {
public static int [][]map;
public static int [][]f;
public static int []dx={0,1,0,-1,0};
public static int []dy={0,0,-1,0,1};
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
while (t-->0){
int n=input.nextInt();
int m=input.nextInt();
map=new int [n+5][m+5];
for (int i=0;i挺高興的一直感覺沒把握做的題,做了兩天,經過調試通過樣例後,沒想到一次性提交就過了
方法就是深搜,不過就是加了一個數組f[x][y],來保存點(x,y)可滑到最低點的最長距離,dfs(x,y)用來深搜這個距離,若f[x][y]已存在,則將函數的值直接返回為f[x][y],
isnoway函數式來判斷點(x,y)是否可以向更低點滑行