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.
๐ ๋ฌธ์ ๋งํฌ
๋ณ์๋ฆฌ ๋ง๋ค๊ธฐ
โ๏ธ ์์๋ ์๊ฐ
5-10๋ถ!
โจ ์๋ ์ฝ๋
โ ๋ฌธ์
๋ณ์ ์์น (float x, float y)
๊ฐ n๊ฐ ์ฃผ์ด์ง๋ค. ๋ชจ๋ ๋ณ์ ํฌํจํ๋ฉด์ ๊ทธ ๊ธธ์ด๊ฐ ๊ฐ์ฅ ์งง์ ๋ณ์๋ฆฌ๋ฅผ ๊ทธ๋ ค๋ณด์!โ ํ์ด
๋๋ฌด ๊ฐ๋จํ ์ต์ ์ ์ฅ ํธ๋ฆฌ ๋ฌธ์ .. ๋ ๋จน ๋๋์ด ์กฐ๊ธ ๋์ง๋ง ์ต๊ทผ์ 3๋ฌธ์ ํธ๋๋ฐ 100๋ฒ ๊ฐ๊น์ด ํ๋ฆฌ๊ณ ๋ฉํ์ด ๊ฐ๋ ค์ ์ด์ง ์ฌ์ด๊ฐ๋ ๋๋์ผ๋ก ํ์ด๋ดค๋ค. ๊ธฐ์กด์ MST ๋ฌธ์ ๋ฅผ ํ๋ ์ผ๋ Union-Find ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํด ๊ตฌํํ๋ค.
๋ณ์ ์์น๊ฐ n๊ฐ ์ฃผ์ด์ง๋ฉด ๊ฐ ๋ณ๋ผ๋ฆฌ ์ด์ ์ ์๋ ์ ๋ถ์ ๊ฐ์๋
n * (n - 1) / 2
๊ฐ ๋๋ค. ํ์ง๋ง ๋ณ์ ๊ฐ์๊ฐ ์ต๋ 100๊ฐ ๋ฐ์ ์๋๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ์ ๋ถ์ ๊ณ ๋ คํ๋ ์๊ณ ๋ฆฌ์ฆ์ ์งฐ๋ค.์ฐ์ ๊ฐ ๋ณ์ ์์น๋ฅผ ์ ๋ถ ๋ฐ์ ๋ค, ๊ฐ ๋ณ๋ง๋ค ๋๊ฐ ์ ์๋ ์ ๋ถ์ ๊ฒฝ์ฐ์ ์๋ฅผ ๋ชจ๋ ์ ์ฅํด ์ฐ์ ์์ ํ์ ์ ์ฅํ๋ค.
์ดํ์ Union-Find๋ฅผ ์ฌ์ฉํ MST ์๊ณ ๋ฆฌ์ฆ์ ์ ์ฉํ๋ฉด ์์ฑ!
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ
ํคํค ๋ฌ๋ค