[c++] BOJ 18240 :: ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ ๋ณต์›ํ•˜๊ธฐ
Algorithm ๋ฌธ์ œ/BOJ 2021. 7. 11. 22:58

๋‚œ์ด๋„ : ๊ณจ๋“œ 2 ๋ฌธ์ œ ์ด์ง„ ํƒ์ƒ‰ ํŠธ๋ฆฌ ๋ณต์›ํ•˜๊ธฐ ๋ฌธ์ œ ๋ฐ”๋กœ๊ฐ€๊ธฐ 1๋ถ€ํ„ฐ N๊นŒ์ง€์˜ ๋ชจ๋“  ์ •์ˆ˜๋ฅผ ํ•œ ๋ฒˆ์”ฉ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ์ˆ˜์—ด A1, A2, ..., AN์ด ์žˆ๋‹ค. ๊ฐ’์ด A1์ธ ๋…ธ๋“œ๋ฅผ ๋ฃจํŠธ๋กœ ํ•˜๋Š” ํŠธ๋ฆฌ์— A2, A3, ..., AN ์„ ์ˆœ์„œ๋Œ€๋กœ ์‚ฝ์ž…ํ•˜๋ ค ํ•œ๋‹ค. N-1๊ฐœ์˜ ๋…ธ๋“œ๋ฅผ ์‚ฝ์ž…ํ•  ๋•Œ๋งˆ๋‹ค ๋ฃจํŠธ์—์„œ ๊ทธ ๋…ธ๋“œ์— ๋„๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด ๊ฑฐ์ณ์•ผ ํ•˜๋Š” ๊ฐ„์„ ์˜ ์ˆ˜, ์ฆ‰ ๋…ธ๋“œ์˜ ๊นŠ์ด๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ A1, A2, ..., AN์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ํ’€์ด ๊ฐ’ ๋ฐ›์œผ๋ฉด์„œ 2N(n-1)children.size() > 0) { // ์™ผ์ชฝ ์ž์‹ ์กด์žฌ Inorder(head->children[0]); } result[head->index] = idx++; if (head->children.size() > 1) { // ์˜ค๋ฅธ์ชฝ ์ž์‹ ..

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 :: 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..