Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: BOJ 2630 색종이 만들기 #37

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
063c09a
Add @Parkjju as a contributor
Parkjju Jul 15, 2022
10f5a89
Add @4923 as a contributor
Parkjju Jul 15, 2022
56214e2
Add @4923 as a contributor
Parkjju Jul 15, 2022
c5fec1f
Add @Parkjju as a contributor
Parkjju Jul 15, 2022
81189c1
Add @hotsun1508 as a contributor
Parkjju Jul 15, 2022
dd1da96
Add @HajunYoo as a contributor
Parkjju Jul 15, 2022
86b2664
Add @wJJin as a contributor
Parkjju Jul 15, 2022
62fa6d5
Add @Hellol77 as a contributor
Parkjju Jul 15, 2022
4535c23
Add @SeolHuiGwan9478 as a contributor
Parkjju Jul 15, 2022
3d098ed
📝 docs: all-contributors CLI yarn 패키지 설치
Parkjju Jul 15, 2022
b4a2836
📝 docs: contributorsPerLine 프로퍼티 4 -> 7로 수정
Parkjju Jul 15, 2022
a543d6d
📝 docs(yarn all-contributors generate, 최신데이터 반영): yarn all-contributo…
Parkjju Jul 15, 2022
8f8e41e
📝 docs: url 그대로 노출되는 문제
Parkjju Jul 15, 2022
60c1000
🐛 fix: 뱃지 위치 수정
Parkjju Jul 15, 2022
42eefae
📝 docs: hufslion 이미지 위치 수정
Parkjju Jul 15, 2022
d39d2e6
Merge branch 'docs/contributor'
Parkjju Jul 15, 2022
e6a3553
Add @hotsun1508 as a contributor
Parkjju Jul 15, 2022
6add591
📝 docs: boj 11729 하노이 탑 이동 순서
Parkjju Jul 16, 2022
3b20fb7
📝 docs: boj 11729 시간초과 에러 해결
Parkjju Jul 16, 2022
8ec93fe
Merge branch 'hufslion10th:main' into main
Parkjju Jul 18, 2022
0da0b6d
📝 docs: boj 1074 Z - 헬퍼메서드 활용 표현
Parkjju Jul 18, 2022
4d8673c
📝 docs: boj 1074 Z
Parkjju Jul 18, 2022
cd227ba
Merge branch 'hufslion10th:main' into main
Parkjju Jul 20, 2022
0d5279a
Merge branch 'hufslion10th:main' into main
Parkjju Jul 22, 2022
bf54ffe
Merge branch 'hufslion10th:main' into main
Parkjju Jul 22, 2022
39892df
📝 docs: boj 1780 종이의 개수
Parkjju Jul 22, 2022
f2370ba
📝 docs: boj 2630 색종이 만들기
Parkjju Jul 25, 2022
574a2c4
📝 docs: 주석 추가
Parkjju Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions BOJ/1780/parkjju.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const fs = require('fs');
let input = fs
.readFileSync('/dev/stdin')
.toString()
.split('\n')
.map((item) => item.trim());

const size = +input[0];
let square = [];
for (let i = 1; i < input.length; i++) {
square.push(input[i]);
}
square = square.map((item) => item.split(' ').map((item) => +item));
let answer = [0, 0, 0];
const solution = (row, col, size) => {
let first = square[row][col];
let same = true;

for (let i = row; i < row + size; i++) {
for (let j = col; j < col + size; j++) {
if (first !== square[i][j]) {
same = false;
break;
}
}
if (!same) {
break;
}
}

if (same) {
answer[first + 1] += 1;
return;
}

let k = size / 3;

for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
solution(row + i * k, col + j * k, k);
}
}
};
solution(0, 0, size);
console.log(answer.at(0));
console.log(answer.at(1));
console.log(answer.at(2));
54 changes: 54 additions & 0 deletions BOJ/2630/parkjju.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const fs = require('fs');
let input = fs.readFileSync('./input.txt').toString().trim().split('\n');
let count = +input[0];
let paper = input
.slice(1, count + 1)
.map((item) => item.split(' ').map((item) => +item));
let zero = 0;
let one = 0;

// 재귀 함수
const isPaper = (x, y, line) => {
if (line === 0) {
return;
}
// 맨 처음 순회하는 값
// 앞으로 순회하다가 prev와 다른 값이 등장하면 그 즉시 순회 중단
let prev = paper[x][y];

// 탈출을 위한 flag 설정
let bool = true;
for (let row = x; row < x + line; row++) {
for (let col = y; col < y + line; col++) {
if (paper[row][col] !== prev) {
bool = false;
break;
}
}
if (!bool) {
break;
}
}

// 전역변수에 접근 - 0 및 1로만 이루어진 사각형이면 + 1
if (bool) {
if (prev === 0) {
zero += 1;
} else {
one += 1;
}
return;
}
// 변 길이 / 2
let temp = parseInt(line / 2);

// 네 조각으로 쪼개진 사각형 순회
for (let i = 0; i < 2; i++) {
for (let j = 0; j < 2; j++) {
isPaper(x + i * temp, y + j * temp, temp);
}
}
};

isPaper(0, 0, count);
console.log(zero, one);