From f0ead9ce242166260520353f4e3b9bc3476e3286 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Sat, 27 Sep 2025 21:18:26 +0900 Subject: [PATCH] 20250927 baekjoon --- code_study/Baekjoon/ts/1987.ts | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 code_study/Baekjoon/ts/1987.ts diff --git a/code_study/Baekjoon/ts/1987.ts b/code_study/Baekjoon/ts/1987.ts new file mode 100644 index 0000000..045b9b1 --- /dev/null +++ b/code_study/Baekjoon/ts/1987.ts @@ -0,0 +1,35 @@ +export {}; + +const input: string[] = require("fs").readFileSync(0).toString().trim().split('\n'); +const [R, C]: number[] = input[0].split(' ').map(Number); + +let board: string[][] = []; +for(let i=1; i<=R; i++) { + board.push(input[i].split('')); +} + +let alphabet: boolean[] = new Array(26).fill(false); +alphabet[board[0][0].charCodeAt(0) - 65] = true; +let maxStep: number = 1; + +const dx: number[] = [1,-1,0,0]; +const dy: number[] = [0,0,1,-1]; + +const dfs = ([cx, cy, cs]: number[]) => { + maxStep = Math.max(cs, maxStep); + + for(let i=0; i<4; i++) { + const nx = cx + dx[i]; + const ny = cy + dy[i]; + + if(0<=nx && nx