Skip to content

Commit 05ebf7a

Browse files
[BOJ] 9655 돌 게임 (S5)
1 parent 9e17838 commit 05ebf7a

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

서정우/10주차/260304.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const fs = require("fs");
2+
const filePath =
3+
process.platform === "linux" ? "/dev/stdin" : "./서정우/input.txt";
4+
const input = fs
5+
.readFileSync(filePath)
6+
.toString()
7+
.trim()
8+
.split("\n")
9+
.map((el) => el.trim());
10+
11+
const [N, M] = input[0].split(" ").map(Number);
12+
13+
const dp = new Array(N + 1).fill(false);
14+
dp[1] = true;
15+
dp[3] = true;
16+
17+
for (let i = 2; i <= N; i++) {
18+
if (i - 1 >= 0 && !dp[i - 1]) {
19+
dp[i] = true;
20+
} else if (i - 3 >= 0 && !dp[i - 3]) {
21+
dp[i] = true;
22+
}
23+
}
24+
25+
console.log(dp[N] ? "SK" : "CY");

서정우/input.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
8 10
2-
2 2 2 2 11 2 5 2
1+
5

0 commit comments

Comments
 (0)