๐ ํ ๋ฐฉํฅ์ผ๋ก๋ง ๊ฐ ์ ์๋ค.
๐ ์ฒ์์ ์๊ฐ์ด๊ณผ๊ฐ ๋ฐ์ํ๋๋ฐ ์นธ์ 0์ด ์ฐ์ฌ์ง ๊ฒฝ์ฐ๋ฅผ ์ฒ๋ฆฌ๋ฅผ ์ํด์ ๋ฌดํ ๋ฃจํ์ ๋น ์ ธ์ ๊ทธ๋ฐ ๋ฏ ํ๋ค.
์ฝ๋
const fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().trim().split('\n');
const N = +input.shift();
input = input.map((item) => item.split(" ").map(Number));
const checked = [];
const willCheck = [[0, 0]];
const dir = [
[0, 1],
[1, 0],
];
while (willCheck.length) {
const [pointY, pointX] = willCheck.shift();
if (!checked.includes([pointY, pointX])) {
checked.push([pointY, pointX]);
const count = input[pointY][pointX];
if (count !== 0) {
for (let i = 0; i < 2; i++) {
const nextY = pointY + dir[i][0] * count;
const nextX = pointX + dir[i][1] * count;
if (nextY === N - 1 && nextX === N - 1) {
return console.log("HaruHaru");
}
if (nextX < N && nextY < N) {
willCheck.push([nextY, nextX]);
}
}
}
}
}
console.log("Hing");