티스토리 뷰
https://www.acmicpc.net/problem/6186
6186번: Best Grass
Bessie is planning her day of munching tender spring grass and is gazing out upon the pasture which Farmer John has so lovingly partitioned into a grid with R (1 <= R <= 100) rows and C (1 <= C <= 100) columns. She wishes to count the number of grass clump
www.acmicpc.net
const fs = require('fs');
const [n, ...arr] = fs.readFileSync("./dev/stdin").toString().trim().split("\n");
const [R, C] = n.split(' ').map(v => +v);
const board = arr.map(v => [...v.split(''), '.'])
board.push(new Array(C + 1).fill('.'));
let cnt = 0;
for (let i = 0; i < R; i++) {
for (let j = 0; j < C; j++) {
if (board[i][j] == '#') {
cnt++;
if (board[i + 1][j] == '#') {
board[i + 1][j] = '.'
}
if (board[i][j + 1] == '#') {
board[i][j + 1] = '.'
}
}
}
}
console.log(cnt)
728x90
'자료구조 알고리즘 > 백준' 카테고리의 다른 글
Node.js)백준 1388번: 바닥 장식 (0) | 2021.09.21 |
---|---|
Node.js) 백준 14397 번: 해변 (0) | 2021.09.20 |
Node.js) 백준 16173번: 점프왕 쩰리 (0) | 2021.09.20 |
Node.js) 백준 1300번 : K번째 수 (0) | 2021.09.20 |
Node.js) 백준 2206번 : 벽 부수고 이동하기. (1) | 2021.09.17 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- create databases;
- 서버점검
- 면접비
- 개발자면접
- 서버개발
- 은둔청년체험
- 로드나인
- create db
- DB 생성
- 롱베케이션
- 그래프
- MOD
- node.js
- BFS
- 면접질문
- 투포인터 연습
- 최소공통조상
- MySQL
- 다이나믹프로그래밍
- 다이나밍프로그래밍
- 투포인터
- 동적프로그래밍
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함