diff --git a/code_study/Baekjoon/python/9295.py b/code_study/Baekjoon/python/9295.py new file mode 100644 index 0000000..bd611a2 --- /dev/null +++ b/code_study/Baekjoon/python/9295.py @@ -0,0 +1,4 @@ +import sys +input = sys.stdin.readline +for i in range(1, int(input())+1) : + print(f"Case {i}:",sum(map(int, input().split()))) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/9252.ts b/code_study/Baekjoon/ts/9252.ts new file mode 100644 index 0000000..c365713 --- /dev/null +++ b/code_study/Baekjoon/ts/9252.ts @@ -0,0 +1,35 @@ +export {}; +const [s1, s2]: string[] = require("fs").readFileSync(0).toString().trim().split("\n"); +const [l1, l2]: number[] = [s1.length, s2.length]; + +let dp: number[][] = Array.from({length: l1+1}, () => new Array(l2+1).fill(0)); + +for(let i=1; i<=l1; i++) { + let c1: string = s1[i-1]; + + for(let j=1; j<=l2; j++) { + let c2: string = s2[j-1]; + if(c1 === c2) dp[i][j] = dp[i-1][j-1] + 1; + else dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]); + } +} + +console.log(dp[l1][l2]); + +if(dp[l1][l2] !== 0) { + let [p1, p2]: number[] = [l1, l2]; + let result: string[] = []; + + while(!(p1===0 || p2===0)) { + const [c1, c2]: string[] = [s1[p1-1], s2[p2-1]]; + + if(dp[p1][p2] === dp[p1][p2-1]) p2--; + else if(dp[p1][p2] === dp[p1-1][p2]) p1--; + else { + result.push(c1); + p1--; p2--; + } + } + + console.log(result.reverse().join("")); +} \ No newline at end of file