From 55246b33a007464992ef10f6d7c82ad7d33d8617 Mon Sep 17 00:00:00 2001 From: jinoo Date: Mon, 7 Apr 2025 23:45:44 +0900 Subject: [PATCH 1/3] =?UTF-8?q?104=EC=B0=A8=201=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\241\260\354\247\204\354\232\260.js" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "live10/test104/\353\254\270\354\240\2341/\354\241\260\354\247\204\354\232\260.js" diff --git "a/live10/test104/\353\254\270\354\240\2341/\354\241\260\354\247\204\354\232\260.js" "b/live10/test104/\353\254\270\354\240\2341/\354\241\260\354\247\204\354\232\260.js" new file mode 100644 index 00000000..606fa119 --- /dev/null +++ "b/live10/test104/\353\254\270\354\240\2341/\354\241\260\354\247\204\354\232\260.js" @@ -0,0 +1,36 @@ +const input = require("fs") + .readFileSync( + process.platform === "linux" + ? "/dev/stdin" + : require("path").join(__dirname, "input.txt"), + "utf8" + ) + .toString() + .trim() + .split("\n") + .map(Number); + +function solution(input) { + const T = input[0]; + const N = input.slice(1); + const dp = []; + const result = []; + dp[0] = 0; + dp[1] = 1; + dp[2] = 1; + dp[3] = 1; + dp[4] = 2; + dp[5] = 2; + + for (let i = 6; i <= Math.max(...N); i++) { + dp[i] = dp[i - 1] + dp[i - 5]; + } + + for (let i = 0; i < T; i++) { + result[i] = dp[N[i]]; + } + + return result.join("\n"); +} + +console.log(solution(input)); From 0e69dccf30fef12423dc3637b8d30c375c0d6cbf Mon Sep 17 00:00:00 2001 From: jinoo Date: Wed, 9 Apr 2025 04:29:10 +0900 Subject: [PATCH 2/3] =?UTF-8?q?104=EC=B0=A8=202=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\241\260\354\247\204\354\232\260.js" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "live10/test104/\353\254\270\354\240\2342/\354\241\260\354\247\204\354\232\260.js" diff --git "a/live10/test104/\353\254\270\354\240\2342/\354\241\260\354\247\204\354\232\260.js" "b/live10/test104/\353\254\270\354\240\2342/\354\241\260\354\247\204\354\232\260.js" new file mode 100644 index 00000000..80b2f5e3 --- /dev/null +++ "b/live10/test104/\353\254\270\354\240\2342/\354\241\260\354\247\204\354\232\260.js" @@ -0,0 +1,43 @@ +const input = require("fs") + .readFileSync( + process.platform === "linux" + ? "/dev/stdin" + : require("path").join(__dirname, "input.txt"), + "utf8" + ) + .toString() + .trim() + .split("\n") + .map((line) => line.split("")); + +function solution(input) { + const N = Number(input[0].join("")); + const friends = input.slice(1); + let maxCount = 0; + + for (let i = 0; i < N; i++) { + const visited = Array(N).fill(false); + + for (let j = 0; j < N; j++) { + if (i === j) continue; + + if (friends[i][j] === "Y") { + visited[j] = true; + } else { + for (let k = 0; k < N; k++) { + if (friends[i][k] === "Y" && friends[k][j] === "Y") { + visited[j] = true; + break; + } + } + } + } + + const count = visited.filter(Boolean).length; + maxCount = Math.max(maxCount, count); + } + + return maxCount; +} + +console.log(solution(input)); From f7149917f7ed9bc3e6adaa82391e448e78c4911f Mon Sep 17 00:00:00 2001 From: jinoo Date: Wed, 9 Apr 2025 04:29:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?104=EC=B0=A8=203=EB=B2=88=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=ED=92=80=EC=9D=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\354\241\260\354\247\204\354\232\260.js" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "live10/test104/\353\254\270\354\240\2343/\354\241\260\354\247\204\354\232\260.js" diff --git "a/live10/test104/\353\254\270\354\240\2343/\354\241\260\354\247\204\354\232\260.js" "b/live10/test104/\353\254\270\354\240\2343/\354\241\260\354\247\204\354\232\260.js" new file mode 100644 index 00000000..3fbee1de --- /dev/null +++ "b/live10/test104/\353\254\270\354\240\2343/\354\241\260\354\247\204\354\232\260.js" @@ -0,0 +1,32 @@ +function solution(begin, target, words) { + let visit = []; + let box = []; + box.push([begin, 0]); + + while (box.length > 0) { + let now = box.shift(); + let txt = now[0]; + let cnt = now[1]; + + if (txt === target) { + return cnt; + } + + for (let i = 0; i < words.length; i++) { + let word = words[i]; + let diff = 0; + for (let j = 0; j < word.length; j++) { + if (txt[j] !== word[j]) { + diff++; + } + } + + if (diff === 1 && !visit.includes(word)) { + visit.push(word); + box.push([word, cnt + 1]); + } + } + } + + return 0; +}