Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.LinkedList;
  3. import java.util.Scanner;
  4.  
  5. public class ccc08s3_2 {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9. // + north south west east
  10. // | north south
  11. // - west east
  12. //step 00 to R-1 C-1
  13. // 3
  14. // 5
  15. // +||*+
  16. // +++|+
  17. // **--+
  18.  
  19. Scanner sc = new Scanner(System.in);
  20. int R = sc.nextInt(); //amount of row
  21. int C = sc.nextInt(); //amount of col
  22.  
  23. char[][] maze = new char[R][C];
  24. for (int r=0; r<R; r++) {
  25. maze[r] = sc.next().toCharArray();
  26. }
  27.  
  28. int[][] step = new int[R][C];
  29. for (int r=0; r<R; r++) {
  30. Arrays.fill(step, Integer.MAX_VALUE);
  31. }
  32.  
  33. LinkedList<Integer> rQ = new LinkedList<Integer>();
  34. LinkedList<Integer> cQ = new LinkedList<Integer>();
  35. //initialize the first location
  36. rQ.add(0);
  37. cQ.add(0);
  38. step[0][0] = 1;
  39.  
  40. while(!rQ.isEmpty()) {
  41. int r = rQ.poll();
  42. int c = cQ.poll();
  43. //get neighbors
  44. if (maze[r][c]=='+' || maze[r][c]=='|') {
  45. //2 neighbor up and down
  46. }
  47.  
  48. if (maze[r][c]=='+' || maze[r][c]=='-') {
  49. //2 neighbor left and right
  50. }
  51.  
  52. }
  53.  
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement