diff --git "a/lkhyun/202502/05 BOJ \352\263\250\353\223\2342 \353\223\261\354\202\260.md" "b/lkhyun/202502/05 BOJ \352\263\250\353\223\2342 \353\223\261\354\202\260.md" new file mode 100644 index 00000000..e3dbd2de --- /dev/null +++ "b/lkhyun/202502/05 BOJ \352\263\250\353\223\2342 \353\223\261\354\202\260.md" @@ -0,0 +1,90 @@ +```java +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.*; + +public class Main { + static BufferedReader br; + static BufferedWriter bw; + public static void main(String[] args) throws Exception { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + int T = Integer.parseInt(st.nextToken()); + int D = Integer.parseInt(st.nextToken()); + + int[][] map = new int[N][M]; + for(int n=0;n=97 && c<=122){ + map[n][temp++] = c-'a' + 26; + } + else{ + map[n][temp++] += c-'A'; + } + } + } + + long[][] shortpath = new long[N*M][N*M]; + for(int i=0;i= 0 && newi < N && newj >= 0 && newj < M){ + int height = map[newi][newj] - map[i][j]; + if(Math.abs((double)height) > T){continue;} + if(height >= 0){//높은 곳에서 아래로 이동 + shortpath[newi*M+newj][i*M+j] = 1; + shortpath[i*M+j][newi*M+newj] = (int)Math.pow(height,2); + } + else{ + shortpath[newi*M+newj][i*M+j] = (int)Math.pow(height,2); + shortpath[i*M+j][newi*M+newj] = 1; + } + + } + } + } + } + for(int x=0;x