Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.LinkedList;
- import java.util.Scanner;
- public class ccc08s3_2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- // + north south west east
- // | north south
- // - west east
- //step 00 to R-1 C-1
- // 3
- // 5
- // +||*+
- // +++|+
- // **--+
- Scanner sc = new Scanner(System.in);
- int R = sc.nextInt(); //amount of row
- int C = sc.nextInt(); //amount of col
- char[][] maze = new char[R][C];
- for (int r=0; r<R; r++) {
- maze[r] = sc.next().toCharArray();
- }
- int[][] step = new int[R][C];
- for (int r=0; r<R; r++) {
- Arrays.fill(step, Integer.MAX_VALUE);
- }
- LinkedList<Integer> rQ = new LinkedList<Integer>();
- LinkedList<Integer> cQ = new LinkedList<Integer>();
- //initialize the first location
- rQ.add(0);
- cQ.add(0);
- step[0][0] = 1;
- while(!rQ.isEmpty()) {
- int r = rQ.poll();
- int c = cQ.poll();
- //get neighbors
- if (maze[r][c]=='+' || maze[r][c]=='|') {
- //2 neighbor up and down
- }
- if (maze[r][c]=='+' || maze[r][c]=='-') {
- //2 neighbor left and right
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement