Skip to content

Commit 0c053cf

Browse files
author
Eric
committed
104차 2번 문제풀이
1 parent 0c9531b commit 0c053cf

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n');
6+
7+
function solution(input) {
8+
const N = Number(input[0]);
9+
const relations = input.slice(1).map((line) => line.split(''));
10+
11+
let max = 0;
12+
13+
for (let i = 0; i < N; i++) {
14+
const set = new Set();
15+
16+
for (let j = 0; j < N; j++) {
17+
if (i === j) continue;
18+
19+
if (relations[i][j] === 'Y') {
20+
set.add(j);
21+
} else {
22+
for (let k = 0; k < N; k++) {
23+
if (relations[i][k] === 'Y' && relations[k][j] === 'Y') {
24+
set.add(j);
25+
break;
26+
}
27+
}
28+
}
29+
}
30+
31+
max = Math.max(max, set.size);
32+
}
33+
return max;
34+
}
35+
36+
console.log(solution(input));

0 commit comments

Comments
 (0)