diff --git "a/khj20006/202502/04 BOJ G1 \353\241\234\353\264\207 \354\262\255\354\206\214\352\270\260.md" "b/khj20006/202502/04 BOJ G1 \353\241\234\353\264\207 \354\262\255\354\206\214\352\270\260.md" new file mode 100644 index 00000000..467619b2 --- /dev/null +++ "b/khj20006/202502/04 BOJ G1 \353\241\234\353\264\207 \354\262\255\354\206\214\352\270\260.md" @@ -0,0 +1,125 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + static int[] dx = {1,0,-1,0}; + static int[] dy = {0,1,0,-1}; + static int INF = (int)1e8 + 1; + + static int H, W; + static int[][] dist; + static char[][] arr; + static int[] X; + static int[] Y; + static int ans; + + static void initialize() { + dist = new int[11][11]; + arr = new char[H][W]; + X = new int[11]; + Y = new int[11]; + for(int i=0;i<=10;i++) Arrays.fill(dist[i], INF); + ans = INF; + } + + static boolean inside(int x, int y) { + return 0<=x&&x Q = new LinkedList<>(); + Q.offer(new int[] {X[s],Y[s],0}); + while(!Q.isEmpty()) { + int[] now = Q.poll(); + int x = now[0], y = now[1], t = now[2]; + if('A' <= arr[x][y] && arr[x][y] <= 'Z') { + dist[s][arr[x][y]-'A'] = t; + } + for(int i=0;i<4;i++) { + int xx = x+dx[i], yy = y+dy[i]; + if(inside(xx,yy) && !vis[xx][yy] && arr[xx][yy] != 'x') { + Q.offer(new int[] {xx,yy,t+1}); + vis[xx][yy] = true; + } + } + } + } + + static void exSearch(int cnt, int choose, int now, int prev, int time, int limit) { + if(cnt == limit) { + ans = Math.min(ans, time); + return; + } + for(int i=1;i<=limit;i++) { + if((choose & (1<= INF) bw.write("-1\n"); + else bw.write(ans+"\n"); + + } + + public static void main(String[] args) throws Exception { + + nextLine(); + W = nextInt(); + H = nextInt(); + while(H != 0) { + solve(); + nextLine(); + W = nextInt(); + H = nextInt(); + } + + + bwEnd(); + } + +} + +```