<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>깊이 우선 탐색 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%EA%B9%8A%EC%9D%B4-%EC%9A%B0%EC%84%A0-%ED%83%90%EC%83%89/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Fri, 15 Mar 2024 16:00:36 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>깊이 우선 탐색 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>백준 1240번 (노드사이의 거리, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-1240%eb%b2%88-%eb%85%b8%eb%93%9c%ec%82%ac%ec%9d%b4%ec%9d%98-%ea%b1%b0%eb%a6%ac-c-baekjoon/37874/</link>
					<comments>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-1240%eb%b2%88-%eb%85%b8%eb%93%9c%ec%82%ac%ec%9d%b4%ec%9d%98-%ea%b1%b0%eb%a6%ac-c-baekjoon/37874/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 04 Mar 2024 15:51:29 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1240]]></category>
		<category><![CDATA[1240 C++]]></category>
		<category><![CDATA[1240번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[Gold]]></category>
		<category><![CDATA[Gold5]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[골드]]></category>
		<category><![CDATA[골드5]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[노드사이의 거리]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1240]]></category>
		<category><![CDATA[백준 1240번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[재귀]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=37874</guid>

					<description><![CDATA[<p>백준 온라인 문제 1240번 문제에 대한 글입니다.<br />
DFS 재귀 함수를 사용하여 해결하였습니다.  (This is about question 1240 of Baekjun Online Problem.<br />
Resolved using the DFS recursive function.)</p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-1240%eb%b2%88-%eb%85%b8%eb%93%9c%ec%82%ac%ec%9d%b4%ec%9d%98-%ea%b1%b0%eb%a6%ac-c-baekjoon/37874/">백준 1240번 (노드사이의 거리, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-75779d84      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#노드사이의-거리" class="uagb-toc-link__trigger">노드사이의 거리</a><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">노드사이의 거리 <img decoding="async" width="30" height="38" class="wp-image-37889" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Gold_5.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Gold_5.jpg 1250w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_5-234x300.jpg 234w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_5-768x983.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_5-1200x1536.jpg 1200w" sizes="(max-width: 30px) 100vw, 30px" /></h2>



<p><a href="https://www.acmicpc.net/problem/1240" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1240</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">9018</td><td class="has-text-align-left" data-align="left">4874</td><td class="has-text-align-left" data-align="left">3752</td><td class="has-text-align-left" data-align="left">53.638%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">문제</h3>



<p> N개의 노드로 이루어진 트리가 주어지고 M개의 두 노드 쌍을 입력받을 때 두 노드 사이의 거리를 출력하라.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">입력</h3>



<p>첫째 줄에 노드의 개수&nbsp;N과 거리를 알고 싶은 노드 쌍의 개수&nbsp;M이 입력되고 다음&nbsp;N-1개의 줄에 트리 상에 연결된 두 점과 거리를 입력받는다. </p>



<p>그 다음 줄에는 거리를 알고 싶은&nbsp;M개의 노드 쌍이 한 줄에 한 쌍씩 입력된다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출력</h3>



<p> M개의 줄에 차례대로 입력받은 두 노드 사이의 거리를 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">제한</h3>



<ul class="wp-block-list">
<li> 2 ≤ N ≤1,000 </li>



<li> 1 ≤ M ≤ 1,000 </li>



<li>트리 상에 연결된 두 점과 거리는&nbsp;10,000&nbsp;이하인 자연수이다.</li>



<li>트리 노드의 번호는&nbsp;1부터&nbsp;N까지 자연수이며, 두 노드가 같은 번호를 갖는 경우는 없다.</li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4 2
2 1 2
4 3 2
1 4 3
1 2
3 2</pre>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2
7</pre>
</div>
</div>



<div style="height:113px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출처</h3>



<ul class="wp-block-list">
<li>빠진 조건을 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/hg7258" target="_blank" rel="noreferrer noopener">hg7258</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/120" target="_blank" rel="noreferrer noopener">트리</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126" target="_blank" rel="noreferrer noopener">너비 우선 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127" target="_blank" rel="noreferrer noopener">깊이 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading">통과된 코드</h2>



<p>DFS를 이용하여 탐색</p>



<p>리펙토링하면 메모리와 시간을 더 줄일 수 있음</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>

using namespace std;

constexpr int MAX = 1001;

int N, M, _End;

vector&lt;int> Nodes[MAX];
vector&lt;int> Distances[MAX][MAX];
bool IsVisted[MAX];


void DFS(int _Len, int _CurNode)
{
	if (_End == _CurNode) {
		cout &lt;&lt; _Len &lt;&lt; '\n';
		return;
	}

	for (int i = 0; i &lt; Nodes[_CurNode].size(); i++)
	{
		int NextNode = Nodes[_CurNode][i];
		if (IsVisted[NextNode]) 
			continue;
		IsVisted[NextNode] = true;
		DFS(_Len + *Distances[_CurNode][NextNode].begin(), NextNode);
		IsVisted[NextNode] = false;
	}

}

int main()
{
	cin >> N >> M;
	int _S, _E, _D;
	for (int i = 0; i &lt; N-1; i++) {
		cin >> _S >> _E >> _D;
		Nodes[_S].push_back(_E);
		Nodes[_E].push_back(_S);
		Distances[_S][_E].push_back(_D);
		Distances[_E][_S].push_back(_D);
	}

	for (int i = 0; i &lt; M; i++) {
		cin >> _S >> _E;
		_End = _E;
		IsVisted[_S] = true;
		DFS(0, _S);
		IsVisted[_S] = false;
	}


	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>방문 체크를 빼먹어서 틀렸다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="830" height="120" src="https://lycos7560.com/wp-content/uploads/2024/03/image.png" alt="" class="wp-image-37875" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image.png 830w, https://lycos7560.com/wp-content/uploads/2024/03/image-300x43.png 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-768x111.png 768w" sizes="(max-width: 830px) 100vw, 830px" /></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>추가</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">    ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
    cin.tie(NULL);
    cout.tie(NULL);</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>

using namespace std;

constexpr int MAX = 1001;

int N, M, _End;

vector&lt;int> Nodes[MAX];
vector&lt;int> Distances[MAX][MAX];
bool IsVisted[MAX];


void DFS(int _Len, int _CurNode)
{
	if (_End == _CurNode) {
		cout &lt;&lt; _Len &lt;&lt; '\n';
		return;
	}

	for (int i = 0; i &lt; Nodes[_CurNode].size(); i++)
	{
		int NextNode = Nodes[_CurNode][i];
		if (IsVisted[NextNode]) 
			continue;
		IsVisted[NextNode] = true;
		DFS(_Len + *Distances[_CurNode][NextNode].begin(), NextNode);
		IsVisted[NextNode] = false;
	}

}

int main()
{
    ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
    cin.tie(NULL);
    cout.tie(NULL);
	cin >> N >> M;
	int _S, _E, _D;
	for (int i = 0; i &lt; N-1; i++) {
		cin >> _S >> _E >> _D;
		Nodes[_S].push_back(_E);
		Nodes[_E].push_back(_S);
		Distances[_S][_E].push_back(_D);
		Distances[_E][_S].push_back(_D);
	}

	for (int i = 0; i &lt; M; i++) {
		cin >> _S >> _E;
		_End = _E;
		IsVisted[_S] = true;
		DFS(0, _S);
		IsVisted[_S] = false;
	}


	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="834" height="84" src="https://lycos7560.com/wp-content/uploads/2024/03/image-1.png" alt="" class="wp-image-37877" srcset="https://lycos7560.com/wp-content/uploads/2024/03/image-1.png 834w, https://lycos7560.com/wp-content/uploads/2024/03/image-1-300x30.png 300w, https://lycos7560.com/wp-content/uploads/2024/03/image-1-768x77.png 768w" sizes="(max-width: 834px) 100vw, 834px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-1240%eb%b2%88-%eb%85%b8%eb%93%9c%ec%82%ac%ec%9d%b4%ec%9d%98-%ea%b1%b0%eb%a6%ac-c-baekjoon/37874/">백준 1240번 (노드사이의 거리, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-1240%eb%b2%88-%eb%85%b8%eb%93%9c%ec%82%ac%ec%9d%b4%ec%9d%98-%ea%b1%b0%eb%a6%ac-c-baekjoon/37874/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 2573번 (빙산, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2573%eb%b2%88-%eb%b9%99%ec%82%b0-c-baekjoon/36585/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2573%eb%b2%88-%eb%b9%99%ec%82%b0-c-baekjoon/36585/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 25 Aug 2023 16:57:28 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[2573]]></category>
		<category><![CDATA[2573번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Gold]]></category>
		<category><![CDATA[Gold4]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[골드]]></category>
		<category><![CDATA[골드4]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[그래프이론]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[너비]]></category>
		<category><![CDATA[너비 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2573]]></category>
		<category><![CDATA[백준 2573번]]></category>
		<category><![CDATA[빙산]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36585</guid>

					<description><![CDATA[<p>백준 2573번 '빙산' 문제에 대한 글입니다. BFS 알고리즘을 이용하여 해결하였습니다. (This article is about the issue of "ice mountain" in Baekjoon Number 2573. It was solved using the BFS algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2573%eb%b2%88-%eb%b9%99%ec%82%b0-c-baekjoon/36585/">백준 2573번 (빙산, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-75779d84      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#빙산" class="uagb-toc-link__trigger">빙산</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">빙산 <img decoding="async" width="30" height="38" class="wp-image-37904" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Gold_4.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Gold_4.jpg 400w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_4-234x300.jpg 234w" sizes="(max-width: 30px) 100vw, 30px" /></h1>



<p><a href="https://www.acmicpc.net/problem/2573" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/2573</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">66795</td><td class="has-text-align-left" data-align="left">18943</td><td class="has-text-align-left" data-align="left">12600</td><td class="has-text-align-left" data-align="left">25.842%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>지구 온난화로 인하여 북극의 빙산이 녹고 있다. </p>



<p>빙산을 그림 1과 같이 2차원 배열에 표시한다고 하자. </p>



<p>빙산의 각 부분별 높이 정보는 배열의 각 칸에 양의 정수로 저장된다. </p>



<p>빙산 이외의 바다에 해당되는 칸에는 0이 저장된다. </p>



<p>그림 1에서 빈칸은 모두 0으로 채워져 있다고 생각한다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="598" height="362" src="https://lycos7560.com/wp-content/uploads/2023/08/image-22.png" alt="" class="wp-image-36590" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-22.png 598w, https://lycos7560.com/wp-content/uploads/2023/08/image-22-300x182.png 300w" sizes="(max-width: 598px) 100vw, 598px" /><figcaption class="wp-element-caption">그림 1. 행의 개수가 5이고 열의 개수가 7인 2차원 배열에 저장된 빙산의 높이 정보</figcaption></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>빙산의 높이는 바닷물에 많이 접해있는 부분에서 더 빨리 줄어들기 때문에, </p>



<p>배열에서 빙산의 각 부분에 해당되는 칸에 있는 높이는 일년마다 그 칸에 동서남북 네 방향으로 붙어있는 0이 저장된 칸의 개수만큼 줄어든다. </p>



<p>단, 각 칸에 저장된 높이는 0보다 더 줄어들지 않는다. </p>



<p>바닷물은 호수처럼 빙산에 둘러싸여 있을 수도 있다. </p>



<p>따라서 그림 1의 빙산은 일년후에 그림 2와 같이 변형된다.</p>



<p>그림 3은 그림 1의 빙산이 2년 후에 변한 모습을 보여준다. </p>



<p>2차원 배열에서 동서남북 방향으로 붙어있는 칸들은 서로 연결되어 있다고 말한다. </p>



<p>따라서 그림 2의 빙산은 한 덩어리이지만, 그림 3의 빙산은 세 덩어리로 분리되어 있다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="636" height="900" src="https://lycos7560.com/wp-content/uploads/2023/08/image-23.png" alt="" class="wp-image-36593" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-23.png 636w, https://lycos7560.com/wp-content/uploads/2023/08/image-23-212x300.png 212w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>한 덩어리의 빙산이 주어질 때, 이 빙산이 두 덩어리 이상으로 분리되는 최초의 시간(년)을 구하는 프로그램을 작성하시오. </p>



<p>그림 1의 빙산에 대해서는 2가 답이다. </p>



<p>만일 전부 다 녹을 때까지 두 덩어리 이상으로 분리되지 않으면 프로그램은 0을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫 줄에는 이차원 배열의 행의 개수와 열의 개수를 나타내는 두 정수 N과 M이 한 개의 빈칸을 사이에 두고 주어진다. </p>



<p>N과 M은 3 이상 300 이하이다. 그 다음 N개의 줄에는 각 줄마다 배열의 각 행을 나타내는 M개의 정수가 한 개의 빈 칸을 사이에 두고 주어진다. </p>



<p>각 칸에 들어가는 값은 0 이상 10 이하이다. </p>



<p>배열에서 빙산이 차지하는 칸의 개수, 즉, 1 이상의 정수가 들어가는 칸의 개수는 10,000 개 이하이다. </p>



<p>배열의 첫 번째 행과 열, 마지막 행과 열에는 항상 0으로 채워진다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫 줄에 빙산이 분리되는 최초의 시간(년)을 출력한다. </p>



<p>만일 빙산이 다 녹을 때까지 분리되지 않으면 0을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 7
0 0 0 0 0 0 0
0 2 4 5 3 0 0
0 3 0 2 5 2 0
0 7 6 2 4 0 0
0 0 0 0 0 0 0</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 A</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0 
0 0 0 0 0 0 0
0 0 0 0 0 0 0</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 A</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">0</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 B</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">7 7
0 0 0 0 0 0 0
0 1 1 0 1 1 0
0 1 9 1 9 1 0
0 1 1 1 1 1 0
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 0 0 0 0</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 B</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/2" target="_blank" rel="noreferrer noopener">Olympiad</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/55" target="_blank" rel="noreferrer noopener">한국정보올림피아드</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/69" target="_blank" rel="noreferrer noopener">KOI 2006</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/364">초등부</a>&nbsp;2번</p>



<ul class="wp-block-list">
<li>잘못된 데이터를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/occidere" target="_blank" rel="noreferrer noopener">occidere</a>,&nbsp;<a href="https://www.acmicpc.net/user/zayne" target="_blank" rel="noreferrer noopener">zayne</a></li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/102">구현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/7">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126">너비 우선 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127">깊이 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;queue>
using namespace std;
constexpr short MAX = 300;
short _MAP[2][MAX][MAX];
bool _IsVisted[MAX][MAX];
short _N, _M, _Res = 0, _Glaciers = 0, _Cluster = 0;
short _DxDy[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

void BFS(short _i, short _j)
{
	queue&lt;pair&lt;short, short>> BFSQueue;
	BFSQueue.push({ _i, _j });
	while (!BFSQueue.empty()) {
		pair&lt;short, short> _CntPos = BFSQueue.front();
		BFSQueue.pop();
		short _Sea = 0;
		for (short i = 0; i &lt; 4; i++) {
			short _dx = _CntPos.first + _DxDy[i][0];
			short _dy = _CntPos.second + _DxDy[i][1];
			if (_dx &lt; 0 || _dy &lt; 0 || _dx >= _N || _dy >= _M)
				continue;
			if (_MAP[0][_dx][_dy] &lt;= 0) {
				_Sea++;
				continue;
			}
			if (_IsVisted[_dx][_dy])
				continue;
			_IsVisted[_dx][_dy] = true;
			BFSQueue.push({ _dx, _dy });
		}
		_MAP[1][_CntPos.first][_CntPos.second] = _Sea;
	}
}


short ClusterCount()
{
	short _cnt = 0;
	for (short i = 0; i &lt; _N; i++)
		for (short j = 0; j &lt; _M; j++)
			_IsVisted[i][j] = false;
	for (short i = 0; i &lt; _N; i++)
		for (short j = 0; j &lt; _M; j++) {
			if (_MAP[0][i][j] &lt;= 0 || _IsVisted[i][j])
				continue;
			BFS(i, j);
			_cnt++;
		}
	return _cnt;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N >> _M;
	short _Temp;
	for (short i = 0; i &lt; _N; i++)
		for (short j = 0; j &lt; _M; j++) {
			cin >> _Temp;
			if (_Temp > 0)
				_Glaciers++;
			_MAP[0][i][j] = _Temp;
		}
	short _Cnt = 0;
	while (true) {
		_Cluster = ClusterCount();
		if (_Cluster >= 2 ) {
			_Res = _Cnt;
			break;
		}
		if (_Glaciers &lt;= 1) {
			_Res = 0; 
			break;
		}

		for (short i = 0; i &lt; _N; i++)
			for (short j = 0; j &lt; _M; j++) {
				if (_MAP[0][i][j] &lt;= 0)
					continue;
				_MAP[0][i][j] -= _MAP[1][i][j];
				if (_MAP[0][i][j] &lt;= 0)
					_Glaciers--;
			}
		_Cnt++;
	}

	cout &lt;&lt; _Res;

	return 0;
}</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1205" height="190" src="https://lycos7560.com/wp-content/uploads/2023/08/image-21.png" alt="" class="wp-image-36587" style="width:867px;height:137px" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-21.png 1205w, https://lycos7560.com/wp-content/uploads/2023/08/image-21-300x47.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-21-768x121.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2573%eb%b2%88-%eb%b9%99%ec%82%b0-c-baekjoon/36585/">백준 2573번 (빙산, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2573%eb%b2%88-%eb%b9%99%ec%82%b0-c-baekjoon/36585/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1967번 (트리의 지름, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1967%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36529/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1967%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36529/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 17 Aug 2023 00:01:03 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1967]]></category>
		<category><![CDATA[1967번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[Gold]]></category>
		<category><![CDATA[Gold4]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[골드]]></category>
		<category><![CDATA[골드4]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[그래프이론]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1967]]></category>
		<category><![CDATA[백준 1967번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[트리]]></category>
		<category><![CDATA[트리의 지름]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36529</guid>

					<description><![CDATA[<p>백준 1967번 '트리의 지름' 문제에 대한 글입니다. DFS 탐색 알고리즘을 이용하여 해결하였습니다. (This article is about the problem of Baekjoon Number 1967 'Diameter of the Tree'. It was solved using the DFS search algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1967%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36529/">백준 1967번 (트리의 지름, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-75779d84      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#트리의-지름" class="uagb-toc-link__trigger">트리의 지름</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">트리의 지름 <img decoding="async" width="30" height="38" class="wp-image-37904" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Gold_4.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Gold_4.jpg 400w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_4-234x300.jpg 234w" sizes="(max-width: 30px) 100vw, 30px" /></h1>



<p><a href="https://www.acmicpc.net/problem/1967">https://www.acmicpc.net/problem/1967</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">39735</td><td class="has-text-align-left" data-align="left">15747</td><td class="has-text-align-left" data-align="left">11924</td><td class="has-text-align-left" data-align="left">41.200%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>트리(tree)는 사이클이 없는 무방향 그래프이다. </p>



<p>트리에서는 어떤 두 노드를 선택해도 둘 사이에 경로가 항상 하나만 존재하게 된다. </p>



<p>트리에서 어떤 두 노드를 선택해서 양쪽으로 쫙 당길 때, 가장 길게 늘어나는 경우가 있을 것이다. </p>



<p>이럴 때 트리의 모든 노드들은 이 두 노드를 지름의 끝 점으로 하는 원 안에 들어가게 된다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="483" height="201" src="https://lycos7560.com/wp-content/uploads/2023/08/image-12.png" alt="" class="wp-image-36531" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-12.png 483w, https://lycos7560.com/wp-content/uploads/2023/08/image-12-300x125.png 300w" sizes="(max-width: 483px) 100vw, 483px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>이런 두 노드 사이의 경로의 길이를 트리의 지름이라고 한다. </p>



<p>정확히 정의하자면 트리에 존재하는 모든 경로들 중에서 가장 긴 것의 길이를 말한다.</p>



<p>입력으로 루트가 있는 트리를 가중치가 있는 간선들로 줄 때, 트리의 지름을 구해서 출력하는 프로그램을 작성하시오. </p>



<p>아래와 같은 트리가 주어진다면 트리의 지름은 45가 된다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="486" height="262" src="https://lycos7560.com/wp-content/uploads/2023/08/image-14.png" alt="" class="wp-image-36533" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-14.png 486w, https://lycos7560.com/wp-content/uploads/2023/08/image-14-300x162.png 300w" sizes="(max-width: 486px) 100vw, 486px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>트리의 노드는 1부터 n까지 번호가 매겨져 있다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>파일의 첫 번째 줄은 노드의 개수 n(1 ≤ n ≤ 10,000)이다. </p>



<p>둘째 줄부터 n-1개의 줄에 각 간선에 대한 정보가 들어온다. </p>



<p>간선에 대한 정보는 세 개의 정수로 이루어져 있다. </p>



<p>첫 번째 정수는 간선이 연결하는 두 노드 중 부모 노드의 번호를 나타내고, 두 번째 정수는 자식 노드를, 세 번째 정수는 간선의 가중치를 나타낸다. </p>



<p>간선에 대한 정보는 부모 노드의 번호가 작은 것이 먼저 입력되고, 부모 노드의 번호가 같으면 자식 노드의 번호가 작은 것이 먼저 입력된다. </p>



<p>루트 노드의 번호는 항상 1이라고 가정하며, 간선의 가중치는 100보다 크지 않은 양의 정수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 트리의 지름을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">12
1 2 3
1 3 2
2 4 5
3 5 11
3 6 9
4 7 1
4 8 7
5 9 15
5 10 4
6 11 6
6 12 10</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">45</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/apjw6112">apjw6112</a></li>



<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/dlwjsgud12">dlwjsgud12</a>,&nbsp;<a href="https://www.acmicpc.net/user/shg9411" target="_blank" rel="noreferrer noopener">shg9411</a>,&nbsp;<a href="https://www.acmicpc.net/user/tony9402" target="_blank" rel="noreferrer noopener">tony9402</a>,&nbsp;<a href="https://www.acmicpc.net/user/yongdol503" target="_blank" rel="noreferrer noopener">yongdol503</a></li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/120">트리</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127">깊이 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="wCvZK5P8Wt"><a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/">백준 1167번 (트리의 지름, C++) [BAEKJOON]</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;백준 1167번 (트리의 지름, C++) [BAEKJOON]&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/embed/#?secret=TGKI0WPUmP#?secret=wCvZK5P8Wt" data-secret="wCvZK5P8Wt" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>백준 1167번 문제와 비슷한 문제</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
using namespace std;

unsigned short _V, _ResNode;
int _Res;
bool isvisted[100001];

struct Node
{
    unsigned short Number;
    vector&lt;pair&lt;unsigned short, unsigned short>> Connections;
    Node(unsigned short _num) : Number(_num) { };
};

vector&lt;Node> Nodes;

void DFS(unsigned short cntNode, int _dist)
{
    isvisted[cntNode] = true;
    if (Nodes[cntNode].Connections.size() == 1 &amp;&amp; _ResNode != cntNode) {
        if (_Res &lt; _dist) {
            _Res = _dist;
            _ResNode = cntNode;
        }
        return;
    }

    for (auto&amp; it : Nodes[cntNode].Connections) {
        if (isvisted[it.first])
            continue;
        DFS(it.first, _dist + it.second);
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> _V;
    for (int i = 0; i &lt;= _V; i++)
        Nodes.push_back(Node(i));

    unsigned short _n1, _n2, _d;
    for (int i = 0; i &lt; _V - 1; i++) {
        cin >> _n1 >> _n2 >> _d;
        Nodes[_n1].Connections.push_back({ _n2, _d });
        Nodes[_n2].Connections.push_back({ _n1, _d });
    }

    _Res = 0;
    _ResNode = 1;
    DFS(1, 0);
    for (int i = 1; i &lt;= _V; i++)
        isvisted[i] = false;
    _Res = 0;
    DFS(_ResNode, 0);
    cout &lt;&lt; _Res;
    return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1443" height="114" src="https://lycos7560.com/wp-content/uploads/2023/08/image-15.png" alt="" class="wp-image-36535" style="width:1028px;height:81px" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-15.png 1443w, https://lycos7560.com/wp-content/uploads/2023/08/image-15-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-15-768x61.png 768w" sizes="(max-width: 1443px) 100vw, 1443px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1967%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36529/">백준 1967번 (트리의 지름, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1967%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36529/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1167번 (트리의 지름, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sat, 12 Aug 2023 19:20:07 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1167]]></category>
		<category><![CDATA[1167번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[Gold]]></category>
		<category><![CDATA[Gold2]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[골드]]></category>
		<category><![CDATA[골드2]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1167]]></category>
		<category><![CDATA[백준 1167번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[트리]]></category>
		<category><![CDATA[트리의 지름]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36474</guid>

					<description><![CDATA[<p>백준 1167번 '트리의 지름' 문제에 대한 글입니다. DFS를 이용하여 문제를 해결하였습니다. (This article is about Baekjoon Number 1167 'Diameter of the Tree'. I solved the problem using 'DFS')</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/">백준 1167번 (트리의 지름, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-a1d67416      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#트리의-지름" class="uagb-toc-link__trigger">트리의 지름</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">트리의 지름 <img decoding="async" width="30" height="38" class="wp-image-37903" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Gold_2.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Gold_2.jpg 400w, https://lycos7560.com/wp-content/uploads/2024/03/Gold_2-234x300.jpg 234w" sizes="(max-width: 30px) 100vw, 30px" /></h1>



<p><a href="https://www.acmicpc.net/problem/1167" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1167</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">44657</td><td class="has-text-align-left" data-align="left">16318</td><td class="has-text-align-left" data-align="left">11729</td><td class="has-text-align-left" data-align="left">33.983%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>트리의 지름이란, 트리에서 임의의 두 점 사이의 거리 중 가장 긴 것을 말한다. </p>



<p>트리의 지름을 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>트리가 입력으로 주어진다.</p>



<p>먼저 첫 번째 줄에서는 트리의 정점의 개수 V가 주어지고 (2 ≤ V ≤ 100,000)</p>



<p>둘째 줄부터 V개의 줄에 걸쳐 간선의 정보가 다음과 같이 주어진다. </p>



<p>정점 번호는 1부터 V까지 매겨져 있다.</p>



<p>먼저 정점 번호가 주어지고, 이어서 연결된 간선의 정보를 의미하는 정수가 두 개씩 주어지는데, </p>



<p>하나는 정점번호, 다른 하나는 그 정점까지의 거리이다. </p>



<p>예를 들어 네 번째 줄의 경우 정점 3은 정점 1과 거리가 2인 간선으로 연결되어 있고, </p>



<p>정점 4와는 거리가 3인 간선으로 연결되어 있는 것을 보여준다. 각 줄의 마지막에는 -1이 입력으로 주어진다. </p>



<p>주어지는 거리는 모두 10,000 이하의 자연수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 트리의 지름을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1 3 2 -1
2 4 4 -1
3 1 2 4 3 -1
4 2 4 3 3 5 6 -1
5 4 6 -1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">11</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제의 오타를 찾은 사람: <a href="https://www.acmicpc.net/user/ababc1005" target="_blank" rel="noreferrer noopener">ababc1005</a>, <a href="https://www.acmicpc.net/user/cfghj101" target="_blank" rel="noreferrer noopener">cfghj101</a>, <a href="https://www.acmicpc.net/user/WeissBlume" target="_blank" rel="noreferrer noopener">WeissBlume</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/author5" target="_blank" rel="noreferrer noopener">author5</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/djm03178" target="_blank" rel="noreferrer noopener">djm03178</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/120" target="_blank" rel="noreferrer noopener">트리</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127" target="_blank" rel="noreferrer noopener">깊이 우선 탐색</a></li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
using namespace std;

int _V,  _ResNode, _Res;
bool isvisted[100001];

struct Node
{
	int Number;
	vector&lt;pair&lt;int, int>> Connections;
	Node(int _num) : Number(_num) { };
};

vector&lt;Node> Nodes;

void DFS(int cntNode, int _dist) 
{
	isvisted[cntNode] = true;
	if (Nodes[cntNode].Connections.size() == 1 &amp;&amp; _ResNode != cntNode) {
		if (_Res &lt; _dist) {
			_Res = _dist;
			_ResNode = cntNode;
		}
		return;
	}

	for (auto&amp; it : Nodes[cntNode].Connections) { 
		if (isvisted[it.first])
			continue;
		DFS(it.first, _dist + it.second);
	}
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _V;
	for (int i = 0; i &lt;= _V; i++) 
		Nodes.push_back(Node(i));
	
	int _n1, _n2, _d;
	for (int i = 1; i &lt;= _V; i++) {
		cin >> _n1;
		while (true) {
			cin >> _n2;
			if (_n2 == -1) break;
			cin >> _d;
			Nodes[_n1].Connections.push_back({ _n2, _d});
		}
	}

	_Res = 0;
	_ResNode = 1;
	DFS(1, 0);
	for (int i = 1; i &lt;= _V; i++)
		isvisted[i] = false;
	_Res = 0;
	DFS(_ResNode, 0);
	cout &lt;&lt; _Res;
	return 0;
}

</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1202" height="143" src="https://lycos7560.com/wp-content/uploads/2023/08/image-5.png" alt="" class="wp-image-36480" style="width:1006px;height:120px" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-5.png 1202w, https://lycos7560.com/wp-content/uploads/2023/08/image-5-300x36.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-5-768x91.png 768w" sizes="(max-width: 1202px) 100vw, 1202px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/">백준 1167번 (트리의 지름, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1167%eb%b2%88-%ed%8a%b8%eb%a6%ac%ec%9d%98-%ec%a7%80%eb%a6%84-c-baekjoon/36474/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 16197번 (두 동전, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16197%eb%b2%88-%eb%91%90-%eb%8f%99%ec%a0%84-c-baekjoon/36394/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16197%eb%b2%88-%eb%91%90-%eb%8f%99%ec%a0%84-c-baekjoon/36394/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sat, 05 Aug 2023 14:48:05 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[16197]]></category>
		<category><![CDATA[16197번]]></category>
		<category><![CDATA[Backtracking]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[너비]]></category>
		<category><![CDATA[너비 우선 탐색]]></category>
		<category><![CDATA[두 동전]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 16197]]></category>
		<category><![CDATA[백준 16197번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36394</guid>

					<description><![CDATA[<p>백준 16197번 '두 동전' 문제에 대한 글입니다. BFS 탐색을 이용하여 해결하였습니다. (This article is about BaekJoon Number 16197 "two coins" problem.<br />
It was solved using BFS.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16197%eb%b2%88-%eb%91%90-%eb%8f%99%ec%a0%84-c-baekjoon/36394/">백준 16197번 (두 동전, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-601fdb45      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#두-동전" class="uagb-toc-link__trigger">두 동전</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#dfs-참고-코드" class="uagb-toc-link__trigger">DFS 참고 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading"><strong>두 동전</strong></h1>



<p><a href="https://www.acmicpc.net/problem/16197" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/16197</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">512 MB</td><td class="has-text-align-left" data-align="left">9745</td><td class="has-text-align-left" data-align="left">4287</td><td class="has-text-align-left" data-align="left">2903</td><td class="has-text-align-left" data-align="left">42.250%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>N×M 크기의 보드와 4개의 버튼으로 이루어진 게임이 있다. </p>



<p>보드는 1×1크기의 정사각형 칸으로 나누어져 있고,&nbsp;각각의 칸은 비어있거나, 벽이다. </p>



<p>두 개의 빈 칸에는 동전이 하나씩 놓여져 있고, 두 동전의 위치는 다르다.</p>



<p>버튼은 &#8220;왼쪽&#8221;, &#8220;오른쪽&#8221;, &#8220;위&#8221;, &#8220;아래&#8221;와 같이 4가지가 있다. </p>



<p>버튼을 누르면 두 동전이 버튼에 쓰여 있는 방향으로 동시에 이동하게 된다.</p>



<ul class="wp-block-list">
<li>동전이 이동하려는 칸이 벽이면, 동전은 이동하지 않는다.</li>



<li>동전이 이동하려는 방향에 칸이 없으면 동전은 보드 바깥으로 떨어진다.</li>



<li>그 외의 경우에는 이동하려는 방향으로 한 칸 이동한다.이동하려는 칸에 동전이 있는 경우에도 한 칸 이동한다.</li>
</ul>



<p>두 동전 중 하나만 보드에서 떨어뜨리기 위해 버튼을 최소 몇&nbsp;번 눌러야하는지 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 보드의 세로 크기 N과 가로 크기 M이 주어진다. (1 ≤ N, M ≤ 20)</p>



<p>둘째 줄부터 N개의 줄에는 보드의 상태가 주어진다.</p>



<ul class="wp-block-list">
<li><code>o</code>: 동전</li>



<li><code>.</code>: 빈 칸</li>



<li><code>#</code>: 벽</li>
</ul>



<p>동전의 개수는 항상 2개이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 두 동전 중 하나만 보드에서 떨어뜨리기 위해 눌러야 하는 버튼의 최소 횟수를 출력한다. </p>



<p>만약, 두 동전을 떨어뜨릴 수 없거나, 버튼을 10번보다 많이 눌러야 한다면, -1을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1 2
oo</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6 2
.#
.#
.#
o#
o#
##</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6 2
..
..
..
o#
o#
##</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 4</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 3
###
.o.
###
.o.
###</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 4</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">-1</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 5</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 3
###
.o.
#.#
.o.
###</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 5</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126" target="_blank" rel="noreferrer noopener">너비 우선 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/5" target="_blank" rel="noreferrer noopener">백트래킹</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size"><strong>통과된 코드</strong></h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
#include &lt;queue>

using namespace std;

int _N, _M, _Res = -1;
int _DxDy[4][2] = { { 1, 0}, { 0, -1}, { 0, 1}, { -1, 0} };
char _Map[20][20];
string _Str;

vector&lt;pair&lt;int,int>> _Coins;

struct CntPos
{
	pair&lt;int,int> CoinOne;
	pair&lt;int,int> CoinTwo;
	int Cnt;

	CntPos(int _x1, int _y1, int _x2, int _y2, int _cnt) 
		: CoinOne(make_pair(_x1, _y1)), CoinTwo(make_pair(_x2, _y2)), Cnt(_cnt) {}
};

queue&lt;CntPos> BfsQueue;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N >> _M;
	for (int i = 0; i &lt; _N; i++) {
		cin >> _Str;
		for (int j = 0; j &lt; _M; j++) {
			_Map[i][j] = _Str[j];
			if (_Str[j] == 'o')
				_Coins.push_back({ i, j });
		}
	}

	BfsQueue.push(CntPos(_Coins[0].first, _Coins[0].second, _Coins[1].first, _Coins[1].second, 0));
	while (!BfsQueue.empty()) {
		CntPos _cntpos = BfsQueue.front();
		BfsQueue.pop();

		for (int i = 0; i &lt; 4; i++) {
			bool CheckOne = false, CheckTwo = false;
			_Coins[0].first = _cntpos.CoinOne.first + _DxDy[i][0];
			_Coins[0].second = _cntpos.CoinOne.second + _DxDy[i][1];
			_Coins[1].first = _cntpos.CoinTwo.first + _DxDy[i][0];
			_Coins[1].second = _cntpos.CoinTwo.second + _DxDy[i][1];

			// 동전의 위치가 같다면 하나만 떨어뜨리는 조건에 맞지 않는다.
			if (_Coins[0] == _Coins[1]) continue;

			// 두 동전 중 하나만 보드에서 떨어뜨리기 위함
			if (_Coins[0].first &lt; 0 || _Coins[0].second &lt; 0 || _Coins[0].first >= _N || _Coins[0].second >= _M)
				CheckOne = true;
			if (_Coins[1].first &lt; 0 || _Coins[1].second &lt; 0 || _Coins[1].first >= _N || _Coins[1].second >= _M)
				CheckTwo = true;

			// 동전이 이동하려는 칸이 벽이면, 동전은 이동하지 않는다.
			if (!CheckOne &amp;&amp; (_Map[_Coins[0].first][_Coins[0].second] == '#')) {
				_Coins[0].first = _cntpos.CoinOne.first;
				_Coins[0].second = _cntpos.CoinOne.second;
			}
			if (!(CheckTwo) &amp;&amp; _Map[_Coins[1].first][_Coins[1].second] == '#') {
				_Coins[1].first = _cntpos.CoinTwo.first;
				_Coins[1].second = _cntpos.CoinTwo.second;
			}

			int _TCnt = _cntpos.Cnt;
			if (_TCnt >= 10) {
				_Res = -1;
				while (!BfsQueue.empty())
					BfsQueue.pop();
				break;
			}

			if (CheckOne ^ CheckTwo) {
				_Res = _TCnt + 1;
				while (!BfsQueue.empty())
					BfsQueue.pop();
				break;
			}
			else if(CheckOne &amp;&amp; CheckTwo)
				continue;

			BfsQueue.push(CntPos(_Coins[0].first, _Coins[0].second, _Coins[1].first, _Coins[1].second, _TCnt + 1));
		}
	}

	cout &lt;&lt; _Res;
	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/08/image-1.png" alt="" class="wp-image-36405" width="905" height="77" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-1.png 1207w, https://lycos7560.com/wp-content/uploads/2023/08/image-1-300x26.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-1-768x66.png 768w" sizes="(max-width: 905px) 100vw, 905px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>생각보다 메모리를 많이 사용&#8230;</p>



<p>DFS 탐색을 이용한 백트레킹 방법이 시간과 메모리 부분에서 더 효율적이다.</p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size"><strong>DFS 참고 코드</strong></h2>



<p><a href="https://hyeo-noo.tistory.com/126" target="_blank" rel="noreferrer noopener">https://hyeo-noo.tistory.com/126</a></p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;queue>
#include &lt;cstring>
 
#define pii pair&lt;int, int>
 
using namespace std;
 
 
int N, M, result = 1e9+7;
int Map[21][21];    // 2 : 동전 위치   0 : 벽 위치   1 : 빈칸
vector&lt; pii > startP;
int dr[4] = {0, 0, 1, -1}, dc[4] = {1, -1, 0, 0};
 
void input(){
    // Map에서 벗어나는 경우는 -1로 설정
    memset(Map, -1, sizeof(Map));
    
    cin >> N >> M;
    string str;
    for(int i = 1; i &lt;= N; i++){
        cin >> str;
        for(int j = 0; j &lt; M; j++){
            if(str[j] == 'o'){
                Map[i][j+1] = 2;
                startP.push_back({i, j+1});
            }
            else if(str[j] == '#') Map[i][j+1] = 0;
            else Map[i][j+1] = 1;
        }
    }
}
 
bool isOut(const pii &amp;A){
    if(A.first &lt; 1 || A.first > N || A.second &lt; 1 || A.second > M) return true;
    return false;
}
 
void dfs(pii A, pii B, int cnt){
    // 현재 result보다 cnt가 크다면 더이상의 탐색은 불필요
    if(result &lt; cnt) return;
    
    // cnt 가 10보다 커지면 result값 갱신
    if(cnt > 10){
        result = min(result, cnt);
        return;
    }
    
    // 둘 다 떨어졌으면 되돌아감
    if(isOut(A) &amp;&amp; isOut(B)) return;
    // 하나만 떨어졌으면 result를 최소 cnt값으로 교체
    else if((isOut(A) &amp;&amp; !isOut(B)) || (!isOut(A) &amp;&amp; isOut(B))){
        result = min(result, cnt);
        return;
    }
    
    for(int i = 0; i &lt; 4; i++){
        pii An = {A.first + dr[i], A.second + dc[i]};
        pii Bn = {B.first + dr[i], B.second + dc[i]};
        if(!Map[An.first][An.second]) An = A;
        if(!Map[Bn.first][Bn.second]) Bn = B;
        
        dfs(An, Bn, cnt+1);
    }
}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    input();
    dfs(startP[0], startP[1], 0);
    
    if(result > 10) cout &lt;&lt; -1;
    else cout &lt;&lt; result;
    
    return 0;
}</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/08/image-2.png" alt="" class="wp-image-36424" width="903" height="74" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-2.png 1204w, https://lycos7560.com/wp-content/uploads/2023/08/image-2-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-2-768x63.png 768w" sizes="(max-width: 903px) 100vw, 903px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16197%eb%b2%88-%eb%91%90-%eb%8f%99%ec%a0%84-c-baekjoon/36394/">백준 16197번 (두 동전, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16197%eb%b2%88-%eb%91%90-%eb%8f%99%ec%a0%84-c-baekjoon/36394/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 2251번 (물통, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2251%eb%b2%88-%eb%ac%bc%ed%86%b5-c-baekjoon/36162/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2251%eb%b2%88-%eb%ac%bc%ed%86%b5-c-baekjoon/36162/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 17 Jul 2023 00:07:07 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[2251]]></category>
		<category><![CDATA[2251번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[너비]]></category>
		<category><![CDATA[너비 우선 탐색]]></category>
		<category><![CDATA[물통]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2251]]></category>
		<category><![CDATA[백준 2251번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36162</guid>

					<description><![CDATA[<p>백준 2251번 '물통' 문제에 대한 블로그 글입니다. (This is a blog post about the problem of 'water bottle' in Baekjoon Number 2251.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2251%eb%b2%88-%eb%ac%bc%ed%86%b5-c-baekjoon/36162/">백준 2251번 (물통, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-a6905183      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#물통" class="uagb-toc-link__trigger">물통</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">물통</h1>



<p><a href="https://www.acmicpc.net/problem/2251" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/2251</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">14437</td><td class="has-text-align-left" data-align="left">7329</td><td class="has-text-align-left" data-align="left">5406</td><td class="has-text-align-left" data-align="left">51.276%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>각각 부피가 A, B, C(1≤A, B, C≤200) 리터인 세 개의 물통이 있다. </p>



<p>처음에는 앞의 두 물통은 비어 있고, 세 번째 물통은 가득(C 리터) 차 있다. </p>



<p>이제 어떤 물통에 들어있는 물을 다른 물통으로 쏟아 부을 수 있는데, </p>



<p>이때에는 한 물통이 비거나, 다른 한 물통이 가득 찰 때까지 물을 부을 수 있다. </p>



<p>이 과정에서 손실되는 물은 없다고 가정한다.</p>



<p>이와 같은 과정을 거치다보면 세 번째 물통(용량이 C인)에 담겨있는 물의 양이 변할 수도 있다. </p>



<p>첫 번째 물통(용량이 A인)이 비어 있을 때, </p>



<p>세 번째 물통(용량이 C인)에 담겨있을 수 있는 물의 양을 모두 구해내는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 세 정수 A, B, C가 주어진다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 공백으로 구분하여 답을 출력한다. 각 용량은 오름차순으로 정렬한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">8 9 10</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1 2 8 9 10</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/2" target="_blank" rel="noreferrer noopener">Olympiad</a> > <a href="https://www.acmicpc.net/category/106" target="_blank" rel="noreferrer noopener">USA Computing Olympiad</a> > <a href="https://www.acmicpc.net/category/262" target="_blank" rel="noreferrer noopener">2000-2001 Season</a> > <a href="https://www.acmicpc.net/category/761" target="_blank" rel="noreferrer noopener">USACO Winter 2001 Contest</a> > <a href="https://www.acmicpc.net/category/detail/3427" target="_blank" rel="noreferrer noopener">Orange</a> 4번</p>



<ul class="wp-block-list">
<li>문제의 오타를 찾은 사람: <a href="https://www.acmicpc.net/user/kesakiyo" target="_blank" rel="noreferrer noopener">kesakiyo</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/methylene" target="_blank" rel="noreferrer noopener">methylene</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126" target="_blank" rel="noreferrer noopener">너비 우선 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127" target="_blank" rel="noreferrer noopener">깊이 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading">통과된 코드</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
using namespace std;
int _A, _B, _C;
bool _Check[201][201][201];
bool _Numbers[201];

void DFS(int _a, int _b, int _c)
{
	if (_a == 0) {
		_Check[_a][_b][_c] = true;
		_Numbers[_c] = true;
	}
	int  _tA, _tB, _tC;
	if (_a != 0) {
		_tB = _a + _b;
		if (_tB > _B) {
			_tA = _tB - _B;
			_tB = _B;
		}
		else _tA = 0;
		if (!_Check[_tA][_tB][_c]) {
			_Check[_tA][_tB][_c] = true;
			DFS(_tA, _tB, _c);
		}
			
		_tC = _a + _c;
		if (_tC > _C) {
			_tA = _tC - _C;
			_tC = _C;
		}
		else _tA = 0;
		if (!_Check[_tA][_b][_tC]) {
			_Check[_tA][_b][_tC] = true;
			DFS(_tA, _b, _tC);
		}
	}

	if (_b != 0) {
		_tA = _b + _a;
		if (_tA > _A) {
			_tB = _tA - _A;
			_tA = _A;
		}
		else _tB = 0;
		if (!_Check[_tA][_tB][_c]) {
			_Check[_tA][_tB][_c] = true;
			DFS(_tA, _tB, _c);
		}

		_tC = _b + _c;
		if (_tC > _C) {
			_tB = _tC - _C;
			_tC = _C;
		}
		else _tB = 0;
		if (!_Check[_a][_tB][_tC]) {
			_Check[_a][_tB][_tC] = true;
			DFS(_a, _tB, _tC);
		}
	}

	if (_c != 0) {
		_tA = _c + _a;
		if (_tA > _A) {
			_tC = _tA - _A;
			_tA = _A;
		}
		else _tC = 0;
		if (!_Check[_tA][_b][_tC]) {
			_Check[_tA][_b][_tC] = true;
			DFS(_tA, _b, _tC);
		}

		_tB = _c + _b;
		if (_tB > _B) {
			_tC = _tB - _B;
			_tB = _B;
		}
		else _tC = 0;
		if (!_Check[_a][_tB][_tC]) {
			_Check[_a][_tB][_tC] = true;
			DFS(_a, _tB, _tC);
		}
	}


}


int main()
{
	cin >> _A >> _B >> _C;
	_Check[0][0][_C];
	_Numbers[_C];
	DFS(0, 0, _C);
	for (int i = 0; i &lt;= _C; i++)
		if (_Numbers[i])
			cout &lt;&lt; i &lt;&lt; " ";

	return 0;
}</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1205" height="98" src="https://lycos7560.com/wp-content/uploads/2023/07/image-39.png" alt="" class="wp-image-36176" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-39.png 1205w, https://lycos7560.com/wp-content/uploads/2023/07/image-39-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-39-768x62.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2251%eb%b2%88-%eb%ac%bc%ed%86%b5-c-baekjoon/36162/">백준 2251번 (물통, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2251%eb%b2%88-%eb%ac%bc%ed%86%b5-c-baekjoon/36162/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 21736번 (헌내기는 친구가 필요해, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-21736%eb%b2%88-%ed%97%8c%eb%82%b4%ea%b8%b0%eb%8a%94-%ec%b9%9c%ea%b5%ac%ea%b0%80-%ed%95%84%ec%9a%94%ed%95%b4-c-baekjoon/36032/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-21736%eb%b2%88-%ed%97%8c%eb%82%b4%ea%b8%b0%eb%8a%94-%ec%b9%9c%ea%b5%ac%ea%b0%80-%ed%95%84%ec%9a%94%ed%95%b4-c-baekjoon/36032/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 12 Jul 2023 22:14:25 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dfs]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[재귀]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36032</guid>

					<description><![CDATA[<p>백준 21736번 '헌내기는 친구가 필요해' 문제에 대한 글입니다. 재귀를 이용한 'DFS Search'을 이용하여 해결하였습니다. (Baekjoon Number 21736 This is an article about the problem of "The old man needs a friend." It was solved by using 'DFS Search' using recursive.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-21736%eb%b2%88-%ed%97%8c%eb%82%b4%ea%b8%b0%eb%8a%94-%ec%b9%9c%ea%b5%ac%ea%b0%80-%ed%95%84%ec%9a%94%ed%95%b4-c-baekjoon/36032/">백준 21736번 (헌내기는 친구가 필요해, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-e89d25e2      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#헌내기는-친구가-필요해" class="uagb-toc-link__trigger">헌내기는 친구가 필요해</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">헌내기는 친구가 필요해</h1>



<p><a href="https://www.acmicpc.net/problem/21736" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/21736</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초 (<a href="https://www.acmicpc.net/problem/21736#" target="_blank" rel="noreferrer noopener">하단 참고</a>)</td><td class="has-text-align-left" data-align="left">1024 MB</td><td class="has-text-align-left" data-align="left">3403</td><td class="has-text-align-left" data-align="left">1990</td><td class="has-text-align-left" data-align="left">1668</td><td class="has-text-align-left" data-align="left">60.943%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>2020년에 입학한 헌내기 도연이가 있다. 도연이는 비대면 수업 때문에 학교에&nbsp;가지 못해 학교에 아는 친구가 없었다. </p>



<p>드디어 대면 수업을 하게 된 도연이는 어서 캠퍼스 내의 사람들과 친해지고 싶다.&nbsp;</p>



<p>도연이가 다니는 대학의 캠퍼스는&nbsp;N x M&nbsp;크기이며&nbsp;캠퍼스에서 이동하는&nbsp;방법은 벽이 아닌 상하좌우로 이동하는 것이다. </p>



<p>예를 들어, 도연이가 (x,&nbsp;y)에 있다면 이동할 수 있는 곳은 (x+1,&nbsp;y), (x,&nbsp;y+1), (x-1,&nbsp;y), (x,&nbsp;y-1)이다. </p>



<p>단, 캠퍼스의 밖으로 이동할 수는 없다.</p>



<p>불쌍한 도연이를 위하여 캠퍼스에서 도연이가 만날 수 있는 사람의 수를 출력하는 프로그램을 작성해보자.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에는 캠퍼스의 크기를 나타내는 두 정수&nbsp;N&nbsp;(1 ≤ N ≤ 600),&nbsp;M&nbsp;(1 ≤ M ≤ 600)이 주어진다.</p>



<p>둘째 줄부터&nbsp;N개의 줄에는 캠퍼스의 정보들이 주어진다.&nbsp;</p>



<p><code>O</code>는 빈 공간,&nbsp;<code>X</code>는 벽,&nbsp;<code>I</code>는 도연이,&nbsp;<code>P</code>는 사람이다.&nbsp;</p>



<p><code>I</code>가 한 번만 주어짐이 보장된다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 도연이가 만날 수 있는 사람의 수를 출력한다. </p>



<p>단, 아무도 만나지 못한 경우&nbsp;<code>TT</code>를 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3 5
OOOPO
OIOOX
OOOXP</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3 3
IOX
OXP
XPP</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">TT</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/5" target="_blank" rel="noreferrer noopener">University</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/527" target="_blank" rel="noreferrer noopener">숙명여자대학교</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/2539" target="_blank" rel="noreferrer noopener">제1회 숙명여자대학교 교내 알고리즘 경진대회 (SMUPC)</a>&nbsp;C번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람:&nbsp;<a href="https://www.acmicpc.net/user/cs71107" target="_blank" rel="noreferrer noopener">cs71107</a>,&nbsp;<a href="https://www.acmicpc.net/user/lky7674" target="_blank" rel="noreferrer noopener">lky7674</a>,&nbsp;<a href="https://www.acmicpc.net/user/plast" target="_blank" rel="noreferrer noopener">plast</a>,&nbsp;<a href="https://www.acmicpc.net/user/sait2000" target="_blank" rel="noreferrer noopener">sait2000</a>,&nbsp;<a href="https://www.acmicpc.net/user/songfox00" target="_blank" rel="noreferrer noopener">songfox00</a>,&nbsp;<a href="https://www.acmicpc.net/user/wbcho0504" target="_blank" rel="noreferrer noopener">wbcho0504</a>,&nbsp;<a href="https://www.acmicpc.net/user/whaeun25" target="_blank" rel="noreferrer noopener">whaeun25</a></li>



<li>문제를 만든 사람:&nbsp;<a href="https://www.acmicpc.net/user/swoon" target="_blank" rel="noreferrer noopener">swoon</a></li>
</ul>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126" target="_blank" rel="noreferrer noopener">너비 우선 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/127" target="_blank" rel="noreferrer noopener">깊이 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>DFS 탐색을 재귀로 구현하여 문제를 해결</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
using namespace std;
int _Res = 0, _N, _M;
int _DxDy[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
char _Map[600][600];
string _Str;
char _Temp;
pair&lt;int, int> StartPos;

// 재귀를 이용한 DFS (Depth-First Search) 탐색 
void DFSSearch(int _CntX, int _CntY)
{
	for (int j = 0; j &lt; 4; j++) {
		int _dx = _CntX + _DxDy[j][0];
		int _dy = _CntY + _DxDy[j][1];
		if (_dx >= _N || _dy >= _M || _dx &lt; 0 || _dy &lt; 0)
			continue;
		if (_Map[_dx][_dy] == 'X')
			continue;
		if (_Map[_dx][_dy] == 'P')
			_Res++;
		// 방문처리 대신에 X(벽)으로 마킹
		_Map[_dx][_dy] = 'X';
		DFSSearch(_dx, _dy);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N >> _M;
	for (int i = 0; i &lt; _N; i++) {
		cin >> _Str;
		for (int j = 0; j &lt; _M; j++) {
			_Map[i][j] = _Str[j];
			if (_Str[j] == 'I') {
				StartPos = make_pair(i, j);
				_Map[i][j] = 'X';
			}
		}
	}
	
	DFSSearch(StartPos.first, StartPos.second);

	if (_Res == 0) cout &lt;&lt; "TT"; 
	else  cout &lt;&lt; _Res;

	return 0;
}</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1064" height="45" src="https://lycos7560.com/wp-content/uploads/2023/07/image-31.png" alt="" class="wp-image-36040" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-31.png 1064w, https://lycos7560.com/wp-content/uploads/2023/07/image-31-300x13.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-31-768x32.png 768w" sizes="(max-width: 1064px) 100vw, 1064px" /></figure>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-21736%eb%b2%88-%ed%97%8c%eb%82%b4%ea%b8%b0%eb%8a%94-%ec%b9%9c%ea%b5%ac%ea%b0%80-%ed%95%84%ec%9a%94%ed%95%b4-c-baekjoon/36032/">백준 21736번 (헌내기는 친구가 필요해, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-21736%eb%b2%88-%ed%97%8c%eb%82%b4%ea%b8%b0%eb%8a%94-%ec%b9%9c%ea%b5%ac%ea%b0%80-%ed%95%84%ec%9a%94%ed%95%b4-c-baekjoon/36032/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 12851번 (숨바꼭질 2, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12851%eb%b2%88-%ec%88%a8%eb%b0%94%ea%bc%ad%ec%a7%88-2-c-baekjoon/35778/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12851%eb%b2%88-%ec%88%a8%eb%b0%94%ea%bc%ad%ec%a7%88-2-c-baekjoon/35778/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 09 Jul 2023 19:39:17 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[12851]]></category>
		<category><![CDATA[12851번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[너비]]></category>
		<category><![CDATA[너비 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 12851]]></category>
		<category><![CDATA[백준 12851번]]></category>
		<category><![CDATA[숨바꼭질]]></category>
		<category><![CDATA[숨바꼭질 2]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35778</guid>

					<description><![CDATA[<p>백준 12851번 '숨바꼭질 2' 문제에 대한 글입니다. BFS 탐색을 이용하여 문제를 해결하였습니다. (This article is about Baekjoon Number 12851 "Hide and Seek 2" problem. We solved the problem using 'BFS Search'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12851%eb%b2%88-%ec%88%a8%eb%b0%94%ea%bc%ad%ec%a7%88-2-c-baekjoon/35778/">백준 12851번 (숨바꼭질 2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-71c2e542      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#숨바꼭질-2" class="uagb-toc-link__trigger">숨바꼭질 2</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">숨바꼭질 2</h1>



<p><a href="https://www.acmicpc.net/problem/12851">https://www.acmicpc.net/problem/12851</a></p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">512 MB</td><td class="has-text-align-left" data-align="left">42740</td><td class="has-text-align-left" data-align="left">12020</td><td class="has-text-align-left" data-align="left">8327</td><td class="has-text-align-left" data-align="left">25.678%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>수빈이는 동생과 숨바꼭질을 하고 있다. </p>



<p>수빈이는 현재 점 N(0 ≤ N ≤ 100,000)에 있고, 동생은 점 K(0 ≤ K ≤ 100,000)에 있다. </p>



<p>수빈이는 걷거나 순간이동을 할 수 있다. </p>



<p>만약, 수빈이의 위치가 X일 때 걷는다면 1초 후에 X-1 또는 X+1로 이동하게 된다. </p>



<p>순간이동을 하는 경우에는 1초 후에 2*X의 위치로 이동하게 된다.</p>



<p>수빈이와 동생의 위치가 주어졌을 때, </p>



<p>수빈이가 동생을 찾을 수 있는 가장 빠른 시간이 몇 초 후인지 </p>



<p>그리고, 가장 빠른 시간으로 찾는 방법이 몇 가지 인지 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫 번째 줄에 수빈이가 있는 위치 N과 동생이 있는 위치 K가 주어진다. </p>



<p>N과 K는 정수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 수빈이가 동생을 찾는 가장 빠른 시간을 출력한다.</p>



<p>둘째 줄에는 가장 빠른 시간으로 수빈이가 동생을 찾는 방법의 수를 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 17</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4
2</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>일반적으로 BFS 방문 체크는 Queue에 넣기 전에 해주지만 </p>



<p>이 문제는 Queue에서 꺼내는 경우 방문 처리를 해주면 된다. </p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;queue>
using namespace std;
queue&lt;pair&lt;int, int>> _BfsQueue;
bool _isVisted[100001];
int _N, _K, _Res = INT32_MAX ,_ResCnt;
int main()
{
	cin >> _N >> _K;
	// 위치, 시간
	pair&lt;int, int> _Pos = make_pair(_N, 0);
	_BfsQueue.push(_Pos);
	while (!_BfsQueue.empty()) {
		_Pos = _BfsQueue.front();
		_BfsQueue.pop();
		int _pos = _Pos.first;
		if (_Res &lt; _Pos.second)
			break;
		_isVisted[_pos] = true;

		if (_pos == _K) {
			_isVisted[_pos] = false;
			_Res = _Pos.second;
			_ResCnt++;
		}

		for (int i = 0; i &lt; 3; i++) {
			switch (i)
			{
				case 0:
					_pos = _Pos.first - 1;
					break;
				case 1:
					_pos = _Pos.first + 1;
					break;
				case 2:
					_pos = _Pos.first * 2;
					break;
			}

			if (_pos &lt;= -1 || _pos >= 100001 || (_isVisted[_pos]))
				continue;
			_BfsQueue.push(make_pair(_pos, _Pos.second + 1));		
		}
	}

	cout &lt;&lt; _Res &lt;&lt; "\n" &lt;&lt; _ResCnt;

	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="965" height="84" src="https://lycos7560.com/wp-content/uploads/2023/07/image-17.png" alt="" class="wp-image-35787" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-17.png 965w, https://lycos7560.com/wp-content/uploads/2023/07/image-17-300x26.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-17-768x67.png 768w" sizes="(max-width: 965px) 100vw, 965px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12851%eb%b2%88-%ec%88%a8%eb%b0%94%ea%bc%ad%ec%a7%88-2-c-baekjoon/35778/">백준 12851번 (숨바꼭질 2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12851%eb%b2%88-%ec%88%a8%eb%b0%94%ea%bc%ad%ec%a7%88-2-c-baekjoon/35778/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 5427번 (불, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-5427%eb%b2%88-%eb%b6%88-c-baekjoon/35736/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-5427%eb%b2%88-%eb%b6%88-c-baekjoon/35736/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 07 Jul 2023 02:12:40 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[5427]]></category>
		<category><![CDATA[5427번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Fire]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[그래프 이론]]></category>
		<category><![CDATA[그래프 탐색]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 5427]]></category>
		<category><![CDATA[백준 5427번]]></category>
		<category><![CDATA[불]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35736</guid>

					<description><![CDATA[<p>백준 5427번 '불' 문제에 대한 글입니다. BFS 탐색을 이용하여 해결하였습니다. (This article is about the issue of "fire" in BaekJoon Number 5427. It was solved using BFS Search.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-5427%eb%b2%88-%eb%b6%88-c-baekjoon/35736/">백준 5427번 (불, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-e5946293      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#불" class="uagb-toc-link__trigger">불</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">불</h1>



<p><a href="https://www.acmicpc.net/problem/5427" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/5427</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">34977</td><td class="has-text-align-left" data-align="left">9216</td><td class="has-text-align-left" data-align="left">6102</td><td class="has-text-align-left" data-align="left">24.356%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>상근이는 빈 공간과 벽으로 이루어진 건물에 갇혀있다. </p>



<p>건물의 일부에는 불이 났고, 상근이는 출구를 향해 뛰고 있다.</p>



<p>매 초마다, 불은 동서남북 방향으로 인접한 빈 공간으로 퍼져나간다. </p>



<p>벽에는 불이 붙지 않는다. 상근이는 동서남북 인접한 칸으로 이동할 수 있으며, 1초가 걸린다. </p>



<p>상근이는 벽을 통과할 수 없고, 불이 옮겨진 칸 또는 이제 불이 붙으려는 칸으로 이동할 수 없다. </p>



<p>상근이가 있는 칸에 불이 옮겨옴과 동시에 다른 칸으로 이동할 수 있다.</p>



<p>빌딩의 지도가 주어졌을 때, 얼마나 빨리 빌딩을 탈출할 수 있는지 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 테스트 케이스의 개수가 주어진다. </p>



<p>테스트 케이스는 최대 100개이다.</p>



<p>각 테스트 케이스의 첫째 줄에는 빌딩 지도의 너비와 높이 w와 h가 주어진다. (1 ≤ w,h ≤ 1000)</p>



<p>다음 h개 줄에는 w개의 문자, 빌딩의 지도가 주어진다.</p>



<ul class="wp-block-list">
<li>&#8216;.&#8217;: 빈 공간</li>



<li>&#8216;#&#8217;: 벽</li>



<li>&#8216;@&#8217;: 상근이의 시작 위치</li>



<li>&#8216;*&#8217;: 불</li>
</ul>



<p>각 지도에 @의 개수는 하나이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>각 테스트 케이스마다 빌딩을 탈출하는데 가장 빠른 시간을 출력한다. </p>



<p>빌딩을 탈출할 수 없는 경우에는 &#8220;IMPOSSIBLE&#8221;을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
4 3
####
#*@.
####
7 6
###.###
#*#.#*#
#.....#
#.....#
#..@..#
#######
7 4
###.###
#....*#
#@....#
.######
5 5
.....
.***.
.*@*.
.***.
.....
3 3
###
#@#
###</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2
5
IMPOSSIBLE
IMPOSSIBLE
IMPOSSIBLE</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/1" target="_blank" rel="noreferrer noopener">ICPC</a> > <a href="https://www.acmicpc.net/category/7" target="_blank" rel="noreferrer noopener">Regionals</a> > <a href="https://www.acmicpc.net/category/10" target="_blank" rel="noreferrer noopener">Europe</a> > <a href="https://www.acmicpc.net/category/15" target="_blank" rel="noreferrer noopener">Northwestern European Regional Contest</a> > <a href="https://www.acmicpc.net/category/89" target="_blank" rel="noreferrer noopener">Benelux Algorithm Programming Contest</a> > <a href="https://www.acmicpc.net/category/detail/424" target="_blank" rel="noreferrer noopener">BAPC 2012</a> F번</p>



<ul class="wp-block-list">
<li>문제의 오타를 찾은 사람: <a href="https://www.acmicpc.net/user/adh0463">a</a><a href="https://www.acmicpc.net/user/adh0463" target="_blank" rel="noreferrer noopener">d</a><a href="https://www.acmicpc.net/user/adh0463">h0463</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/b8goal" target="_blank" rel="noreferrer noopener">b8goal</a>, <a href="https://www.acmicpc.net/user/djm03178" target="_blank" rel="noreferrer noopener">djm03178</a></li>



<li>문제를 번역한 사람: <a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/7" target="_blank" rel="noreferrer noopener">그래프 이론</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/11" target="_blank" rel="noreferrer noopener">그래프 탐색</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/126" target="_blank" rel="noreferrer noopener">너비 우선 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>해당 좌표에 불이 언제 도착하는지 먼저 BFS 탐색을 이용하여 확인하고</p>



<p>상근이의 위치에서 BFS 탐색을 이용하여 출구를 찾는다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;queue>

using namespace std;

int _T, _W, _H, _Res;
pair&lt;int, int> _CntPos;
int _Map[1002][1002];
bool _IsVisted[1002][1002], _Check;
string _TStr;
// 상, 하, 좌, 우
int _DxDy[4][2] = { {1,0}, {-1,0}, {0,1}, {0,-1} };
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _T;
	while (_T-- > 0) {
		cin >> _W >> _H;
		queue&lt;pair&lt;int, int>> _FireQueue;
		_Check = false;
		for (int i = 1; i &lt;= _H; i++) {
			cin >> _TStr;
			for (int j = 1; j &lt;= _W; j++) {
				if (_TStr[j - 1] == '@') _CntPos = make_pair(i, j);
				else if (_TStr[j - 1] == '*') {
					_Map[i][j] = 1;
					_FireQueue.push(make_pair(i, j));
				}
				else if (_TStr[j - 1] == '#')
					_Map[i][j] = -1;
			}
		}

		while (!_FireQueue.empty()) {
			pair&lt;int, int> _CntFirePos = _FireQueue.front();
			_FireQueue.pop();
			for (int i = 0; i &lt; 4; i++) {
				int _dx = _CntFirePos.first + _DxDy[i][0];
				int _dy = _CntFirePos.second + _DxDy[i][1];
				// 이미 불이 있거나 벽이면 넘어간다.
				if (_Map[_dx][_dy] == -1) continue;
				if (_Map[_dx][_dy] > 0) continue;
				// 범위를 벗어나는 경우 넘어간다.
				if (_dx > _H || _dx &lt;= 0 || _dy > _W || _dy &lt;= 0) continue;
				_Map[_dx][_dy] = _Map[_CntFirePos.first][_CntFirePos.second] + 1;
				_FireQueue.push(make_pair(_dx, _dy));
			}
		}

		// 순서, x, y
		queue&lt; pair&lt;int, pair&lt;int, int>>> _BFSQueue;
		_BFSQueue.push(make_pair(1, _CntPos));
		_IsVisted[_CntPos.first][_CntPos.second] = true;
		while (!_BFSQueue.empty()) {
			int _cnt = _BFSQueue.front().first;
			pair&lt;int, int> _cntPos = _BFSQueue.front().second;
			_BFSQueue.pop();
			for (int i = 0; i &lt; 4; i++) {
				int _dx = _cntPos.first + _DxDy[i][0];
				int _dy = _cntPos.second + _DxDy[i][1];
				// 벽이거나 해당 칸에 불이 붙는 순서와 비교하여 갈 수 없으면 넘어간다.
				if (_Map[_dx][_dy] == -1 || (_Map[_dx][_dy] &lt;= _cnt + 1 &amp;&amp; _Map[_dx][_dy] != 0) || _IsVisted[_dx][_dy]) continue;
				// 탈출에 성공하는 경우
				if (_dx > _H || _dx &lt;= 0 || _dy > _W || _dy &lt;= 0) {
					_Res = _cnt;
					_Check = true;
					break;
				}

				_BFSQueue.push(make_pair(_cnt + 1, make_pair(_dx, _dy)));
				_IsVisted[_dx][_dy] = true;
			}
			if (_Check)
				break;
		}

		if (_Check) cout &lt;&lt; _Res &lt;&lt; "\n";
		else cout &lt;&lt; "IMPOSSIBLE" &lt;&lt; "\n";

		// 초기화
		for (int i = 1; i &lt;= _H; i++) {
			for (int j = 1; j &lt;= _W; j++) {
				_Map[i][j] = 0;
				_IsVisted[i][j] = false;
			}
		}
	}

	return 0;
}
</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1207" height="137" src="https://lycos7560.com/wp-content/uploads/2023/07/image-14.png" alt="" class="wp-image-35747" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-14.png 1207w, https://lycos7560.com/wp-content/uploads/2023/07/image-14-300x34.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-14-768x87.png 768w" sizes="(max-width: 1207px) 100vw, 1207px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-5427%eb%b2%88-%eb%b6%88-c-baekjoon/35736/">백준 5427번 (불, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-5427%eb%b2%88-%eb%b6%88-c-baekjoon/35736/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Programmers 121690 4번 보물 지도 [PCCP 모의고사 2회]</title>
		<link>https://lycos7560.com/cpp/programmers/programmers-121690-4%eb%b2%88-%eb%b3%b4%eb%ac%bc-%ec%a7%80%eb%8f%84-pccp-%eb%aa%a8%ec%9d%98%ea%b3%a0%ec%82%ac-2%ed%9a%8c/35629/</link>
					<comments>https://lycos7560.com/cpp/programmers/programmers-121690-4%eb%b2%88-%eb%b3%b4%eb%ac%bc-%ec%a7%80%eb%8f%84-pccp-%eb%aa%a8%ec%9d%98%ea%b3%a0%ec%82%ac-2%ed%9a%8c/35629/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 02 Jul 2023 22:15:56 +0000</pubDate>
				<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[[PCCP 모의고사 2]]]></category>
		<category><![CDATA[121690]]></category>
		<category><![CDATA[121690번]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[PCCP]]></category>
		<category><![CDATA[Programmers 121690]]></category>
		<category><![CDATA[Programmers 121690번]]></category>
		<category><![CDATA[Programmers Certified Coding Professional]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그래프]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[깊이]]></category>
		<category><![CDATA[깊이 우선 탐색]]></category>
		<category><![CDATA[모의고사]]></category>
		<category><![CDATA[보물 지도]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩전문역량인증]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[탐색]]></category>
		<category><![CDATA[프로그래머스]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35629</guid>

					<description><![CDATA[<p>programmers 121690번 '보물 지도' 문제에 대한 글입니다. BFS 탐색을 이용하여 해결하였습니다. (This article is about the problem of 'Treasure Map' in programmers 121690. It was solved using BFS Search.) [PCCP]</p>
<p>The post <a href="https://lycos7560.com/cpp/programmers/programmers-121690-4%eb%b2%88-%eb%b3%b4%eb%ac%bc-%ec%a7%80%eb%8f%84-pccp-%eb%aa%a8%ec%9d%98%ea%b3%a0%ec%82%ac-2%ed%9a%8c/35629/">Programmers 121690 4번 보물 지도 [PCCP 모의고사 2회]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-8bbbaa18      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#보물-지도" class="uagb-toc-link__trigger">보물 지도</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">보물 지도</h1>



<p class="has-small-font-size"><a href="https://school.programmers.co.kr/learn/courses/15009/lessons/121690" target="_blank" rel="noreferrer noopener">https://school.programmers.co.kr/learn/courses/15009/lessons/121690</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제 설명</h3>



<p>진수는 보물이 묻힌 장소와 함정이 표시된 보물 지도를 이용해 보물을 찾으려 합니다. </p>



<p>보물지도는 가로 길이가 <code>n</code>, 세로 길이가 <code>m</code>인 직사각형 모양입니다.</p>



<p>맨 왼쪽 아래 칸의 좌표를 (1, 1)으로, 맨 오른쪽 위 칸의 좌표를 (n, m)으로 나타냈을 때, 보물은 (n, m) 좌표에 묻혀있습니다. </p>



<p>또한, 일부 칸에는 함정이 있으며, 해당 칸으로는 지나갈 수 없습니다.</p>



<p>진수는 처음에 (1, 1) 좌표에서 출발해 보물이 있는 칸으로 이동하려 합니다. </p>



<p>이동할 때는 [상,하,좌,우]로 인접한 네 칸 중 한 칸으로 걸어서 이동합니다. </p>



<p>한 칸을 걸어서 이동하는 데 걸리는 시간은 1입니다.</p>



<p>진수는 보물이 위치한 칸으로 수월하게 이동하기 위해 신비로운 신발을 하나 준비했습니다. </p>



<p>이 신발을 신고 뛰면 한 번에 두 칸을 이동할 수 있으며, 함정이 있는 칸도 넘을 수 있습니다. </p>



<p>하지만, 이 신발은 한 번밖에 사용할 수 없습니다. </p>



<p>신비로운 신발을 사용하여 뛰어서 두 칸을 이동하는 시간도 1입니다.</p>



<p>이때 진수가 출발점에서 보물이 위치한 칸으로 이동하는데 필요한 최소 시간을 구해야 합니다.</p>



<p>예를 들어, 진수의 보물지도가 아래 그림과 같을 때, 진수가 걸어서 오른쪽으로 3칸, </p>



<p>걸어서 위쪽으로 3칸 이동하면 6의 시간에 보물이 위치한 칸으로 이동할 수 있습니다. </p>



<p>만약, 오른쪽으로 걸어서 1칸, 위쪽으로 걸어서 1칸, 신비로운 신발을 사용하여 위로 뛰어 2칸, </p>



<p>오른쪽으로 걸어서 2칸 이동한다면 총 5의 시간에 보물이 위치한 칸으로 이동할 수 있으며, </p>



<p>이보다 빠른 시간 내에 보물이 있는 위치에 도착할 수 없습니다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="460" height="461" src="https://lycos7560.com/wp-content/uploads/2023/07/image-1.png" alt="" class="wp-image-35631" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-1.png 460w, https://lycos7560.com/wp-content/uploads/2023/07/image-1-300x300.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-1-150x150.png 150w" sizes="(max-width: 460px) 100vw, 460px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>진수의 보물지도가 표현하는 지역의 가로 길이를 나타내는 정수 <code>n</code>, </p>



<p>세로 길이를 나타내는 정수 <code>m</code>, 함정의 위치를 나타내는 2차원 정수 배열 <code>hole</code>이 주어졌을 때, </p>



<p>진수가 보물이 있는 칸으로 이동하는데 필요한 최소 시간을 return 하는 solution 함수를 완성해주세요. </p>



<p><strong>단, 보물이 있는 칸으로 이동할 수 없다면, -1을 return 해야 합니다.</strong></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">제한사항</h3>



<ul class="wp-block-list">
<li>1 ≤ <code>n</code>, <code>m</code> ≤ 1,000
<ul class="wp-block-list">
<li>단,&nbsp;<code>n</code>&nbsp;*&nbsp;<code>m</code>이 3 이상인 경우만 입력으로 주어집니다.</li>
</ul>
</li>



<li>1 ≤ <code>hole</code>의 길이 ≤ <code>n</code> * <code>m</code> &#8211; 2
<ul class="wp-block-list">
<li><code>hole[i]</code>는 [a, b]의 형태이며, (a, b) 칸에 함정이 존재한다는 의미이며, 1 ≤ a ≤&nbsp;<code>n</code>, 1 ≤ b ≤&nbsp;<code>m</code>을 만족합니다.</li>



<li>같은 함정에 대한 정보가 중복해서 들어있지 않습니다.</li>
</ul>
</li>



<li>(1, 1) 칸과 (n, m) 칸은 항상 함정이 없습니다.</li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입출력 예</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">n</th><th class="has-text-align-left" data-align="left">m</th><th class="has-text-align-left" data-align="left">hole</th><th class="has-text-align-left" data-align="left">result</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">4</td><td class="has-text-align-left" data-align="left">4</td><td class="has-text-align-left" data-align="left">[[2, 3], [3, 3]]</td><td class="has-text-align-left" data-align="left">5</td></tr><tr><td class="has-text-align-left" data-align="left">5</td><td class="has-text-align-left" data-align="left">4</td><td class="has-text-align-left" data-align="left">[[1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 3], [4, 1], [4, 3], [5, 3]]</td><td class="has-text-align-left" data-align="left">-1</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-default" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h3 class="wp-block-heading has-large-font-size">입출력 예 설명</h3>



<p class="has-medium-font-size"><strong>입출력 예 #1</strong></p>



<ul class="wp-block-list">
<li>본문의 예시와 같습니다.</li>
</ul>



<p class="has-medium-font-size"><strong>입출력 예 #2</strong></p>



<ul class="wp-block-list">
<li>보물지도를 그림으로 나타내면 아래와 같으며, 보물이 위치한 칸으로 이동할 수 없습니다. <br>따라서, -1을 return 해야 합니다.</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="619" height="466" src="https://lycos7560.com/wp-content/uploads/2023/07/image-2.png" alt="" class="wp-image-35637" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-2.png 619w, https://lycos7560.com/wp-content/uploads/2023/07/image-2-300x226.png 300w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>신발은 구멍과 상관없이 사용해도 된다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;string>
#include &lt;vector>
#include &lt;tuple>
#include &lt;queue>
bool _Map[1001][1001];
bool _IsVisted[1001][1001][2]; // 배열의 마지막은 신발의 사용 유무
int _dxdy[8][2] = { {1,0},{0,1},{-1,0},{0,-1}, {2,0},{0,2},{-2,0},{0,-2} };
using namespace std;
int solution(int n, int m, vector&lt;vector&lt;int>> holeVector) {
    int answer = -1;
	for (auto&amp; hole : holeVector)
		_Map[hole[0]][hole[1]] = true;
	tuple&lt;int, int, bool, int> _CntPos = make_tuple(1, 1, true, 0);
	queue&lt;tuple&lt;int, int, bool, int>> _MyQueue;
	_IsVisted[1][1][1] = true;
	_MyQueue.push(_CntPos);
	while (!_MyQueue.empty()) {
		_CntPos = _MyQueue.front();
		_MyQueue.pop();
		int _cntX = get&lt;0>(_CntPos);
		int _cntY = get&lt;1>(_CntPos);
		bool _shoes = get&lt;2>(_CntPos);
		int _cnt = get&lt;3>(_CntPos);	

		// 목적지에 도착
		if (_cntX == n &amp;&amp; _cntY == m) {
				answer = _cnt;
				break;
		}

		// 총 8가지의 경우를 탐색
		// 0 ~ 3 상,하,좌,우
		// 4 ~ 7 신발을 사용하여 상,하,좌,우를 2칸씩 이동
		// 꼭 구멍이 있어야 신발을 사용하는 것이 아니다.
		for (int i = 0; i &lt; 8; i++) {
			if (!_shoes &amp;&amp; i >= 4) break;
			int _dx = _cntX + _dxdy[i][0];
			int _dy = _cntY + _dxdy[i][1];
			// 맵의 범위를 벗어나는 경우
			if (_dx > n || _dy > m || _dx &lt;= 0 || _dy &lt;= 0 ) 
				continue;
			// 이동을 하려던 곳이 구멍 &amp;&amp; 신발이 없음 || 이미 방문한 적이 있다.
			if (_Map[_dx][_dy] || _IsVisted[_dx][_dy][_shoes])
				continue;

			if (i >= 4) { // 신발을 사용하여 이동하는 경우
				_MyQueue.push(make_tuple(_dx, _dy, false, _cnt + 1));
				_IsVisted[_dx][_dy][false] = true;
			}
			else { // 신발을 사용하지 않는 경우
				_MyQueue.push(make_tuple(_dx, _dy, _shoes, _cnt + 1));
				_IsVisted[_dx][_dy][_shoes] = true;
			}

		}
	}

	return answer;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="554" height="590" src="https://lycos7560.com/wp-content/uploads/2023/07/image-3.png" alt="" class="wp-image-35640" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-3.png 554w, https://lycos7560.com/wp-content/uploads/2023/07/image-3-282x300.png 282w" sizes="(max-width: 554px) 100vw, 554px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/programmers/programmers-121690-4%eb%b2%88-%eb%b3%b4%eb%ac%bc-%ec%a7%80%eb%8f%84-pccp-%eb%aa%a8%ec%9d%98%ea%b3%a0%ec%82%ac-2%ed%9a%8c/35629/">Programmers 121690 4번 보물 지도 [PCCP 모의고사 2회]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/programmers/programmers-121690-4%eb%b2%88-%eb%b3%b4%eb%ac%bc-%ec%a7%80%eb%8f%84-pccp-%eb%aa%a8%ec%9d%98%ea%b3%a0%ec%82%ac-2%ed%9a%8c/35629/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
