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.
1. 14502
๐ ๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/14502
โ๏ธ ์์๋ ์๊ฐ
50m
โจ ์๋ ์ฝ๋
๋ฒฝ 3๊ฐ ์ธ์ฐ๋ ๊ฑธ ์ฝ๋๋ก ์ด๋ป๊ฒ ์ฎ๊ธธ๊น ์๊ฐ์ ํ๋ ์ค์ ์ ์ idx๋ฅผ ์ฌ์ฉํด์ x,y์ขํ๋ฅผ ๊ตฌํ๋ ๋ฐฉ์์ด ๋ ์ฌ๋ผ ์ฌ์ฉํ์ด๋ค!
dfs๋ฅผ ํตํด์ ๋ฒฝ3๊ฐ๋ฅผ ๋ง๋ค์ด์ค ์ํ์์ depth๊ฐ 3์ด ๋ฌ์๋ ๊ทธ ์์์ bfs๋ฅผ ๋์์ ์ ๋ต์ ๊ฐฑ์ ํ๋ฉด ๋์
์ฒ์์ else๋ก buildwall(idx+1, depth);
์ด ๋ถ๋ถ์ ๋นผ์ ์คํจํ์๋๋ฐ ์ ์คํจ ํ๋๋ฉด else๋ก ๋นผ์ ์ฒ๋ฆฌํ๊ฒ ๋๋ฉด์
์ ์ธ์ฐ๊ณ ๋์ด๊ฐ๋ ๊ฒฝ์ฐ๋ ์ฒ๋ฆฌ๋ฅผ ์ํ๊ณ ๋ฒฝ ์ธ์ฐ๋ ๊ฒฝ์ฐ๋ง ํ์์ ํ๊ฒ ๋จ
์๋ ๋ถ๋ถ์ ๋๋ฒ๊น ์ฉ ๋ฐฐ์ด์ ํ์ธํ๋ ์ฉ๋์์
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
2. 2206
๐ ๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/2206
โ๏ธ ์์๋ ์๊ฐ
์ ๋ต ์ฐธ๊ณ (30๋ถ ๊ณ ๋ฏผ)
โจ ์๋ ์ฝ๋
๋ฒฝ์ ๋ถ์ ๊ฒฝ์ฐ, ์ ๋ถ์ ๊ฒฝ์ฐ๋ฅผ ๋ค ์๊ฐํ๋๊ฑธ ์ฝ๋๋ก ์ด๋ป๊ฒ ๋ณํํ ๊น ์๊ฐํ๋ค๊ฐ ์ ๋ ์ฌ๋ผ์ ๋ฐ๋ก ์ ๋ต์ ์ฐธ๊ณ ํ์ต๋๋ค.
int dist[1005][1005][2];
[0] ๋ฒฝ์ ํ๋๋ ์ ๋ถ์๊ณ (x,y)๊น์ง ์ค๋๋ฐ ๊ฑธ๋ฆฌ๋ ๋น์ฉ
[1] ๋ฒฝ์ ํ๋๋ง ๋ถ์๊ณ (x,y)๊น์ง ์ค๋๋ฐ ๊ฑธ๋ฆฌ๋ ๋น์ฉ, (x,y)๊ฐ ๋ฒฝ์ด๋ผ์ ๋ถ์๋ ๊ฒฝ์ฐ ํฌํจ
bfsํ์ ๋น์ทํด์ ์ฃผ์ ๋ฌ์๋์๊ฒ์ผ๋ก ์ดํด๋์ค๊ฑฐ๊ฐ์ต๋๋ค!
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
์ํ๋ฅผ 3์ฐจ์ ๋ฐฐ์ด์ ์ถ๊ฐ๋ก ๋ฃ๋ ๋ฐฉ์์ ๋ฌธ์ ๋ฅผ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง ์๋ก ์์์ด์
tie๋ก ๋ณ์๋ฅผ ๋ฐ์ ์ ์์ด์
<์ฐธ๊ณ >
https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x09/solutions/2206.cpp