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.
๐ ๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/2206
โ๏ธ ์์๋ ์๊ฐ
40๋ถ
โจ ์๋ ์ฝ๋
24์ฃผ์ฐจ๋ ์์ํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
๋ณดํต BFS๋ 2์ฐจ์ ๋ฐฐ์ด๋ก ํน์ ์นธ์ ๋ฐฉ๋ฌธํ๋์ง ์ฒดํฌํด์ผ ํ์ง๋ง, ์ด ๋ฌธ์ ์์๋ ๊ทธ๋ ๊ฒ ํ๋ฉด, ์ด๋ค ์นธ์ ๋ฒฝ์ ์ ๋ถ์๊ณ ๋์ฐฉํ ๊ฒฝ์ฐ์ ๋ฒฝ์ ๋ถ์๊ณ ๋์ฐฉํ ๊ฒฝ์ฐ๋ฅผ ๊ตฌ๋ถํ ์ ์์ต๋๋ค.
๊ทธ๋ฌ๋ฏ๋ก, '๋ฒฝ์ ์ ๋ถ์๊ณ ์จ ๊ฒฝ๋ก'๋ ์์ผ๋ก ๋ฒฝ์ ๋ถ์ ๊ธฐํ๊ฐ ๋จ์์๊ธฐ ๋๋ฌธ์ ๋ ์ค์ํ ์ ์๋๋ฐ, ์ด ๊ธฐํ๋ฅผ ๋ฌด์ํ๊ฒ ๋๋๊ฒ๋๋ค.
์ ๋ ์ด ๋ฌธ์ ๋ฅผ ํ๊ธฐ ์ํด์, ์๋ก ๋ค๋ฅธ ๋ ๊ฐ์ ๋งต์ด ๊ฒน์ณ์ ธ์๋ค๊ณ ์๊ฐํ์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ด ๋ ๊ฐ์ ๋งต์ ๋์์ ํํํ๋ ๊ฒ์ ๋๋ค. 3์ฐจ์ ๋ฐฐ์ด๋ก ๋ง์ด์ฃ .
์ด๋ฐ ์์ด๋์ด๋ฅผ ๊ฐ์ง๊ณ ์ ์ฝ๋๋ฅผ ๋ณด์๋ฉด ์ดํดํ์ค ๊ฒ ์ ๋๋ค!
์ ๋ ์ด ๋ฌธ์ ๋ฅผ ํ๊ธฐ ์ํด์ tuple์ ์ฌ์ฉํ๋๋ฐ์,
ํํ์ ์์ํ๋๋ฐ, ์ฒ์์ ๋ฒฝ์ ๋ถ์ ์ ์ด ์์ผ๋ 0๋ฒ ๋งต์์ ์์ํฉ๋๋ค. ๊ทธ๋์ visited[0][0][0]์ ๋ฐฉ๋ฌธํ๋ค๊ณ ๋์ฅ์ ์ฐ์ต๋๋ค.
์ด์ , while ๋ฃจํ ์์์ ๋ ๊ฐ์ง ์ด๋ ๊ท์น์ด ์๋๋ฐ
์ด ๊ณผ์ ์ ๋ชฉ์ ์ง์ ๋์ฐฉํ ๋๊น์ง ๋ฐ๋ณตํ๋ ๊ฒ๋๋ค.
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
3์ฐจ์ ๋ฐฐ์ด์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ์๋ค๋ ๊ฒ์ ์๊ฒ ๋์๊ณ , tuple์ ์ฌ์ฉํ๋ฉด ์ฝ๋๊ฐ ๊ฐํธํด์ง๊ณ ํธํด์ง๋ค๋ ๊ฒ์ ์๊ฒ ๋์์!