Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- js ์ค์ฝํ
- ์ค์ฝํ
- suspense ๋น๋๊ธฐ
- ์ฌ์ฉ์ฑ ๊ฐ์
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ๋ฐฑ์ค 2108 nodejs
- suspense react-query
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- suspense ๋ณ๋ชฉํ์
- js ๋ฌธ์์ด ์์ถ
- ๊ตฌ๋ฆํค
- js
- ์ต์ ๋์ฒด์ด๋
- ์นด์นด์ค ์ฝํ
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ๋ฐฑ์ค 1339๋ฒ js
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- next13 emotion
- emtion app router
- emotion RSC
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- suspense ๋์์๋ฆฌ
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- app router emotion
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 14503๋ฒ] ๋ก๋ด์ฒญ์๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 14503๋ฒ] ๋ก๋ด์ฒญ์๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 4. 30. 14:42728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/14503
const { SocketAddress } = require('net');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
rl.on('line', function (line) {
input.push(line);
if (input.length === +input[0].split(' ')[0] + 2) {
input = input.map((v) => v.split(' ').map(Number));
rl.close();
}
}).on('close', function () {
const [x, y] = input.shift().map((v) => +v + 1);
let [r, c, d] = input.shift().map(Number);
let answer = 1;
let count = 0;
input[r][c] = 'v';
while (r > 0 && c > 0 && r <= x && c <= y) {
if (count === 4) {
if (d === 0) {
if (input[r + 1][c] === 1) {
break;
}
r++;
} else if (d === 1) {
if (input[r][c - 1] === 1) {
break;
}
c--;
} else if (d === 2) {
if (input[r - 1][c] === 1) {
break;
}
r--;
} else if (d === 3) {
if (input[r][c + 1] === 1) {
break;
}
c++;
}
count = 0;
}
if (d === 0) {
if (input[r][c - 1] !== 0) {
d = 3;
count++;
} else {
d = 3;
c--;
input[r][c] = ++answer;
count = 0;
}
} else if (d === 1) {
if (input[r - 1][c] !== 0) {
d = 0;
count++;
} else {
d = 0;
r--;
input[r][c] = ++answer;
count = 0;
}
} else if (d === 2) {
if (input[r][c + 1] !== 0) {
d = 1;
count++;
} else {
d = 1;
c++;
input[r][c] = ++answer;
count = 0;
}
} else if (d === 3) {
if (input[r + 1][c] !== 0) {
d = 2;
count++;
} else {
d = 2;
r++;
input[r][c] = ++answer;
count = 0;
}
}
}
console.log(answer);
});
๋์๋จ๋ถ์ ๋๋ ์ ๊ท์น์ ๋ง๊ฒ ์ผ์ชฝ์ผ๋ก ๋๋ฉด์ ์ฒญ์ํ๋ฉด ๋๋ค!
count(ํ์ ์)๊ฐ 4์ด๊ณ ๋ค์ ๋ฒฝ์ด ์์ผ๋ฉด ํ๋ก๊ทธ๋จ์ ์ข ๋ฃํ๊ณ , ๋ฒฝ์ด ์๋๋ฉด ๋ค๋ก ํ ์นธ ๊ฐ์ฃผ๋ฉด ๋๋ค.
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 2108๋ฒ] ํต๊ณํ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.03 |
---|---|
[๋ฐฑ์ค 1759๋ฒ] ์ํธ ๋ง๋ค๊ธฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.05.02 |
[๋ฐฑ์ค 9935๋ฒ] ๋ฌธ์์ด ํญ๋ฐ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.06 |
[๋ฐฑ์ค 14490๋ฒ] ๋ฐฑ๋์ด - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.05 |
[๋ฐฑ์ค 10610๋ฒ] 30 - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.05 |
Comments