-
Notifications
You must be signed in to change notification settings - Fork 9
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
최주은 / 16주차 #23
Open
jee-woo
wants to merge
25
commits into
algorithm-tear-up-20b:main
Choose a base branch
from
jee-woo:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
최주은 / 16주차 #23
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5f01b7a
[BOJ] 예산 / 실버3 / 30분
jee-woo daf04d1
[BOJ] 나무 자르기 / 실버2 / 15분
jee-woo 48e89f2
[BOJ] 랜선 자르기 / 실버2 / 1시간
jee-woo 44a4272
IF문 좀 대신 써줘 / 실버3 / 1시간
jee-woo 5a5e007
용돈 관리 / 실버2 / 1시간
jee-woo 2f6ea9a
[BOJ] 안전 영역 / 실버1 / 20분
jee-woo 5ee1503
[BOJ] 유기농 배추 / 실버2 / 1시간
jee-woo 025d226
[BOJ] 연결 요소의 개수 / 실버2 / 1시간
jee-woo 65bf5ad
[BOJ] 경로 찾기 / 실버1 / 1시간
jee-woo e7101e5
[BOJ] DOM / 실버2 / 40분
jee-woo f657d4c
[BOJ] DFS와 BFS / 실버2 / 1시간
jee-woo 5478484
[BOJ] 유기농 배추 / 실버2 / 30분
jee-woo e7ca103
[BOJ] 촌수 계산 / 실버2 / 1시간
jee-woo 49217fb
[BOJ] 미로 탐색 / 실버1 / 30분~1시간
jee-woo f640652
[BOJ] 나이트의 이동 / 실버1 / 30분
jee-woo dd55f3d
[BOJ] 2xn 타일링 / 실버3 / 15분
jee-woo 5b9ddcd
[BOJ] 01타일 / 실버3 / 25분
jee-woo 536a159
[BOJ] 돌 게임 / 실버5 / 20분
jee-woo c0de78d
[BOJ] 이친수 / 실버3 / 20분
jee-woo c8830d4
[BOJ] 1로 만들기 / 실버3 / 20분
jee-woo 6473362
[BOJ] 진우의 달 여행 (Small) / 실버3 / 1시간 이내
jee-woo 9566e70
[BOJ] 연속합 / 실버2 / 30분
jee-woo 972914b
[BOJ] 부분수열의 합 / 실버2 / 30분 이상
jee-woo db5c204
[BOJ] 사탕 게임 / 실버2 / 1시간 이내 (레퍼런스 참고)
jee-woo dee1a5a
[BOJ] 숫자 야구 / 실버3 / 1시간 이상
jee-woo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const fs = require("fs"); | ||
const input = fs | ||
.readFileSync( | ||
process.platform === "linux" ? "/dev/stdin" : __dirname + "/2468.txt" | ||
) | ||
.toString() | ||
.split("\n") | ||
.map((el) => el.split(" ").map(Number)); | ||
|
||
const N = input[0][0]; | ||
const map = input.slice(1); | ||
|
||
const solution = (n, map) => { | ||
let maxCount = 0; | ||
|
||
let visited = new Array(n); | ||
for (let i = 0; i < n; i++) visited[i] = new Array(n).fill(false); | ||
|
||
const dfs = (i, j, height) => { | ||
visited[i][j] = true; | ||
if (map[i - 1]?.[j] >= height && !visited[i - 1]?.[j]) | ||
dfs(i - 1, j, height); | ||
if (map[i + 1]?.[j] >= height && !visited[i + 1]?.[j]) | ||
dfs(i + 1, j, height); | ||
if (map[i]?.[j - 1] >= height && !visited[i]?.[j - 1]) | ||
dfs(i, j - 1, height); | ||
if (map[i]?.[j + 1] >= height && !visited[i]?.[j + 1]) | ||
dfs(i, j + 1, height); | ||
}; | ||
|
||
let count; | ||
for (let rainfall = 1; rainfall <= 100; rainfall++) { | ||
count = 0; | ||
visited = new Array(n); | ||
for (let i = 0; i < n; i++) visited[i] = new Array(n).fill(false); | ||
|
||
for (let i = 0; i < n; i++) { | ||
for (let j = 0; j < n; j++) { | ||
if (map[i][j] >= rainfall && !visited[i][j]) { | ||
dfs(i, j, rainfall); | ||
count++; | ||
} | ||
} | ||
} | ||
maxCount = Math.max(maxCount, count); | ||
if (count === 0) break; | ||
} | ||
|
||
return maxCount; | ||
}; | ||
|
||
console.log(solution(N, map)); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 각 방향마다 dfs 함수를 호출하는 방법도 있네요