diff --git a/code_study/Baekjoon/python/10768.py b/code_study/Baekjoon/python/10768.py new file mode 100644 index 0000000..80af2c3 --- /dev/null +++ b/code_study/Baekjoon/python/10768.py @@ -0,0 +1 @@ +print((lambda m, d : "Before" if m == 1 else "After" if m > 2 else "Special" if d == 18 else "Before" if d < 18 else "After")(int(input()), int(input()))) \ No newline at end of file diff --git a/code_study/Baekjoon/ts/16724.ts b/code_study/Baekjoon/ts/16724.ts new file mode 100644 index 0000000..139f312 --- /dev/null +++ b/code_study/Baekjoon/ts/16724.ts @@ -0,0 +1,50 @@ +export {}; +const input = require("fs").readFileSync(0).toString().trim().split('\n'); +const [N, M]: number[] = input[0].split(" ").map(Number); +let field: string[] = []; +for(let i=1; i<=N; i++) field.push(input[i]); + +let parents: number[] = Array.from({length: N*M}, (_, i) => i); +let rank: number[] = new Array(N*M).fill(0); +const areaNum = (col: number, row: number): number => { return M*row + col; } + +const find = (x: number): number => { + if(x !== parents[x]) return parents[x] = find(parents[x]); + return parents[x]; +} + +const union = (x: number, y: number) => { + x = find(x); + y = find(y); + + if(x===y) return; + + if(rank[x] < rank[y]) { + const temp = x; + x = y; + y = temp; + } + + parents[y] = x; + + if(rank[x] === rank[y]) rank[x]++; +} + +for(let x=0; x { if(v===i) ans += 1 }); +console.log(ans);