`
gsh457rk
  • 浏览: 15337 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

1154_java

 
阅读更多

1154_java
2011年03月01日
   import java.io.BufferedReader; 
  import java.io.InputStreamReader; 
  import java.util.Scanner; 
  public class Main { 
  private static String[] a = null; 
  private static int max = -1; 
  private static int n = 0; 
  private static int m = 0; 
  private static void dfs(int x, int y, char[] c, int current) { 
  boolean find = false; 
  for (int i = 0; i = 0) { 
  dfs(x - 1, y, c, current + 1); 
  } 
  if (x + 1 = 0) { 
  dfs(x, y - 1, c, current + 1); 
  } 
  if (y + 1 < m) { 
  dfs(x, y + 1, c, current + 1); 
  } 
  } 
  /** 
  * @param args 
  */ 
  public static void main(String[] args) throws Exception { 
  BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); 
  String line = stdin.readLine(); 
  String[] temp = line.split("[ ]+"); 
  n = Integer.parseInt(temp[0]); 
  m = Integer.parseInt(temp[1]); 
  a = new String[n + 1]; 
  for (int i = 0; i < n; i++) { 
  a[i] = stdin.readLine(); 
  } 
  char[] c = new char[30]; 
  dfs(0, 0, c, 0); 
  System.out.println(max); 
  } 
  } 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics