[c++] BOJ 19535 :: ใ„ทใ„ทใ„ทใ…ˆ
Algorithm ๋ฌธ์ œ/BOJ 2021. 7. 11. 22:56

๋‚œ์ด๋„ : ๊ณจ๋“œ 3 ๋ฌธ์ œ ใ„ทใ„ทใ„ทใ…ˆ ๋ฌธ์ œ ๋ฐ”๋กœ๊ฐ€๊ธฐ ์ •์ ์ด ๋„ค ๊ฐœ ์ด์ƒ ์žˆ๋Š” ์ž„์˜์˜ ํŠธ๋ฆฌ์— ๋Œ€ํ•ด, ๊ทธ ํŠธ๋ฆฌ์—์„œ ์ •์  ๋„ค ๊ฐœ๋กœ ์ด๋ฃจ์–ด์ง„ ์ง‘ํ•ฉ์„ ๊ณ ๋ฅด์ž. ์ „์ฒด ํŠธ๋ฆฌ์˜ ๊ฐ„์„ ๋“ค ์ค‘ ์ง‘ํ•ฉ์— ์†ํ•œ ๋‘ ์ •์ ์„ ์ž‡๋Š” ๊ฐ„์„ ๋งŒ์„ ๋‚จ๊ฒผ์„ ๋•Œ, ๋„ค ๊ฐœ์˜ ์ •์ ์ด ํ•˜๋‚˜์˜ ํŠธ๋ฆฌ ํ˜•ํƒœ๋กœ ์ด์–ด์ง€๊ฒŒ ๋œ๋‹ค๋ฉด ‘ใ„ท’ ๋ชจ์–‘์ด๊ฑฐ๋‚˜ ‘ใ…ˆ’ ๋ชจ์–‘์ผ ๊ฒƒ์ด๋‹ค. ํŠธ๋ฆฌ์—์„œ ‘ใ„ท’์˜ ๊ฐœ์ˆ˜์™€ ‘ใ…ˆ’์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ฐ๊ฐ ํŠธ๋ฆฌ์—์„œ ‘ใ„ท’ ๋ชจ์–‘, ‘ใ…ˆ’ ๋ชจ์–‘์„ ์ด๋ฃจ๋Š” ์ •์  ๋„ค ๊ฐœ์งœ๋ฆฌ ์ง‘ํ•ฉ์˜ ๊ฐœ์ˆ˜๋ผ๊ณ  ํ•˜์ž. ์ด์ œ, ๋™ํ˜„์ด๋Š” ์„ธ์ƒ์˜ ๋ชจ๋“  ํŠธ๋ฆฌ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์„ธ ์ข…๋ฅ˜๋กœ ๋‚˜๋ˆ„์—ˆ๋‹ค. D-ํŠธ๋ฆฌ : ‘ใ„ท’์ด ‘ใ…ˆ’์˜ 3๋ฐฐ๋ณด๋‹ค ๋งŽ์€ ํŠธ๋ฆฌ G-ํŠธ๋ฆฌ : ‘ใ„ท’์ด ‘ใ…ˆ’์˜ 3๋ฐฐ๋ณด๋‹ค ์ ์€ ํŠธ๋ฆฌ DUDUDUNGA-ํŠธ๋ฆฌ : ‘ใ„ท’์ด ‘ใ…ˆ’์˜ ์ •ํ™•ํžˆ 3๋ฐฐ๋งŒํผ ์žˆ๋Š” ํŠธ๋ฆฌ ์‹ ์ด ๋‚œ ๋™ํ˜„์ด๋Š” ํŠธ๋ฆฌ๋งŒ ๋ณด..

React-query :: api fetch ์‹œ ์‚ฌ์šฉํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
์›น (WEB)/๊ณต๋ถ€ 2021. 7. 10. 12:38

React-query : fetch, cache, synchronize, update(for server state)์— ์‚ฌ์šฉ๋˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค. ๊ณต์‹์‚ฌ์ดํŠธ React Query Hooks for fetching, caching and updating asynchronous data in React react-query.tanstack.com ๋ฐฐ๊ฒฝ server state ์‚ฌ์šฉ ์‹œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. caching deduping(๋ฐ์ดํ„ฐ ์ค‘๋ณต ์ œ๊ฑฐ) update "out of date" data / know when is it reflecting updates data pagination optimization, lazy loading data memory management, garba..

React-query :: Query Invalidation
์›น (WEB)/๊ณต๋ถ€ 2021. 7. 10. 12:37

query๊ฐ€ ์˜ค๋ž˜ ๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ํŒ๋‹จํ•˜๊ณ  ๋‹ค์‹œ fetchํ•ด์˜ฌ ๋•Œ, queryClient.invalidateQueries ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. https://react-query.tanstack.com/guides/query-invalidation Query Invalidation Query Invalidation Waiting for queries to become stale before they are fetched again doesn't always work, especially when you know for a fact that a query's data is out of date because of something the user has done. For that purpose, the Quer..

React-query :: Mutations
์›น (WEB)/๊ณต๋ถ€ 2021. 7. 10. 12:36

query์™€ ๋‹ค๋ฅด๊ฒŒ CUD์— ์‚ฌ์šฉ๋œ๋‹ค. https://react-query.tanstack.com/guides/mutations Mutations Subscribe to our newsletter The latest TanStack news, articles, and resources, sent to your inbox. react-query.tanstack.com ์‚ฌ์šฉ์˜ˆ์ œ const mutation = useMutation(newTodo => axios.post('/todos', newTodo)) return ( {mutation.isLoading ? ( 'Adding todo...' ) : ( {mutation.isError ? ( An error occurred: {mutation.error.mes..

React-query :: Query
์›น (WEB)/๊ณต๋ถ€ 2021. 7. 10. 12:35

๊ธฐ๋ณธ ์‚ฌ์šฉ const info = useQuery('unique_key', fetchData); // fetchData๋Š” promise ๋ฐ˜ํ™˜ uniqueํ•œ key๋กœ ์ •์˜ํ•˜๋ฉฐ, key์— ๋ฌถ์ด๋Š” ๋ฐ์ดํ„ฐ๋Š” ๋น„๋™๊ธฐ ๋ฐ์ดํ„ฐ์ด๋‹ค. useQuery๊ฐ€ ๋ฐ˜ํ™˜ํ•˜๋Š” result๋Š” ๋น„๋™๊ธฐ ๋ฐ์ดํ„ฐ์˜ ์ƒํƒœ๋ฅผ ๋‹ด๊ณ  ์žˆ๋‹ค. ์ƒํƒœ loading isLoading์ด true๊ฐ€ ๋œ๋‹ค. error isError๊ฐ€ true๊ฐ€ ๋˜๋ฉฐ, error์— ์—๋Ÿฌ ์ •๋ณด๊ฐ€ ๋‹ด๊ธด๋‹ค. success isSuccess๊ฐ€ true๊ฐ€ ๋˜๋ฉฐ, data์— ์ •๋ณด๊ฐ€ ๋‹ด๊ธด๋‹ค. idle ์‚ฌ์šฉ ์˜ˆ์ œ const { isLoading, isError, data, error } = useQuery('key', fetchData); // const { status, data, erro..

DeepLink๋ž€? :: ์›๋งํฌ, ๋”ฅ๋งํฌ, ๋””ํผ๋“œ ๋”ฅ๋งํฌ
์›น (WEB)/๊ณต๋ถ€ 2021. 7. 10. 12:07

์›น ํŽ˜์ด์ง€์—์„œ ์•ฑ ๋‚ด๋ถ€๋กœ ์œ ์ €๋ฅผ ์ด๋™ํ•˜๊ธฐ ์œ„ํ•ด ๋”ฅ๋งํฌ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ฆ‰, ๋”ฅ๋งํฌ๋Š” ๋ชจ๋ฐ”์ผ ์•ฑ ๋‚ด์˜ ํŠน์ • ์ฝ˜ํ…์ธ ๋กœ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๋งํฌ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. Deeplink ์ข…๋ฅ˜ URL Scheme ๊ณ ์œ ์•ฑ://์ฝ˜ํ…์ธ  ์˜ ํ˜•ํƒœ์ด๋‹ค. ์•ฑ์ด ๊น”๋ ค์žˆ์„ ๋•Œ ํŠน์ • ์•ฑ์˜ ํŠน์ • ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•œ๋‹ค. ์•ฑ ๋ฏธ์„ค์น˜ ์‹œ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š”๋‹ค. Universal Link IOS์—์„œ๋งŒ ๋™์ž‘ํ•˜๋Š” ๋”ฅ๋งํฌ์ด๋‹ค. ์œ ๋‹ˆ๋ฒ„์…œ ๋งํฌ๋Š” ์•ฑ์—์„œ ํ—ˆ์šฉํ•  ๋„๋ฉ”์ธ์„ ๋“ฑ๋กํ•ด์ฃผ์–ด์•ผ ํ•˜๋ฉฐ, ์›น ํ”„๋ก ํŠธ์—์„œ .well-known/apple-app-site-association ํŒŒ์ผ์„ ์ •์˜ํ•˜์—ฌ ํ˜€์šฉํ•  path๋ฅผ ์ง์ ‘ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. ์œ ๋‹ˆ๋ฒ„์…œ ๋งํฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ชจ๋ฐ”์ผ ์›น์œผ๋กœ ํŠน์ • Path์˜ ํŽ˜์ด์ง€์— ์ ‘์† ์‹œ ์•ฑ ๋‚ด์˜ ํ•ด๋‹น ์œ„์น˜๋กœ ์œ ์ €๋ฅผ ์ด๋™ ์‹œ์ผœ์ค„ ์ˆ˜ ์žˆ๋‹ค. App Link ..

๊ฐœ๋ฐœ์ž๋กœ์„œ ์•ž์œผ๋กœ๋ฅผ ๊ณ„ํšํ•ด๋ณด์ž
๋„์ ์ด๋Š” ๊ธ€/๊ฐœ๋ฐœ์ž๋กœ์„œ ๋„์ ์ด๋Š” ๊ธ€ 2021. 7. 10. 11:31

