Skip to content

Commit 80a2f0b

Browse files
committed
103차 1번 문제풀이
1 parent 7e543e1 commit 80a2f0b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const input = require("fs")
2+
.readFileSync(
3+
process.platform === "linux"
4+
? "/dev/stdin"
5+
: require("path").join(__dirname, "input.txt"),
6+
"utf8"
7+
)
8+
.toString()
9+
.trim()
10+
.split("\n")
11+
.map((line) => line.split(" ").map(Number));
12+
13+
function solution(input) {
14+
const N = input[0][0];
15+
const G = input.slice(1);
16+
17+
for (let k = 0; k < N; k++)
18+
for (let i = 0; i < N; i++)
19+
for (let j = 0; j < N; j++) if (G[i][k] && G[k][j]) G[i][j] = 1;
20+
21+
return G.map((row) => row.join(" ")).join("\n");
22+
}
23+
24+
console.log(solution(input));

0 commit comments

Comments
 (0)