티스토리 뷰
https://www.acmicpc.net/problem/1018
const fs = require('fs');
const [n, ...arr] = fs.readFileSync("/dev/stdin").toString().trim().split("\n");
const [x, y] = n.split(' ').map(v => +v);
const rightBoard = 'WBWBWBWBBWBWBWBW'.repeat(4);
const rightBoard2 = 'BWBWBWBWWBWBWBWB'.repeat(4);
let answer = 100;
for (let i = 0; i < x - 7; i++) {
for (let j = 0; j < y - 7; j++) {
const temp = arr[i].substr(j, 8)
+ arr[i + 1].substr(j, 8)
+ arr[i + 2].substr(j, 8)
+ arr[i + 3].substr(j, 8)
+ arr[i + 4].substr(j, 8)
+ arr[i + 5].substr(j, 8)
+ arr[i + 6].substr(j, 8)
+ arr[i + 7].substr(j, 8)
let cnt1 = 0;
let cnt2 = 0;
for (let k = 0; k < 64; k++) {
if (temp[k] != rightBoard[k]) cnt1++;
if (temp[k] != rightBoard2[k]) cnt2++;
}
if (cnt1 < answer) answer = cnt1;
if (cnt2 < answer) answer = cnt2;
}
}
console.log(answer);
728x90
'자료구조 알고리즘 > 백준' 카테고리의 다른 글
Node.js) 백준 15649번 : N과 M (1) (0) | 2021.09.08 |
---|---|
Node.js) 백준 1436번 : 영화감독 슘 (0) | 2021.09.08 |
Node.Js) 백준 7568번 : 덩치 (0) | 2021.09.08 |
Node.js) 백준 2231번 : 분해합 (0) | 2021.09.08 |
Node.js) 백준 2798번 : 블랙잭 (0) | 2021.09.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 투포인터 연습
- create databases;
- 서버개발
- 동적프로그래밍
- 다이나믹프로그래밍
- BFS
- 다이나밍프로그래밍
- 면접비
- MySQL
- DB 생성
- node.js
- 로드나인
- 최소공통조상
- 투포인터
- MOD
- create db
- 롱베케이션
- 면접질문
- 그래프
- 개발자면접
- 은둔청년체험
- 서버점검
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함