๋‚˜๋Š” ์ตœ๊ทผ ๋ฒ„ํ‚ทํ”Œ๋ ˆ์ด์Šค๋ผ๋Š” ํšŒ์‚ฌ์— ์ž…์‚ฌํ•˜๊ณ  '๋ ›์‹œ'๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ๊ทผ๋ฌด ์ค‘์ด๋‹ค. ๊ฐ“ ์‹œ์ž‘ํ•œ ๊ฐœ๋ฐœ์ž์ด๋‹ˆ ๋งŒํผ ๊ฐ™์€ ํŒ€์˜ ์‹œ๋‹ˆ์–ด ๋ถ„์ด ๊ต์œก์„ ๋งก์•„์„œ ํ•ด์ฃผ๊ณ  ๊ณ„์‹ ๋ฐ, ๊ธฐ์ˆ ์ ์ธ ๋ถ€๋ถ„ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ฐœ๋ฐœ์ž๋กœ์„œ์˜ ์‚ถ์— ์žˆ์–ด์„œ ๋„์›€์ด ๋ ๋งŒํ•œ ์ด์•ผ๊ธฐ๋“ค์„ ๋งŽ์ด ํ•ด์ฃผ์‹ ๋‹ค. ๊ทธ์˜ ์ด๋ฆ„์€ '์กด'. ์ฟ ์ฟ . ์ฃผ์œ„์— ๋ฉ‹์žˆ๋Š” ์‚ฌ๋žŒ์ด ์žˆ์œผ๋ฉด ๊ทธ ์‚ฌ๋žŒ์˜ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๋ฅผ ๋‹ฎ์•„๊ฐ€๋ ค ๋…ธ๋ ฅํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ, ๋‚˜ ๋˜ํ•œ ์กด๋‹˜์˜ ์—ฌ๋Ÿฌ ๊ฐ€์ง€๋ฅผ ๋‹ฎ์•„๊ฐ€๋ ค ๋…ธ๋ ฅ ์ค‘์ด๋‹ค. ๋ง ํ•œ๋งˆ๋”” ํ•œ๋งˆ๋”” ์ฃผ๋‹ˆ์–ด์— ๋ถ€๋‹ด์ด ๋ ๊นŒ ์‹ ๊ฒฝ ์“ฐ์‹œ๋Š” ๋ชจ์Šต๋ถ€ํ„ฐ ์ž์‹ ์ด ๋ชจ๋ฅด๋Š” ๊ฒƒ์„ ์ธ์ •ํ•˜๊ณ  ๋น ๋ฅด๊ฒŒ ๋ฐฐ์›Œ๋‚˜๊ฐ€๋Š” ํ–‰๋™๋ ฅ๊นŒ์ง€. ๋‹น์žฅ์— ์ด๋ ‡๊ฒŒ ๊ธ€์„ ์“ฐ๊ฒŒ ๋œ ๊ณ„๊ธฐ๋„ ์กด๋‹˜์˜ ์˜ํ–ฅ์„ ๋ฐ›์•„์„œ ์ผ์ง€ ๋ชจ๋ฅธ๋‹ค. ์›๋ž˜ ๋‚˜๋Š” ๊ธ€์„ ์“ฐ๊ธฐ๋ฅผ ๊ฝค ์ข‹์•„ํ–ˆ๋˜ ๊ฒƒ ๊ฐ™์€๋ฐ... ์–ด๋Š์ƒŒ๊ฐ€๋ถ€ํ„ฐ ๊ธ€์„ ์•ˆ์“ฐ๊ฒŒ ๋˜์—ˆ..

[c++] BOJ 3584 :: ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ
Algorithm ๋ฌธ์ œ/BOJ 2021. 7. 3. 15:30

๋‚œ์ด๋„ : ๊ณจ๋“œ 4 ๊ฑธ๋ฆฐ ์‹œ๊ฐ„ : 40๋ถ„ ๋ฌธ์ œ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ ๋ฌธ์ œ ๋ฐ”๋กœ๊ฐ€๊ธฐ ๋ฃจํŠธ๊ฐ€ ์žˆ๋Š” ํŠธ๋ฆฌ(rooted tree)๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ๊ทธ ํŠธ๋ฆฌ ์ƒ์˜ ๋‘ ์ •์ ์ด ์ฃผ์–ด์งˆ ๋•Œ ๊ทธ๋“ค์˜ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ(Nearest Common Anscestor)์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •์˜๋ฉ๋‹ˆ๋‹ค. ๋‘ ๋…ธ๋“œ์˜ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ์€, ๋‘ ๋…ธ๋“œ๋ฅผ ๋ชจ๋‘ ์ž์†์œผ๋กœ ๊ฐ€์ง€๋ฉด์„œ ๊นŠ์ด๊ฐ€ ๊ฐ€์žฅ ๊นŠ์€(์ฆ‰ ๋‘ ๋…ธ๋“œ์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด) ๋…ธ๋“œ๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด 15์™€ 11๋ฅผ ๋ชจ๋‘ ์ž์†์œผ๋กœ ๊ฐ–๋Š” ๋…ธ๋“œ๋Š” 4์™€ 8์ด ์žˆ์ง€๋งŒ, ๊ทธ ์ค‘ ๊นŠ์ด๊ฐ€ ๊ฐ€์žฅ ๊นŠ์€(15์™€ 11์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด) ๋…ธ๋“œ๋Š” 4 ์ด๋ฏ€๋กœ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ์€ 4๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ๋ฃจํŠธ๊ฐ€ ์žˆ๋Š” ํŠธ๋ฆฌ๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ๋‘ ๋…ธ๋“œ๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๊ทธ ๋‘ ๋…ธ๋“œ์˜ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ณตํ†ต ์กฐ์ƒ์„ ์ฐพ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์„ธ์š”..