<?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/%ED%8B%80%EB%A0%B8%EC%8A%B5%EB%8B%88%EB%8B%A4/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Thu, 28 Mar 2024 11:44:31 +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>백준 14500번 (테트로미노, C++) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14500%eb%b2%88-%ed%85%8c%ed%8a%b8%eb%a1%9c%eb%af%b8%eb%85%b8-c-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33194/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14500%eb%b2%88-%ed%85%8c%ed%8a%b8%eb%a1%9c%eb%af%b8%eb%85%b8-c-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33194/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 16 Feb 2023 01:53:01 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[14500]]></category>
		<category><![CDATA[14500번]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[BruteForce]]></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[백준 14500]]></category>
		<category><![CDATA[백준 14500번]]></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=33194</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 14500번 '테트로미노' 문제에 대한 글입니다. 'brute force' 알고리즘과 'DFS 탐색'을 이용하여 해결하였습니다. (This is BAEKJOON's 14500 article on the 'Tetromino' problem. It was solved using the 'brute force' algorithm and 'DFS search'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14500%eb%b2%88-%ed%85%8c%ed%8a%b8%eb%a1%9c%eb%af%b8%eb%85%b8-c-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33194/">백준 14500번 (테트로미노, 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-6eabfa96      "
					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><li class="uagb-toc__list"><a href="#추가-반례" class="uagb-toc-link__trigger">추가 반례</a></ol>					</div>
									</div>
				</div>
			


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



<h1 class="wp-block-heading">테트로미노</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/14500" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/14500</a></p>



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



<figure id="problem-info" 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">69583</td><td class="has-text-align-left" data-align="left">26178</td><td class="has-text-align-left" data-align="left">17011</td><td class="has-text-align-left" data-align="left">35.673%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">폴리오미노란 크기가 1×1인 정사각형을 여러 개 이어서 붙인 도형이며, 다음과 같은 조건을 만족해야 한다.</p>



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



<p class="has-medium-font-size">정사각형은 서로 겹치면 안 된다.</p>



<p class="has-medium-font-size">도형은 모두 연결되어 있어야 한다.</p>



<p class="has-medium-font-size">정사각형의 변끼리 연결되어 있어야 한다. 즉, 꼭짓점과 꼭짓점만 맞닿아 있으면 안 된다.</p>



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



<p class="has-medium-font-size">정사각형 4개를 이어 붙인 폴리오미노는 테트로미노라고 하며, 다음과 같은 5가지가 있다.</p>



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



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="488" height="308" src="https://lycos7560.com/wp-content/uploads/2023/02/image-73.png" alt="" class="wp-image-33195" srcset="https://lycos7560.com/wp-content/uploads/2023/02/image-73.png 488w, https://lycos7560.com/wp-content/uploads/2023/02/image-73-300x189.png 300w" sizes="(max-width: 488px) 100vw, 488px" /></figure>



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



<p class="has-medium-font-size">아름이는 크기가 N×M인 종이 위에 테트로미노 하나를 놓으려고 한다. </p>



<p class="has-medium-font-size">종이는 1×1 크기의 칸으로 나누어져 있으며, 각각의 칸에는 정수가 하나 쓰여 있다.</p>



<p class="has-medium-font-size">테트로미노 하나를 적절히 놓아서 테트로미노가 놓인 칸에 쓰여 있는 수들의 합을 최대로 하는 프로그램을 작성하시오.</p>



<p class="has-medium-font-size">테트로미노는 반드시 한 정사각형이 정확히 하나의 칸을 포함하도록 놓아야 하며, 회전이나 대칭을 시켜도 된다.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 종이의 세로 크기 N과 가로 크기 M이 주어진다. (4&nbsp;≤ N, M ≤ 500)</p>



<p class="has-medium-font-size">둘째 줄부터 N개의 줄에 종이에 쓰여 있는 수가 주어진다. </p>



<p class="has-medium-font-size">i번째 줄의 j번째 수는 위에서부터 i번째 칸, 왼쪽에서부터 j번째 칸에 쓰여 있는 수이다. </p>



<p class="has-medium-font-size">입력으로 주어지는 수는 1,000을 넘지 않는 자연수이다.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 테트로미노가 놓인 칸에 쓰인 수들의 합의 최댓값을 출력한다.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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 5
1 2 3 4 5
5 4 3 2 1
2 3 4 5 6
6 5 4 3 2
1 2 1 2 1</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">19</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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="">20</pre>



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



<h2 class="wp-block-heading">예제 입력 3</h2>



<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 10
1 2 1 2 1 2 1 2 1 2
2 1 2 1 2 1 2 1 2 1
1 2 1 2 1 2 1 2 1 2
2 1 2 1 2 1 2 1 2 1</pre>



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



<h2 class="wp-block-heading">예제 출력 3</h2>



<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</pre>



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



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



<ul class="wp-block-list">
<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/appie701" target="_blank" rel="noreferrer noopener">appie701</a>, <a href="https://www.acmicpc.net/user/crookid" target="_blank" rel="noreferrer noopener">crookid</a>, <a href="https://www.acmicpc.net/user/esuperstar" target="_blank" rel="noreferrer noopener">esuperstar</a>, <a href="https://www.acmicpc.net/user/raboribus" target="_blank" rel="noreferrer noopener">raboribus</a>, <a href="https://www.acmicpc.net/user/rlatpwlsdlek" target="_blank" rel="noreferrer noopener">rlatpwlsdlek</a>, <a href="https://www.acmicpc.net/user/stack" target="_blank" rel="noreferrer noopener">stack</a>, <a href="https://www.acmicpc.net/user/vjerksen" target="_blank" rel="noreferrer noopener">vjerksen</a></li>



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



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



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



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



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



<li><a href="https://www.acmicpc.net/problem/tag/125" 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)"/>



<figure class="wp-block-image size-full"><img decoding="async" width="389" height="284" src="https://lycos7560.com/wp-content/uploads/2023/02/image-75.png" alt="" class="wp-image-33204" srcset="https://lycos7560.com/wp-content/uploads/2023/02/image-75.png 389w, https://lycos7560.com/wp-content/uploads/2023/02/image-75-300x219.png 300w" sizes="(max-width: 389px) 100vw, 389px" /></figure>



<p class="has-medium-font-size">DFS 탐색</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="283" height="161" src="https://lycos7560.com/wp-content/uploads/2023/02/image-77.png" alt="" class="wp-image-33206"/></figure>



<p class="has-medium-font-size">BFS 탐색 (나는 예외 처리로 해결)</p>



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



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



<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;

constexpr int MAX = 500;

int map[MAX][MAX];

bool checkMap[MAX][MAX];

int N, M, result = 0;

// 탐색하는 방향 설정 =>  상, 하 ,좌 ,우
int dxdy[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };

void DFS_Search(int nowX, int nowY, int cnt, int val)
{
	if (cnt == 4) {
		result = max(result, val);
		return;
	}

	for (int i = 0; i &lt; 4; i++) {

		int dx = nowX + dxdy[i][0];
		int dy = nowY + dxdy[i][1];

		// 범위를 벗어나면 넘어간다.
		if (dx &lt; 0 || dy &lt; 0 || dx >= N || dy >= M) continue;
		// 방문했다면 넘어간다.
		if (checkMap[dx][dy] == true) continue;

		cnt++;
		val += map[dx][dy];
		checkMap[dx][dy] = true;
		DFS_Search(dx, dy, cnt, val);
		checkMap[dx][dy] = false;
		cnt--;
		val -= map[dx][dy];

	}
}

// 'ㅗ' 탐색을 위한 함수
void Exception_Search(int nowX, int nowY, int val)
{
	for (int i = 0; i &lt; 4; i++) {
		int dx = nowX + dxdy[i][0];
		int dy = nowY + dxdy[i][1];
		if (dx &lt; 0 || dy &lt; 0 || dx >= N || dy >= M) continue;
		val += map[dx][dy];
	}

	for (int i = 0; i &lt; 4; i++) {
		int dx = nowX + dxdy[i][0];
		int dy = nowY + dxdy[i][1];

		if (dx &lt; 0 || dy &lt; 0 || dx >= N || dy >= M) {
			result = max(result, val);
			continue;
		}

		val -= map[dx][dy];
		result = max(result, val);
		val += map[dx][dy];
	}

}


int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	std::cout.tie(NULL);

	cin >> N >> M;

	for (int i = 0; i &lt; N; i++) {
		for (int j = 0; j &lt; M; j++) {
			cin >> map[i][j];
		}
	}

	for (int i = 0; i &lt; N; i++) {
		for (int j = 0; j &lt; M; j++) {
			checkMap[i][j] = true;
			DFS_Search(i, j, 1, map[i][j]);
			checkMap[i][j] = false;
			Exception_Search(i, j, map[i][j]);
		}
	}

	cout &lt;&lt; result;

	return 0;
}</pre>



<div style="height:20px" 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/02/image-74.png" alt="" class="wp-image-33198" width="877" height="150" srcset="https://lycos7560.com/wp-content/uploads/2023/02/image-74.png 746w, https://lycos7560.com/wp-content/uploads/2023/02/image-74-300x51.png 300w" sizes="(max-width: 877px) 100vw, 877px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1292" height="646" src="https://lycos7560.com/wp-content/uploads/2023/02/image-79.png" alt="" class="wp-image-33209" srcset="https://lycos7560.com/wp-content/uploads/2023/02/image-79.png 1292w, https://lycos7560.com/wp-content/uploads/2023/02/image-79-300x150.png 300w, https://lycos7560.com/wp-content/uploads/2023/02/image-79-768x384.png 768w" sizes="(max-width: 1292px) 100vw, 1292px" /></figure>



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



<h1 class="wp-block-heading">추가 반례</h1>



<p><a href="https://www.acmicpc.net/board/view/61597" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/board/view/61597</a></p>



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



<h2 class="wp-block-heading">예제 입력 A</h2>



<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 10
3 3 6 4 1 4 8 5 3 2
9 5 1 2 4 1 9 9 5 5
2 5 1 2 3 3 3 7 6 4
1 6 5 6 4 7 4 7 7 4
3 8 5 9 6 4 2 6 1 1
6 3 3 7 1 2 2 2 8 4</pre>



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



<h2 class="wp-block-heading">예제 출력 A</h2>



<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="">33</pre>



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



<h2 class="wp-block-heading">예제 입력 B</h2>



<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 4
1 1 1 1
2 1000 1 1
1 1000 2 1
1 1 1 1</pre>



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



<h2 class="wp-block-heading">예제 출력 B</h2>



<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="">2004</pre>



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



<h2 class="wp-block-heading">예제 입력 C</h2>



<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 4
0 0 0 0
0 0 0 0
0 0 0 0
1 2 3 4

4 4
0 0 0 1
0 0 0 2
0 0 0 3
0 0 0 4

4 4
0 0 0 0
0 0 0 0
0 0 1 2
0 0 3 4

4 4
0 0 0 0
0 0 1 0
0 0 2 0
0 0 3 4

4 4
0 0 0 0
0 0 0 0
0 1 2 3
0 4 0 0

4 4
0 0 0 0
0 0 1 2
0 0 0 3
0 0 0 4

4 4
0 0 0 0
0 0 0 0
0 0 0 1
0 4 3 2

4 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 4 3

4 4
0 0 0 0
0 0 0 0
0 1 0 0
0 2 3 4

4 4
0 0 0 0
0 0 2 1
0 0 3 0
0 0 4 0

4 4
0 0 0 0
0 0 0 0
0 1 2 3
0 0 0 4

4 4
0 0 0 0
0 0 0 1
0 0 2 3
0 0 4 0

4 4
0 0 0 0
0 0 1 0
0 0 2 3
0 0 0 4

4 4
0 0 0 0
0 0 0 0
0 1 2 0
0 0 3 4

4 4
0 0 0 0
0 0 0 0
0 0 3 4
0 1 2 0

4 4
0 0 0 0
0 0 0 1
0 0 2 3
0 0 0 4

4 4
0 0 0 0
0 0 1 0
0 0 2 3
0 0 4 0

4 4
0 0 0 0
0 0 0 0
0 0 1 0
0 2 3 4

4 4
0 0 0 0
0 0 0 0
0 1 2 3
0 0 4 0</pre>



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



<h2 class="wp-block-heading">예제 출력 C</h2>



<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="">10</pre>



<div style="height:60px" 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-14500%eb%b2%88-%ed%85%8c%ed%8a%b8%eb%a1%9c%eb%af%b8%eb%85%b8-c-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33194/">백준 14500번 (테트로미노, 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-14500%eb%b2%88-%ed%85%8c%ed%8a%b8%eb%a1%9c%eb%af%b8%eb%85%b8-c-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33194/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1738번 (골목길, C++, Bellman–Ford) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1738%eb%b2%88-%ea%b3%a8%eb%aa%a9%ea%b8%b8-c-bellman-ford-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33119/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1738%eb%b2%88-%ea%b3%a8%eb%aa%a9%ea%b8%b8-c-bellman-ford-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33119/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sat, 11 Feb 2023 01:19:36 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1738]]></category>
		<category><![CDATA[1738번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[Bellman–Ford]]></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[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1738]]></category>
		<category><![CDATA[백준 1738번]]></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=33119</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 1738번 '골목길' 문제에 대한 글입니다. Bellman–Ford 알고리즘을 이용하여 해결하였습니다. (This is an article about the 'Alley Road' problem in BAEKJOON 1738. Solved using Bellman–Ford algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1738%eb%b2%88-%ea%b3%a8%eb%aa%a9%ea%b8%b8-c-bellman-ford-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33119/">백준 1738번 (골목길, C++, Bellman–Ford) / 추가 반례 [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-56e81e2a      "
					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><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:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">골목길</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1738" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1738</a></p>



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



<figure id="problem-info" 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">5531</td><td class="has-text-align-left" data-align="left">932</td><td class="has-text-align-left" data-align="left">552</td><td class="has-text-align-left" data-align="left">17.824%</td></tr></tbody></table></figure>



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



<p class="has-medium-font-size">민승이는&nbsp;놀러가기 위해 집을 나섰다. </p>



<p class="has-medium-font-size">민승이네 집에서 코레스코 콘도까지 가기 위해서는 복잡하게 얽혀있는 골목길들을 통과해야 한다.</p>



<p class="has-medium-font-size">그런데, 어떤 길에는 깡패가 서식하고 있어, 그 길을 지나게 되면 깡패에게 일정한 양의 금품을 갈취당하게 된다. </p>



<p class="has-medium-font-size">그런가하면, 어떤 길에는 지나가던 행인들이 흘리고 간 금품들이 떨어져 있어, 그 길을 지나게 되면 일정한 양의 금품을 획득하게 된다.&nbsp;</p>



<p class="has-medium-font-size">한 번 지나간 길을 다시 방문하더라도 금품을 갈취당하거나 획득한다.</p>



<p class="has-medium-font-size">골목길의 연결 상태와, 각 골목길을 지날 때 갈취당하거나 획득하게 되는 금품의 양이 주어졌을 때, </p>



<p class="has-medium-font-size">민승이가 최대한 유리한 경로를 따라 집에서 코레스코 콘도까지 가기 위해서는 어떻게 해야 하는지 출력하는 프로그램을 작성하시오.&nbsp;</p>



<p class="has-medium-font-size">보유 중인 금품의 양이 음수가 될 수 있다.&nbsp;</p>



<p class="has-medium-font-size">최대한 유리한 경로 또는 최적의 경로는 민승이네 집에서 출발하여 코레스코 콘도에 도착하는 경로 중 금품의 양이 최대가 되는 경로이다.&nbsp;</p>



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



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



<p class="has-medium-font-size">첫째 줄에 골목길들이 교차하는 지점의 개수&nbsp;n (2 ≤ n ≤ 100)과 </p>



<p class="has-medium-font-size">골목길의 개수&nbsp;m&nbsp;(1 ≤ m ≤ 20,000)&nbsp;이 차례로 주어진다. </p>



<p class="has-medium-font-size">이어지는 m개의 행에 각각의 골목길을 나타내는 세 정수 u, v, w가 차례로 주어진다. </p>



<p class="has-medium-font-size">이는 u번 교차점에서 v번 교차점으로 이동할 수 있는 골목길이 나있다는 의미이다. </p>



<p class="has-medium-font-size">즉, 주어지는 골목길들은 기본적으로 모두 일방통행로이다.</p>



<p class="has-medium-font-size">w (0 ≤ |w| ≤ 1,000)는 이 길을 지날 때 갈취당하거나 획득하게 되는 금품의 양이다. </p>



<p class="has-medium-font-size">음수는 갈취, 양수는 획득을 뜻한다.</p>



<p class="has-medium-font-size">골목길의 교차점 번호는 1이상 n이하의 정수이다. </p>



<p class="has-medium-font-size">민승이네 집은 1번 교차점에 있고, 이곳 코레스코 콘도는 n번 교차점에 있다.</p>



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



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



<p class="has-medium-font-size">최적의 경로를 구할 수 있다면 민승이네 집부터 코레스코 콘도까지 가는 동안 거치게 되는 </p>



<p class="has-medium-font-size">교차점들의 번호를 공백 하나를 사이에 두고 차례로 출력하면 된다.&nbsp;</p>



<p class="has-medium-font-size">그런데, 경우에 따라서는 최적의 경로라는 것이 존재하지 않는 상황이 발생한다. </p>



<p class="has-medium-font-size">어떠한 경우에 그런 상황이 발생하는지 생각해 보자.&nbsp;</p>



<p class="has-medium-font-size">그러한 경우에는 -1을 출력하도록 한다.</p>



<p class="has-medium-font-size">최적의 경로가 여러 개 존재할 때는 아무거나 출력해도 된다.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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
1 2 3
1 3 4
3 1 -7
2 3 2
3 4 1
4 2 -5
4 5 1</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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 3 4 5</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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
1 2 3
1 3 4
3 1 -7
2 3 2
3 4 1
4 2 -2
4 5 1</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



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



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



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



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



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



<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/10" 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)"/>



<figure class="wp-block-embed is-type-wp-embed is-provider-어제와-내일의-나-그-사이의-이야기 wp-block-embed-어제와-내일의-나-그-사이의-이야기"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="fCwu8tviMy"><a href="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b2%a8%eb%a7%8c-%ed%8f%ac%eb%93%9c-bellman-ford-algorithm-%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%ec%a0%95%eb%a6%ac/33044/">알고리즘 &#8211; 벨만-포드 (Bellman–Ford Algorithm) 알고리즘 정리</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;알고리즘 &#8211; 벨만-포드 (Bellman–Ford Algorithm) 알고리즘 정리&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b2%a8%eb%a7%8c-%ed%8f%ac%eb%93%9c-bellman-ford-algorithm-%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%ec%a0%95%eb%a6%ac/33044/embed/#?secret=3wXyJtRRUm#?secret=fCwu8tviMy" data-secret="fCwu8tviMy" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<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)"/>



<h1 class="wp-block-heading">주의 사항</h1>



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



<p class="has-medium-font-size">이 문제는 Bellman–Ford 알고리즘을 사용할 때 사이클이 있다고 해서 무조건 -1 을 출력하면 안된다.</p>



<p class="has-medium-font-size">해당 사이클이 <strong>최적의 경로에 영향이 있는지 확인</strong>이 필요하다.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1409" height="1920" src="https://lycos7560.com/wp-content/uploads/2023/02/KakaoTalk_20230211_101542736.jpg" alt="" class="wp-image-33132" srcset="https://lycos7560.com/wp-content/uploads/2023/02/KakaoTalk_20230211_101542736.jpg 1409w, https://lycos7560.com/wp-content/uploads/2023/02/KakaoTalk_20230211_101542736-220x300.jpg 220w, https://lycos7560.com/wp-content/uploads/2023/02/KakaoTalk_20230211_101542736-768x1047.jpg 768w, https://lycos7560.com/wp-content/uploads/2023/02/KakaoTalk_20230211_101542736-1127x1536.jpg 1127w" sizes="(max-width: 1409px) 100vw, 1409px" /></figure>



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



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



<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 long long int INF = INT64_MAX;

constexpr int MAXN = 101;

vector&lt;pair&lt;int, int>> graph[MAXN];

long long int disArr[MAXN];

// N : 지점의 개수, M : 골목길의 개수
int N, M, u, v, w;

int trace[MAXN];

int main()
{

	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	std::cout.tie(NULL);

	cin >> N >> M;

	fill(disArr, disArr + MAXN, INF);

	disArr[1] = 0;

	for (int i = 0; i &lt; M; i++) {
		cin >> u >> v >> w;
		// 단방향
		graph[u].push_back(make_pair(v, -w));
	}


	// (모든 정점의 수 - 1) 번 확인한다.
	// N 번은 순환 체크
	for (int k = 1; k &lt;= N; k++) {
		for (int i = 1; i &lt;= N; i++) {
			for (int j = 0; j &lt; graph[i].size(); j++) {

				int u = i; // 시작점
				int v = graph[i][j].first; // 도착점
				int weight = graph[i][j].second; // 가중치

				// 만약 임시 배열이 무한대가 아니고 &amp;&amp;
				// 시작 임시 배열의 가중치가 도착지의 가중치보다 크다면
				if (disArr[u] != INF &amp;&amp; disArr[u] + weight &lt; disArr[v]) {
					disArr[v] = disArr[u] + weight;
					trace[v] = u;

					// K == N 일때 새로 업데이트 된다는 의미는 
					// 사이클에 포함되거나 사이클에서 도착 지점으로 도달 가능
					// 다음의 disArr[N] == -INF 코드를 통하여 영향이 있는 경로인지 판별 
					if (k == N) disArr[v] = -INF;
					// -INF로 더이상 업데이트를 막는다.
				}
			}
		}
	}

	if (disArr[N] == INF || disArr[N] == -INF) cout &lt;&lt; "-1";
	else {
		// 경로를 역으로 추적한다.
		int now = N;
		vector&lt;int> myV;
		while (now != 0) {
			myV.push_back(now);
			now = trace[now]; 
		}

		for (auto it = myV.rbegin(); it != myV.rend(); ++it) cout &lt;&lt; *it &lt;&lt; " ";

	}

	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="1032" height="372" src="https://lycos7560.com/wp-content/uploads/2023/02/image-65.png" alt="" class="wp-image-33121" srcset="https://lycos7560.com/wp-content/uploads/2023/02/image-65.png 1032w, https://lycos7560.com/wp-content/uploads/2023/02/image-65-300x108.png 300w, https://lycos7560.com/wp-content/uploads/2023/02/image-65-768x277.png 768w" sizes="(max-width: 1032px) 100vw, 1032px" /></figure>



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



<h1 class="wp-block-heading">추가 반례</h1>



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



<h2 class="wp-block-heading">예제 입력 A</h2>



<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 4
1 2 1
2 3 1
3 2 1
1 4 1</pre>



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



<h2 class="wp-block-heading">예제 출력 A</h2>



<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 4</pre>



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



<h2 class="wp-block-heading">예제 입력 B</h2>



<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 11
1 2 3
1 3 4
3 1 -7
2 3 2
3 4 1
4 2 -5
4 7 1
4 5 1
5 6 2
6 5 3
6 7 -1000</pre>



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



<h2 class="wp-block-heading">예제 출력 B</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 C</h2>



<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
1 2 1
2 3 1
3 4 1
4 5 1
1 5 10
1 2 50
2 5 80</pre>



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



<h2 class="wp-block-heading">예제 출력 C</h2>



<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 5</pre>



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



<h2 class="wp-block-heading">예제 입력 D</h2>



<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 5
1 2 -1
2 3 1
3 4 1
4 2 1
2 5 -1</pre>



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



<h2 class="wp-block-heading">예제 출력 D</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 E</h2>



<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 4
1 4 3
2 3 1
3 2 1
4 2 1</pre>



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



<h2 class="wp-block-heading">예제 출력 E</h2>



<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 4</pre>



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



<h2 class="wp-block-heading">예제 입력 F</h2>



<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 5
1 2 1
2 3 1
3 4 1
3 2 1
4 1 1</pre>



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



<h2 class="wp-block-heading">예제 출력 F</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 G</h2>



<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 5
1 2 1
2 3 1
3 4 1
3 1 1
4 1 1</pre>



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



<h2 class="wp-block-heading">예제 출력 G</h2>



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



<h2 class="wp-block-heading">예제 입력 H</h2>



<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 5
1 2 1
2 3 1
3 4 1
4 3 1
2 5 1</pre>



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



<h2 class="wp-block-heading">예제 출력 H</h2>



<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 5</pre>



<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-1738%eb%b2%88-%ea%b3%a8%eb%aa%a9%ea%b8%b8-c-bellman-ford-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33119/">백준 1738번 (골목길, C++, Bellman–Ford) / 추가 반례 [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-1738%eb%b2%88-%ea%b3%a8%eb%aa%a9%ea%b8%b8-c-bellman-ford-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/33119/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1107번 (리모컨, C++, Brute Force) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1107%eb%b2%88-%eb%a6%ac%eb%aa%a8%ec%bb%a8-c-brute-force-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5678/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1107%eb%b2%88-%eb%a6%ac%eb%aa%a8%ec%bb%a8-c-brute-force-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5678/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 27 Jan 2023 17:25:46 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1107]]></category>
		<category><![CDATA[1107번]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[BruteForce]]></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[백준 1107]]></category>
		<category><![CDATA[백준 1107번]]></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=5678</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 1107번 '리모컨' 문제에 대한 글입니다. 'Brute Force' 알고리즘을 이용하여 해결하였습니다.<br />
(This is an article about the 'remote control' problem in BAEKJOON 1107. Solved using the 'Brute Force' algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1107%eb%b2%88-%eb%a6%ac%eb%aa%a8%ec%bb%a8-c-brute-force-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5678/">백준 1107번 (리모컨, C++, Brute Force) / 추가 반례 [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>



<h1 class="wp-block-heading">리모컨</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1107" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1107</a></p>



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



<figure id="problem-info" 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">82926</td><td class="has-text-align-left" data-align="left">20011</td><td class="has-text-align-left" data-align="left">13910</td><td class="has-text-align-left" data-align="left">22.624%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">수빈이는 TV를 보고 있다. 수빈이는 채널을 돌리려고 했지만, 버튼을 너무 세게 누르는&nbsp;바람에, 일부 숫자 버튼이 고장났다.</p>



<p class="has-medium-font-size">리모컨에는 버튼이 0부터 9까지 숫자, +와 -가 있다. +를 누르면 현재 보고있는 채널에서 +1된 채널로 이동하고, </p>



<p class="has-medium-font-size">-를 누르면 -1된 채널로 이동한다. 채널 0에서 -를 누른 경우에는 채널이 변하지 않고, 채널은 무한대 만큼 있다.</p>



<p class="has-medium-font-size">수빈이가 지금 이동하려고 하는 채널은 N이다. 어떤 버튼이 고장났는지 주어졌을 때, </p>



<p class="has-medium-font-size">채널 N으로 이동하기 위해서 버튼을 최소 몇 번 눌러야하는지 구하는 프로그램을 작성하시오. </p>



<p class="has-medium-font-size">수빈이가 지금 보고 있는 채널은 100번이다.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 수빈이가 이동하려고 하는 채널 N (0 ≤ N ≤ 500,000)이 주어진다.  </p>



<p class="has-medium-font-size">둘째 줄에는 고장난 버튼의 개수 M (0 ≤ M ≤ 10)이 주어진다. </p>



<p class="has-medium-font-size">고장난 버튼이 있는 경우에는 셋째 줄에는 고장난 버튼이 주어지며, 같은 버튼이 여러 번 주어지는 경우는 없다.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 채널 N으로 이동하기 위해 버튼을 최소 몇 번 눌러야 하는지를 출력한다.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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="">5457
3
6 7 8</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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="">100
5
0 1 2 3 4</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 3</h2>



<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="">500000
8
0 2 3 4 6 7 8 9</pre>



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



<h2 class="wp-block-heading">예제 출력 3</h2>



<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="">11117</pre>



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



<h2 class="wp-block-heading">예제 입력 4</h2>



<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="">100
3
1 0 5</pre>



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



<h2 class="wp-block-heading">예제 출력 4</h2>



<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:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 5</h2>



<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="">14124
0</pre>



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



<h2 class="wp-block-heading">예제 출력 5</h2>



<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</pre>



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



<h2 class="wp-block-heading">예제 입력 6</h2>



<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
9
1 2 3 4 5 6 7 8 9</pre>



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



<h2 class="wp-block-heading">예제 출력 6</h2>



<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:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 7</h2>



<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="">80000
2
8 9</pre>



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



<h2 class="wp-block-heading">예제 출력 7</h2>



<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="">2228</pre>



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



<h2 class="wp-block-heading">예제 입력 A</h2>



<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
9
1 2 3 4 5 6 7 8 9</pre>



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



<h2 class="wp-block-heading">예제 출력 A</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 B</h2>



<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="">140200
3
4 5 6</pre>



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



<h2 class="wp-block-heading">예제 출력 B</h2>



<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="">207</pre>



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



<h2 class="wp-block-heading">예제 입력 C</h2>



<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="">1555
3
0 1 9</pre>



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



<h2 class="wp-block-heading">예제 출력 C</h2>



<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="">670</pre>



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



<h2 class="wp-block-heading">예제 입력 D</h2>



<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="">99999
9
0 2 3 4 5 6 7 8 9</pre>



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



<h2 class="wp-block-heading">예제 출력 D</h2>



<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="">11118</pre>



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



<h2 class="wp-block-heading">예제 입력 E</h2>



<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="">50000
9
0 1 2 3 4 5 6 7 8</pre>



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



<h2 class="wp-block-heading">예제 출력 E</h2>



<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="">40005</pre>



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



<h2 class="wp-block-heading">예제 입력 F</h2>



<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="">139133
7
9 6 8 2 1 5 7</pre>



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



<h2 class="wp-block-heading">예제 출력 F</h2>



<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="">94694</pre>



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



<h2 class="wp-block-heading">예제 입력 G</h2>



<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
0</pre>



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



<h2 class="wp-block-heading">예제 출력 G</h2>



<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:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">힌트</h2>



<p class="has-medium-font-size">예제 1의 경우 5455++ 또는 5459&#8211;</p>



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



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



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



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



<li>잘못된 조건을 찾은 사람: <a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a></li>
</ul>



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/125" target="_blank" rel="noreferrer noopener">브루트포스 알고리즘</a></li>
</ul>



<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)"/>



<p class="has-medium-font-size">아래에서 위로 올라가는 방법도 있지만 위에서 아래로 내려가는 방법도 같이 생각해야한다.</p>



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



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



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



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

using namespace std;

bool arr[10];

string str, strTemp;

int N, M, temp, cnt, target, result = INT32_MAX;

void dfs(string st, char ch)
{
	if (st.length() == str.length() + 1) return;
	st.push_back(ch);
	cnt = abs(target - atoi(st.c_str())) + st.length();
	result = min(cnt, result);

	for (int i = 0; i &lt; 10; i++) {
		if (arr[i] == true) continue;
		dfs(st, i + '0');
	}
}

int main()
{
	cin >> str >> M;

	target = atoi(str.c_str());

	for (int i = 0; i &lt; M; i++) {
		cin >> temp;
		arr[temp] = true;
	}
	
	for (int i = 0; i &lt; 10; i++) {
		if (arr[i] == true) continue;
		dfs(strTemp, i + '0');
	}

	result = min(abs(target - 100), result);

	cout &lt;&lt; result;

	return 0;
}</pre>



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



<p class="has-medium-font-size">문자열로 접근하니까 속도가 너무 느리다&#8230;.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1245" height="160" src="https://lycos7560.com/wp-content/uploads/2023/01/image-30.png" alt="" class="wp-image-5679" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-30.png 1245w, https://lycos7560.com/wp-content/uploads/2023/01/image-30-300x39.png 300w, https://lycos7560.com/wp-content/uploads/2023/01/image-30-768x99.png 768w" sizes="(max-width: 1245px) 100vw, 1245px" /></figure>



<div style="height:38px" 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-1107%eb%b2%88-%eb%a6%ac%eb%aa%a8%ec%bb%a8-c-brute-force-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5678/">백준 1107번 (리모컨, C++, Brute Force) / 추가 반례 [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-1107%eb%b2%88-%eb%a6%ac%eb%aa%a8%ec%bb%a8-c-brute-force-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5678/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1620번 (나는야 포켓몬 마스터 이다솜, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1620%eb%b2%88-%eb%82%98%eb%8a%94%ec%95%bc-%ed%8f%ac%ec%bc%93%eb%aa%ac-%eb%a7%88%ec%8a%a4%ed%84%b0-%ec%9d%b4%eb%8b%a4%ec%86%9c-c-baekjoon/5586/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1620%eb%b2%88-%eb%82%98%eb%8a%94%ec%95%bc-%ed%8f%ac%ec%bc%93%eb%aa%ac-%eb%a7%88%ec%8a%a4%ed%84%b0-%ec%9d%b4%eb%8b%a4%ec%86%9c-c-baekjoon/5586/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 26 Jan 2023 12:15:26 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1620]]></category>
		<category><![CDATA[1620번]]></category>
		<category><![CDATA[atoi]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cin]]></category>
		<category><![CDATA[cin.tie(NULL)]]></category>
		<category><![CDATA[cout]]></category>
		<category><![CDATA[cout.tie(NULL)]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false)]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false);]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[unordered_map]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[나는야 포켓몬 마스터 이다솜]]></category>
		<category><![CDATA[문자]]></category>
		<category><![CDATA[문자열]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1620]]></category>
		<category><![CDATA[백준 1620번]]></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=5586</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 1620번 '나는야 포켓몬 마스터 이다솜' 문제에 대한 글입니다. 'array'과 'unordered_map' 자료 구조를 이용하여 해결하였습니다. (This is an article about the issue of BAEKJOON No. 1620 I am Pokemon Master Lee Da-som. We solved it using the data structure of 'array' and 'unordered_map'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1620%eb%b2%88-%eb%82%98%eb%8a%94%ec%95%bc-%ed%8f%ac%ec%bc%93%eb%aa%ac-%eb%a7%88%ec%8a%a4%ed%84%b0-%ec%9d%b4%eb%8b%a4%ec%86%9c-c-baekjoon/5586/">백준 1620번 (나는야 포켓몬 마스터 이다솜, 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>



<h1 class="wp-block-heading">나는야 포켓몬 마스터 이다솜</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1620" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1620</a></p>



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



<figure id="problem-info" 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">64247</td><td class="has-text-align-left" data-align="left">22477</td><td class="has-text-align-left" data-align="left">16798</td><td class="has-text-align-left" data-align="left">33.746%</td></tr></tbody></table></figure>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="489" height="333" src="https://lycos7560.com/wp-content/uploads/2023/01/image.png" alt="" class="wp-image-5588" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image.png 489w, https://lycos7560.com/wp-content/uploads/2023/01/image-300x204.png 300w" sizes="(max-width: 489px) 100vw, 489px" /></figure>



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



<p class="has-medium-font-size">안녕? 내 이름은 이다솜. 나의 꿈은 포켓몬 마스터야. </p>



<p class="has-medium-font-size">일단 포켓몬 마스터가 되기 위해선 포켓몬을 한 마리 잡아야겠지? 근처 숲으로 가야겠어.</p>



<p class="has-medium-font-size">(뚜벅 뚜벅)</p>



<p class="has-medium-font-size">얏! 꼬렛이다. 꼬렛? 귀여운데, 나의 첫 포켓몬으로 딱 어울린데? 내가 잡고 말겠어. 가라! 몬스터볼~</p>



<p class="has-medium-font-size">(펑!) 헐랭&#8230; 왜 안 잡히지?ㅜㅜ 몬스터 볼만 던지면 되는 게 아닌가&#8230;ㅜㅠ</p>



<p class="has-medium-font-size">(터벅터벅)</p>



<p class="has-medium-font-size">어? 누구지?</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="492" height="331" src="https://lycos7560.com/wp-content/uploads/2023/01/image-1.png" alt="" class="wp-image-5589" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-1.png 492w, https://lycos7560.com/wp-content/uploads/2023/01/image-1-300x202.png 300w" sizes="(max-width: 492px) 100vw, 492px" /></figure>



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



<p class="has-medium-font-size">오박사 : 나는 태초마을의 포켓몬 박사 오민식 박사라네. </p>



<p class="has-medium-font-size">다솜아, 포켓몬을 잡을 때는, 일단 상대 포켓몬의 체력을 적당히 바닥으로 만들어놓고 몬스터 볼을 던져야 한단다. </p>



<p class="has-medium-font-size">자, 내 포켓몬 이상해꽃으로 한번 잡아보렴. 포켓몬의 기술을 쓰는 것을 보고 </p>



<p class="has-medium-font-size">포켓몬을 줄지 안줄지 결정을 하겠네. 자 한번 해보아라. 다솜아.</p>



<p class="has-medium-font-size">이다솜 : 이상해꽃이라&#8230;음.. 꽃이니깐 왠지 햇빛을 받아서 공격을 할 것 같은데&#8230; 음&#8230; 이상해꽃! 햇빛공격!!!</p>



<p class="has-medium-font-size">(꼬렛이 이상해꽃에게 공격을 받아 체력이 25 감소했다.)    </p>



<p class="has-medium-font-size">가라! 몬스터 볼!!!    (꼬렛을 잡았습니다.)    야호! 신난다. 꼬렛을 잡았다.</p>



<p class="has-medium-font-size">오박사 : 오우!! 방금 쓴 공격은 솔라빔이라고 하네.. 어떻게 공격을 한 건가? </p>



<p class="has-medium-font-size">솔라빔이란 공격에 대해서 공부를 한 건가?</p>



<p class="has-medium-font-size">이다솜 : 꽃이니깐 왠지 햇빛을 제대로 받으면 광합성을 해서 음.. 그냥 그럴 것 같아서요 ☞☜</p>



<p class="has-medium-font-size">오박사 : 다른 아이들은 넝쿨채찍이나, 나뭇잎 공격을 하는데, 다솜이는 역시 뭔가 다르구나. </p>



<p class="has-medium-font-size">그럼 나와 함께 연구소로 가자꾸나. 내가 포켓몬을 한 마리 줄 테니, 너의 꿈을 펼쳐보아라. 꿈은 이루어진단다.</p>



<p class="has-medium-font-size">이다솜 : 네! 오박사님, 고마워요.ㅜㅜ</p>



<p class="has-medium-font-size">오박사 : 가자. 나의 연구소는 너의 옆집의 아랫집이란다. 같이 가도록하자. 지금 포켓몬을 주마.</p>



<p class="has-medium-font-size">이다솜 : 네. 야호!!</p>



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



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



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



<p class="has-medium-font-size">오영식 : 어? 오박사님 얘는 누구인가요?</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="490" height="328" src="https://lycos7560.com/wp-content/uploads/2023/01/image-3.png" alt="" class="wp-image-5591" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-3.png 490w, https://lycos7560.com/wp-content/uploads/2023/01/image-3-300x201.png 300w" sizes="(max-width: 490px) 100vw, 490px" /></figure>



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



<p class="has-medium-font-size">오박사 : 얘는 너의 라이벌이 될 친구 이다솜이라고 하네. </p>



<p class="has-medium-font-size">자, 포켓몬을 한 마리 골라보도록 해봐라 다솜아. 레이디퍼스트 네가 먼저 골라봐라.</p>



<p class="has-medium-font-size">이다솜 : 저는 생각해둔 포켓몬이 있어요. 피카츄 골라도 될까요?</p>



<p class="has-medium-font-size">오박사 : 그래 여기 피카츄가 한 마리 있단다. 피카츄를 가져가거라.</p>



<p class="has-medium-font-size">오영식 : 그럼 저는 이브이를 가져가겠어요. 그럼 나중에 보자 이다솜.</p>



<p class="has-medium-font-size">이다솜 : 그럼 꼬렛을 다시 잡으러 가야겠다. 영식아, 그리고 민식박사님 빠잉!</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="484" height="319" src="https://lycos7560.com/wp-content/uploads/2023/01/image-4.png" alt="" class="wp-image-5592" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-4.png 484w, https://lycos7560.com/wp-content/uploads/2023/01/image-4-300x198.png 300w" sizes="(max-width: 484px) 100vw, 484px" /></figure>



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



<p class="has-medium-font-size">이다솜 : 피카츄 공격!</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="485" height="324" src="https://lycos7560.com/wp-content/uploads/2023/01/image-5.png" alt="" class="wp-image-5593" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-5.png 485w, https://lycos7560.com/wp-content/uploads/2023/01/image-5-300x200.png 300w" sizes="(max-width: 485px) 100vw, 485px" /></figure>



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



<p class="has-medium-font-size">가라 몬스터 볼!</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="491" height="328" src="https://lycos7560.com/wp-content/uploads/2023/01/image-6.png" alt="" class="wp-image-5594" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-6.png 491w, https://lycos7560.com/wp-content/uploads/2023/01/image-6-300x200.png 300w" sizes="(max-width: 491px) 100vw, 491px" /></figure>



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



<p class="has-medium-font-size">이다솜 : 야호! 신난다. 꼬렛을 잡았다!!!!!</p>



<p class="has-medium-font-size">이다솜 : 그럼! 일단 사천왕을 이기고 오겠어!</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="485" height="331" src="https://lycos7560.com/wp-content/uploads/2023/01/image-7.png" alt="" class="wp-image-5595" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-7.png 485w, https://lycos7560.com/wp-content/uploads/2023/01/image-7-300x205.png 300w" sizes="(max-width: 485px) 100vw, 485px" /></figure>



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



<p class="has-medium-font-size">이다솜 : 여기가 사천왕과 대결하려면 가야하는 곳인가..</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="489" height="325" src="https://lycos7560.com/wp-content/uploads/2023/01/image-8.png" alt="" class="wp-image-5596" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-8.png 489w, https://lycos7560.com/wp-content/uploads/2023/01/image-8-300x199.png 300w" sizes="(max-width: 489px) 100vw, 489px" /></figure>



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



<p class="has-medium-font-size">경비원 : 사천왕과 대결을 하려면, 마을의 체육관 리더를 이겨서 배지를 8개를 모아야 한다네&#8230; 배지를 모아서 오도록 하게</p>



<p class="has-medium-font-size">이다솜 : 잉ㅠㅜ&#8230; 그럼 배지부터 모아야 하는구나ㅠㅜㅠㅜ 나쁘당 그냥 좀 봐주지..</p>



<p class="has-medium-font-size">&lt;1 년 후&gt;</p>



<p class="has-medium-font-size">그동안의 줄거리 : 이다솜은 일단 상록 숲의 체육관 리더에게 도전을 했다. </p>



<p class="has-medium-font-size">하지만 상록숲 체육관의 리더는 실종된 상태. 따라서 회색마을부터 도전하기로 했다. </p>



<p class="has-medium-font-size">체육관의 리더를 이기면서, 로켓단을 해체시키기도 하고, 여러 가지 사건도 있었다. </p>



<p class="has-medium-font-size">결국 전설의 포켓몬도 잡고, 이제 사천왕을 이기려고 도전하기로 했다. </p>



<p class="has-medium-font-size">사천왕은 모두 가볍게 이기고, 이제 마지막 라이벌 오!영!식! 이다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="492" height="330" src="https://lycos7560.com/wp-content/uploads/2023/01/image-9.png" alt="" class="wp-image-5597" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-9.png 492w, https://lycos7560.com/wp-content/uploads/2023/01/image-9-300x201.png 300w" sizes="(max-width: 492px) 100vw, 492px" /></figure>



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



<p class="has-medium-font-size">오영식 : 훗. 1년 전의 그 이다솜이 사천왕을 이기고 현재 포켓몬 마스터인 나에게 덤벼? 어디 한번 덤벼보시지.</p>



<p class="has-medium-font-size">이다솜 : 헐랭&#8230; 나를 우습게보네&#8230;. 한번 두고 보시지! 그럼 대결이닷!</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="323" src="https://lycos7560.com/wp-content/uploads/2023/01/image-10.png" alt="" class="wp-image-5598" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-10.png 486w, https://lycos7560.com/wp-content/uploads/2023/01/image-10-300x199.png 300w" sizes="(max-width: 486px) 100vw, 486px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="487" height="328" src="https://lycos7560.com/wp-content/uploads/2023/01/image-11.png" alt="" class="wp-image-5599" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-11.png 487w, https://lycos7560.com/wp-content/uploads/2023/01/image-11-300x202.png 300w" sizes="(max-width: 487px) 100vw, 487px" /></figure>



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="490" height="997" src="https://lycos7560.com/wp-content/uploads/2023/01/image-13.png" alt="" class="wp-image-5601" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-13.png 490w, https://lycos7560.com/wp-content/uploads/2023/01/image-13-147x300.png 147w" sizes="(max-width: 490px) 100vw, 490px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="487" height="670" src="https://lycos7560.com/wp-content/uploads/2023/01/image-14.png" alt="" class="wp-image-5602" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-14.png 487w, https://lycos7560.com/wp-content/uploads/2023/01/image-14-218x300.png 218w" sizes="(max-width: 487px) 100vw, 487px" /></figure>



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



<p class="has-medium-font-size">이다솜 : 휴&#8230; 이겼다.</p>



<p class="has-medium-font-size">오영식 : 내가 지다니 분하다. ㅜㅜ</p>



<p class="has-medium-font-size">오박사 : 그럼 다솜아 이제 진정한 포켓몬 마스터가 되기 위해 도감을 완성시키도록 하여라. </p>



<p class="has-medium-font-size">일단 네가 현재 가지고 있는 포켓몬 도감에서 포켓몬의 이름을 보면 포켓몬의 번호를 말하거나, </p>



<p class="has-medium-font-size">포켓몬의 번호를 보면 포켓몬의 이름을 말하는 연습을 하도록 하여라. </p>



<p class="has-medium-font-size">나의 시험을 통과하면, 내가 새로 만든 도감을 주도록 하겠네.</p>



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



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



<p class="has-medium-font-size">첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. </p>



<p class="has-medium-font-size">N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? </p>



<p class="has-medium-font-size">모르면 물어봐도 괜찮아. 나는 언제든지 질문에 답해줄 준비가 되어있어.</p>



<p class="has-medium-font-size">둘째 줄부터 N개의 줄에 포켓몬의 번호가 1번인 포켓몬부터 N번에 해당하는 포켓몬까지 한 줄에 하나씩 입력으로 들어와. </p>



<p class="has-medium-font-size">포켓몬의 이름은 모두 영어로만 이루어져있고, 또, 음&#8230; 첫 글자만 대문자이고, 나머지 문자는 소문자로만 이루어져 있어. </p>



<p class="has-medium-font-size">아참! 일부 포켓몬은 마지막 문자만 대문자일 수도 있어. 포켓몬 이름의 최대 길이는 20, 최소 길이는 2야. </p>



<p class="has-medium-font-size">그 다음 줄부터 총 M개의 줄에 내가 맞춰야하는 문제가 입력으로 들어와. 문제가 알파벳으로만 들어오면 포켓몬 번호를 말해야 하고, </p>



<p class="has-medium-font-size">숫자로만 들어오면, 포켓몬 번호에 해당하는 문자를 출력해야해. </p>



<p class="has-medium-font-size">입력으로 들어오는 숫자는 반드시 1보다 크거나 같고, N보다 작거나 같고, </p>



<p class="has-medium-font-size">입력으로 들어오는 문자는 반드시 도감에 있는 포켓몬의 이름만 주어져. 그럼 화이팅!!!</p>



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



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



<p class="has-medium-font-size">첫째 줄부터 차례대로 M개의 줄에 각각의 문제에 대한 답을 말해줬으면 좋겠어!!!. </p>



<p class="has-medium-font-size">입력으로 숫자가 들어왔다면 그 숫자에 해당하는 포켓몬의 이름을, </p>



<p class="has-medium-font-size">문자가 들어왔으면 그 포켓몬의 이름에 해당하는 번호를 출력하면 돼. 그럼 땡큐~</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="263" height="243" src="https://lycos7560.com/wp-content/uploads/2023/01/image-15.png" alt="" class="wp-image-5604"/></figure>



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



<p class="has-medium-font-size">이게 오박사님이 나에게 새로 주시려고 하는 도감이야. </p>



<p class="has-medium-font-size">너무 가지고 싶다ㅠㅜ. 꼭 만점을 받아줬으면 좋겠어!! 파이팅!!!</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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="">26 5
Bulbasaur
Ivysaur
Venusaur
Charmander
Charmeleon
Charizard
Squirtle
Wartortle
Blastoise
Caterpie
Metapod
Butterfree
Weedle
Kakuna
Beedrill
Pidgey
Pidgeotto
Pidgeot
Rattata
Raticate
Spearow
Fearow
Ekans
Arbok
Pikachu
Raichu
25
Raichu
3
Pidgey
Kakuna</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">Pikachu
26
Venusaur
16
14</pre>



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



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



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



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



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/136" 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)"/>



<p class="has-medium-font-size">주의할 점은 들어오는 문자열을 숫자와 문자로 구분하는 방법이다.</p>



<p class="has-medium-font-size">문제의 조건은 문자의 첫 인덱스는 숫자가 아니다. </p>



<p class="has-medium-font-size">그래서 문자열의 첫 인덱스를 숫자인지 문자인지 구분하여 해결하였다.</p>



<p class="has-medium-font-size">추가적으로 atoi() 를 사용하여 문자를 숫자로 변환해주었다. &lt;iostream></p>



<p class="has-medium-font-size">atoi는 해당하는 문자열이 숫자면 숫자를 반환한다</p>



<p class="has-medium-font-size">만약 해당하는 문자열이 숫자로 변환이 불가능하다면 아니라면 0을 반환</p>



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



<h2 class="wp-block-heading">통과된 코드</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;unordered_map>

using namespace std;

unordered_map&lt;string, int> uSortMap;

int N, M;
string strArr[100001];

int main()
{

	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> N >> M;
	
	for (int i = 1; i &lt;= N; i++) {
		cin >> strArr[0];
		strArr[i] = strArr[0];
		uSortMap.insert({ strArr[0], i });
	}

	for (int i = 0; i &lt; M; i++) {
		cin >> strArr[0];
		if (strArr[0][0] >= '0' &amp;&amp; strArr[0][0] &lt;= '9') {
			cout &lt;&lt; strArr[atoi(strArr[0].c_str())] &lt;&lt; "\n";
			// atoi(string.c_str())
			// atoi는 해당하는 문자열이 숫자면 숫자를 반환한다 
			// 만약 해당하는 문자열이 숫자로 변환이 불가능하다면 아니라면 0을 반환
		}
		else {
			cout &lt;&lt; uSortMap.find(strArr[0])->second &lt;&lt; "\n";
		} 
	}

	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/01/image-16.png" alt="" class="wp-image-5606" width="1078" height="186" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-16.png 1437w, https://lycos7560.com/wp-content/uploads/2023/01/image-16-300x52.png 300w, https://lycos7560.com/wp-content/uploads/2023/01/image-16-768x133.png 768w" sizes="(max-width: 1078px) 100vw, 1078px" /></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="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-1620%eb%b2%88-%eb%82%98%eb%8a%94%ec%95%bc-%ed%8f%ac%ec%bc%93%eb%aa%ac-%eb%a7%88%ec%8a%a4%ed%84%b0-%ec%9d%b4%eb%8b%a4%ec%86%9c-c-baekjoon/5586/">백준 1620번 (나는야 포켓몬 마스터 이다솜, 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-1620%eb%b2%88-%eb%82%98%eb%8a%94%ec%95%bc-%ed%8f%ac%ec%bc%93%eb%aa%ac-%eb%a7%88%ec%8a%a4%ed%84%b0-%ec%9d%b4%eb%8b%a4%ec%86%9c-c-baekjoon/5586/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 16681번 (등산, C++, Dijkstra) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16681%eb%b2%88-%eb%93%b1%ec%82%b0-c-dijkstra-baekjoon/5559/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16681%eb%b2%88-%eb%93%b1%ec%82%b0-c-dijkstra-baekjoon/5559/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 18:14:49 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[16681]]></category>
		<category><![CDATA[16681번]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cin]]></category>
		<category><![CDATA[cin.tie(NULL)]]></category>
		<category><![CDATA[cout]]></category>
		<category><![CDATA[cout.tie(NULL)]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Dijkstra]]></category>
		<category><![CDATA[DP]]></category>
		<category><![CDATA[DynamicProgramming]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false)]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false);]]></category>
		<category><![CDATA[long long int]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[multimap]]></category>
		<category><![CDATA[mutimap]]></category>
		<category><![CDATA[priority_queue]]></category>
		<category><![CDATA[PriorityQueue]]></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[너비]]></category>
		<category><![CDATA[너비 우선 탐색]]></category>
		<category><![CDATA[다이나믹 프로그래밍]]></category>
		<category><![CDATA[다익스트라]]></category>
		<category><![CDATA[데이크스트라]]></category>
		<category><![CDATA[등산]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 16681]]></category>
		<category><![CDATA[백준 16681번]]></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=5559</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 16681번 '등산' 문제에 대한 글입니다. Dijkstra 알고리즘을 이용하여 해결하였습니다. (This is an article about the 'climbing' problem in BAEKJOON No. 16681. It was solved using Dijkstra algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-16681%eb%b2%88-%eb%93%b1%ec%82%b0-c-dijkstra-baekjoon/5559/">백준 16681번 (등산, C++, Dijkstra) [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>



<h1 class="wp-block-heading">등산</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/16681">https://www.acmicpc.n</a><a href="https://www.acmicpc.net/problem/16681" target="_blank" rel="noreferrer noopener">et/problem/16681</a></p>



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



<figure id="problem-info" 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">3180</td><td class="has-text-align-left" data-align="left">827</td><td class="has-text-align-left" data-align="left">568</td><td class="has-text-align-left" data-align="left">22.576%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">주환이는 요즘 등산에 빠졌다. 주환이는 등산을 위해 지도를 가지고 있는데, </p>



<p class="has-medium-font-size">그 지도에는 각 지점의 높이와 갈 수 있는 다른 지점까지의 거리가 표시되어 있다.</p>



<p class="has-medium-font-size">주환이는 아침에 집에서 출발하여 등산을 갔다가, 오후 수업을 듣기 위해 고려대학교로 돌아와야 한다.</p>



<p class="has-medium-font-size">1. 주환이는 지도의 임의의 지점을 골라, 그 지점을 목표로 정한다. 집 또는 고려대학교는 목표로 선택할 수 없다.</p>



<p class="has-medium-font-size">2. 주환이가 집에서 정한 목표에 도달할 때 까지는 항상 높이가 증가하는 방향으로만 이동해야 한다.</p>



<p class="has-medium-font-size">3. 주환이가 정한 목표에 도달한 후, 고려대학교로 갈 때에는 항상 높이가 감소하는 방향으로만 이동해야 한다.</p>



<p class="has-medium-font-size">4. 주환이는 거리 1을 움직일 때 마다&nbsp;<em>D&nbsp;</em>의 체력이 소모된다.</p>



<p class="has-medium-font-size">5. 주환이는 정한 목표에 도달하면 높이 1당&nbsp;<em>E</em>&nbsp;의 성취감을 얻는다. 즉 높이가&nbsp;<em>h</em>인 목표에 도달하면&nbsp;<em>hE</em>의 성취감을 얻는다.</p>



<p class="has-medium-font-size">주환이는 이 등산의 가치를 (얻은 성취감) &#8211; (소모한 체력) 으로 계산하기로 하였다. </p>



<p class="has-medium-font-size">주환이를 위해 가치가 가장 높은 등산 경로를 선택해주자.</p>



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



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



<p class="has-medium-font-size">첫 번째 줄에 지도에 표시된 지점의 개수, 지점을 잇는 경로의 개수, 주환이의 거리 비례 체력 소모량, </p>



<p class="has-medium-font-size">높이 비례 성취감 획득량을 나타내는 정수&nbsp;<em>N</em>,&nbsp;<em>M</em>,&nbsp;<em>D</em>,&nbsp;<em>E</em>가 공백을 사이에 두고 주어진다. </p>



<p class="has-medium-font-size">(2 ≤&nbsp;<em>N</em>&nbsp;≤ 100,000, 1 ≤&nbsp;<em>M</em>&nbsp;≤ 200,000, 1&nbsp;≤&nbsp;<em>D</em>&nbsp;≤ 100, 1 ≤&nbsp;&nbsp;<em>E&nbsp;</em>≤ 100)</p>



<p class="has-medium-font-size">두 번째 줄에&nbsp;<em>N</em>개의 정수&nbsp;<em>h<sub>1</sub>, &#8230;&nbsp; ,h<sub>N</sub></em>이 공백으로 구분되어 주어진다.&nbsp;<em>h<sub>i</sub></em>는&nbsp;<em>i&nbsp;</em>번째 지점의 높이를 의미한다. </p>



<p class="has-medium-font-size">(1 ≤&nbsp;<em>h<sub>i</sub></em>&nbsp;≤ 1,000,000, 1 ≤&nbsp;<em>i&nbsp;</em>≤&nbsp;<em>N</em>)</p>



<p class="has-medium-font-size">세 번째 줄부터&nbsp;<em>M</em>개의 줄에 걸쳐 세 정수&nbsp;<em>a, b, n</em>이 공백으로 구분되어 주어진다. </p>



<p class="has-medium-font-size">이는&nbsp;<em>a</em>번 지점과&nbsp;<em>b</em>번 지점을 잇는 거리&nbsp;<em>n</em>의 양방향 경로가 있음을 의미한다. (1 ≤&nbsp;<em>a, b</em>&nbsp;≤&nbsp;<em>N</em>, 1 ≤&nbsp;<em>n</em>&nbsp;≤ 100,000)</p>



<p class="has-medium-font-size">어떤 지점에서 다른 지점으로 가는 경로가 여러 개 있을 수도 있으며 (등산로는 여러 개가 있을 수 있다), </p>



<p class="has-medium-font-size">한 지점에서 출발해 그 지점으로 돌아가는 경로가 있을 수도 있다 (쉼터에서 몇 바퀴 돌며 쉴 수도 있다).</p>



<p class="has-medium-font-size">주환이의 집은 1번 지점에 위치하고, 고려대학교는&nbsp;<em>N</em>번 지점에 위치하며 주환이의 집과 고려대학교의 높이는 1임이 보장된다.</p>



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



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



<p class="has-medium-font-size">첫 번째 줄에 주환이가 얻을 수 있는 가치의 최댓값을 출력한다. </p>



<p class="has-medium-font-size">만약 조건을 만족하는 등산 경로를 선택할 수 없다면, &#8220;<code>Impossible</code>&#8220;을 쌍따옴표를 제외하고 출력한다. </p>



<p class="has-medium-font-size">답이 음수일 수 있음에 유의하여라.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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 13 4 9
1 4 7 3 10 2 15 1
1 2 3
3 4 2
5 6 6
7 8 2
2 3 4
6 7 2
3 6 1
4 8 3
5 1 6
8 3 5
2 5 4
4 6 3
5 3 8</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">15</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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 2 1 1
1 1 1
1 2 5
2 3 5</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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="">Impossible</pre>



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



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



<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/341" target="_blank" rel="noreferrer noopener">고려대학교</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/698" target="_blank" rel="noreferrer noopener">2018 고려대학교 프로그래밍 경시대회 (KCPC)</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/1974" target="_blank" rel="noreferrer noopener">Advanced Div.</a>&nbsp;C번</p>



<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/341" target="_blank" rel="noreferrer noopener">고려대학교</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/698" target="_blank" rel="noreferrer noopener">2018 고려대학교 프로그래밍 경시대회 (KCPC)</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/1975" target="_blank" rel="noreferrer noopener">Intermediate Div.</a>&nbsp;E번</p>



<ul class="wp-block-list">
<li>문제를 만든 사람:&nbsp;<a href="https://www.acmicpc.net/user/oree2113">oree2113</a></li>
</ul>



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



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



<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/22" target="_blank" rel="noreferrer noopener">데이크스트라</a></li>
</ul>



<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)"/>



<figure class="wp-block-image size-large"><img decoding="async" width="1421" height="3000" src="https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-1421x3000.jpg" alt="" class="wp-image-5568" srcset="https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-1421x3000.jpg 1421w, https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-142x300.jpg 142w, https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-768x1621.jpg 768w, https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-728x1536.jpg 728w, https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-970x2048.jpg 970w, https://lycos7560.com/wp-content/uploads/KakaoTalk_20230126_031127765-scaled.jpg 910w" sizes="(max-width: 1421px) 100vw, 1421px" /></figure>



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



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



<p class="has-medium-font-size"><strong>자료형 long long 필수!</strong></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;vector>

using namespace std;

constexpr int MAXN = 100001;
constexpr long long int INF = INT64_MAX;
constexpr long long int uINF = INT64_MIN;

///*
//각 노드에 연결되어 있는 노드에 대한 정보를 담는 벡터
//a번 노드에서 b번 노드로 가는 비용이 c라는 의미
//graph[a].push_back((make_pair(B, C));
//*/
vector&lt;pair&lt;int, int>> upGraph[MAXN];
vector&lt;pair&lt;int, int>> downGraph[MAXN];

// Dijkstra 알고리즘에 사용할 우선순위 큐
priority_queue&lt;pair&lt;long long int, int>> myPQ;

// N 지점의 개수, M 지점을 잇는 경로의 개수
// D 주환이의 거리 비례 체력 소모량, E 높이 비례 성취감 획득량
int N, M, D, E;

// 각 지점의 높이를 저장하는 배열
int hArr[MAXN];

// 등산을 하는데 필요한 배열 (집 -> 산)
long long int upArr[MAXN];

long long int temp = 0;
// 결과를 저장
long long int result = uINF;

// 하산을 하는데 필요한 배열 (산 -> 고려대)
long long int downArr[MAXN];

// V1,2 지점, d : 지점 사이의 거리
int V1, V2, d;

void Dijkstra(int start, long long int arr[], vector&lt;pair&lt;int, int>> graph[])
{
    // 임시배열 초기화
    for (int i = 1; i &lt;= N; i++) arr[i] = INF;
    // 우선순위 큐에 삽입.
    myPQ.push({ 0, start }); // &lt; first : 거리 , second : 노드 인덱스 >
    arr[start] = 0;
    while (!myPQ.empty()) {
        // -를 붙이는 이유는 우선순위 큐를 이용하여 정렬하기 위함이다.
        // (최소힙으로 구현)
        long long int nCost = -myPQ.top().first;
        int now = myPQ.top().second;
        myPQ.pop();
        // 이미 담겨 있는 것보다 거리가 크면 넘어간다.
        if (arr[now] &lt; nCost) continue;
        // 해당 노드에서 연결된 모든 경로를 확인
        for (int i = 0; i &lt; graph[now].size(); i++) {
            // disSum = 임시 노드 + 현재 노드에서 i로가는 비용
            long long int disSum = nCost + graph[now][i].second;
            // 비용이 더 작다면 최단경로 테이블 값을 갱신.
            if (disSum &lt; arr[graph[now][i].first]) {
                // 임시 노드 업데이트
                arr[graph[now][i].first] = disSum;
                // 우선순위 큐에 (거리, 노드 인덱스) 푸시
                myPQ.push(make_pair(-disSum, graph[now][i].first));
            }
        }
    }
}


int main()
{
    ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
    // cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
    cin.tie(NULL);
    cout.tie(NULL);

    // 문제의 조건들을 입력 받는다.
    cin >> N >> M >> D >> E;

    // 각 지점의 높이를 입력 받는다.
    for (int i = 1; i &lt;= N; i++) cin >> hArr[i];

    // 경로를 입력 받는다.
    for (int i = 0; i &lt; M; i++) {

        cin >> V1 >> V2 >> d;

        // 높이가 같을 경우에는 생각하지 않는다.
        if (hArr[V1] > hArr[V2]) { // V1의 높이가 더 높을 경우
            upGraph[V2].push_back(make_pair(V1, d));
            downGraph[V2].push_back(make_pair(V1, d));
        }
        else if (hArr[V1] &lt; hArr[V2]) { // V1의 높이가 더 낮은 경우
            upGraph[V1].push_back(make_pair(V2, d));
            downGraph[V1].push_back(make_pair(V2, d));
        }

    }

    Dijkstra(1, upArr, upGraph);
    Dijkstra(N, downArr, downGraph);

    for (int i = 1; i &lt;= N; i++) {
        if (upArr[i] == INF || downArr[i] == INF) continue;
        temp = upArr[i] + downArr[i];
        result = max(result, hArr[i] * E - temp * D);
    }

    if (result == uINF) cout &lt;&lt; "Impossible";
    else cout &lt;&lt; result;
    
    return 0;
}</pre>



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



<p class="has-medium-font-size">최악의 경우 예를 들어 N = 100,000 / M = 200,000  / <em>h<sub>i</sub></em> = i / 모든 경로 거리 1 / D = 1 / E = 100 이런 식이면</p>



<p class="has-medium-font-size">int 를 사용하면 터진다. ㅠㅠ</p>



<p class="has-medium-font-size">long long int 로 바꾸어주자</p>



<p class="has-medium-font-size">로직 문제로 오인해서 많이 틀렸다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1038" height="321" src="https://lycos7560.com/wp-content/uploads/image-1060.png" alt="" class="wp-image-5560" srcset="https://lycos7560.com/wp-content/uploads/image-1060.png 1038w, https://lycos7560.com/wp-content/uploads/image-1060-300x93.png 300w, https://lycos7560.com/wp-content/uploads/image-1060-768x238.png 768w" sizes="(max-width: 1038px) 100vw, 1038px" /></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="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-16681%eb%b2%88-%eb%93%b1%ec%82%b0-c-dijkstra-baekjoon/5559/">백준 16681번 (등산, C++, Dijkstra) [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-16681%eb%b2%88-%eb%93%b1%ec%82%b0-c-dijkstra-baekjoon/5559/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 18500번 (미네랄 2, C++, Simulation) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18500%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-2-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5533/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18500%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-2-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5533/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 09:53:37 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[18500]]></category>
		<category><![CDATA[18500번]]></category>
		<category><![CDATA[2933]]></category>
		<category><![CDATA[2933번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cin.tie(NULL)]]></category>
		<category><![CDATA[cout.tie(NULL)]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false)]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false);]]></category>
		<category><![CDATA[simulation]]></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[미네랄 2]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 18500]]></category>
		<category><![CDATA[백준 18500번]]></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>
		<category><![CDATA[틀렸습니다!]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=5533</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 18500번 '미네랄 2' 문제에 대한 글입니다. '그래프 Search'을 이용하여 해결하였습니다.<br />
추가적인 테스트 케이스를 제시합니다. (This is BAEKJOON's 18500 article on the 'Mineral 2' problem. I solved it using 'Graph Search'.<br />
Present additional test cases.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18500%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-2-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5533/">백준 18500번 (미네랄 2, C++, Simulation) / 추가 반례 [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>



<h1 class="wp-block-heading">미네랄 2</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/18500" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/18500</a></p>



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



<figure id="problem-info" 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">512 MB</td><td class="has-text-align-left" data-align="left">2109</td><td class="has-text-align-left" data-align="left">713</td><td class="has-text-align-left" data-align="left">549</td><td class="has-text-align-left" data-align="left">34.355%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">창영과 상근은 한 동굴을 놓고 소유권을 주장하고 있다. </p>



<p class="has-medium-font-size">두 사람은 막대기를 서로에게 던지는 방법을 이용해 누구의 소유 인지를 결정하기로 했다. </p>



<p class="has-medium-font-size">싸움은 동굴에서 벌어진다. 동굴에는 미네랄이 저장되어 있으며, 던진 막대기가 미네랄을 파괴할 수도 있다.</p>



<p class="has-medium-font-size">동굴은 R행 C열로 나타낼 수 있으며, R×C칸으로 이루어져 있다. </p>



<p class="has-medium-font-size">각 칸은 비어있거나 미네랄을 포함하고 있으며, 네 방향 중 하나로 인접한 미네랄이 포함된 두 칸은 같은 클러스터이다.</p>



<p class="has-medium-font-size">창영은 동굴의 왼쪽에 서있고, 상근은 오른쪽에 서있다. 두 사람은 턴을 번갈아가며 막대기를 던진다. </p>



<p class="has-medium-font-size">막대를 던지기 전에 던질 높이를 정해야 한다. 막대는 땅과 수평을 이루며 날아간다.</p>



<p class="has-medium-font-size">막대가 날아가다가 미네랄을 만나면, 그 칸에 있는 미네랄은 모두 파괴되고 막대는 그 자리에서 이동을 멈춘다.</p>



<p class="has-medium-font-size">미네랄이 파괴된 이후에 남은 클러스터가 분리될 수도 있다.  </p>



<p class="has-medium-font-size">새롭게 생성된 클러스터가 떠 있는 경우에는 중력에 의해서 바닥으로 떨어지게 된다. </p>



<p class="has-medium-font-size">떨어지는 동안 클러스터의 모양은 변하지 않는다. 클러스터는 다른 클러스터나 땅을 만나기 전까지 계속해서 떨어진다. </p>



<p class="has-medium-font-size">클러스터는 다른 클러스터 위에 떨어질 수 있고, 그 이후에는 합쳐지게 된다.</p>



<p class="has-medium-font-size">동굴에 있는 미네랄의 모양과 두 사람이 던진 막대의 높이가 주어진다. </p>



<p class="has-medium-font-size">모든 막대를 던지고 난 이후에 미네랄 모양을 구하는 프로그램을 작성하시오.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 동굴의 크기 R과 C가 주어진다. (1 ≤ R,C ≤ 100)</p>



<p class="has-medium-font-size">다음 R개 줄에는 C개의 문자가 주어지며, &#8216;.&#8217;는 빈 칸, &#8216;x&#8217;는 미네랄을 나타낸다.</p>



<p class="has-medium-font-size">다음 줄에는 막대를 던진 횟수 N이 주어진다. (1 ≤ N ≤ 100)</p>



<p class="has-medium-font-size">마지막 줄에는 막대를 던진 높이가 주어지며, 공백으로 구분되어져 있다. </p>



<p class="has-medium-font-size">모든 높이는 1과 R사이이며, 높이 1은 행렬의 가장 바닥, R은 가장 위를 의미한다. <br><br>첫 번째 막대는 왼쪽에서 오른쪽으로 던졌으며, 두 번째는 오른쪽에서 왼쪽으로, 이와 같은 식으로 번갈아가며 던진다.</p>



<p class="has-medium-font-size">공중에 떠 있는 미네랄 클러스터는 없으며, 두 개 또는 그 이상의 클러스터가 동시에 떨어지는 경우도 없다. </p>



<p class="has-medium-font-size"><s>클러스터가 떨어질 때,&nbsp;그 클러스터 각 열의 맨 아래 부분 중 하나가 바닥 또는 미네랄 위로 떨어지는 입력만 주어진다.</s></p>



<p>(2933번 문제와 차이)</p>



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



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



<p class="has-medium-font-size">입력 형식과 같은 형식으로 미네랄 모양을 출력한다.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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 6
......
..xx..
..x...
..xx..
.xxxx.
1
3</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">......
......
..xx..
..xx..
.xxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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 8
........
........
...x.xx.
...xxx..
..xxx...
..x.xxx.
..x...x.
.xxx..x.
5
6 6 4 3 1</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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="">........
........
........
........
.....x..
..xxxx..
..xxx.x.
..xxxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 3</h2>



<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 6
......
......
xx....
.xx...
..xx..
...xx.
....x.
2
6 4</pre>



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



<h2 class="wp-block-heading">예제 출력 3</h2>



<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="">......
......
......
......
..xx..
xx.xx.
.x..x.</pre>



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



<h2 class="wp-block-heading">예제 입력 A</h2>



<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="">13 100
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
..................................................x................................................x
..................................................x................................................x
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
11 
1 1 1 1 1 1 1 1 1 1 1 </pre>



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



<h2 class="wp-block-heading">예제 출력 A</h2>



<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="">....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
..................................................x................................................x
...................................................................................................x</pre>



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



<h2 class="wp-block-heading">예제 입력 B</h2>



<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="">9 8
........
...xxx..
.xxx....
.x.x.xxx
.x.x...x
.x.xxx.x
.x.....x
.x.....x
.xxx...x
1
7</pre>



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



<h2 class="wp-block-heading">예제 출력 B</h2>



<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="">........
........
...xxx..
.xxx.xxx
.x.x...x
.x.x...x
.x.xxx.x
.x.....x
.xxx...x</pre>



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



<h2 class="wp-block-heading">예제 입력 C</h2>



<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 4
xxxx
xx.x
x..x
...x
1
3</pre>



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



<h2 class="wp-block-heading">예제 출력 C</h2>



<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="">xxxx
.x.x
...x
x..x</pre>



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



<h2 class="wp-block-heading">예제 입력 D</h2>



<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 5
.....
.xxx.
.x...
xx.xx
x...x
x...x
x...x
1
4</pre>



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



<h2 class="wp-block-heading">예제 출력 D</h2>



<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="">.....
.....
.xxx.
.x.xx
xx..x
x...x
x...x</pre>



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



<h2 class="wp-block-heading">예제 입력 E</h2>



<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 2
..
.x
1
2</pre>



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



<h2 class="wp-block-heading">예제 출력 E</h2>



<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="">..
.x</pre>



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



<h2 class="wp-block-heading">예제 입력 F</h2>



<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 5
xxxxx
x....
xxxxx
x....
x....
10 1 2 3 4 5 1 2 3 4 5</pre>



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



<h2 class="wp-block-heading">예제 출력 F</h2>



<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="">.....
.....
.....
.xxxx
xxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 G</h2>



<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="">10 10
xxxxxxxxxx
....x.....
...xxx....
.....x....
....xx....
.....x....
xxxxxx....
..x.......
.xxxx.....
...xxxxxxx
10 9 8 7 6 5 4 3 2 1 1</pre>



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



<h2 class="wp-block-heading">예제 출력 G</h2>



<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="">..........
..........
..........
..........
..........
..........
xxxxxxxxxx
....xx....
xxxxxx....
.xxxxxxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 H</h2>



<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 4
...x
..xx
.xxx
xxxx
10 1 2 3 4 1 2 3 4 3 4</pre>



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



<h2 class="wp-block-heading">예제 출력 H</h2>



<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="">....
....
.xxx
..xx</pre>



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



<h2 class="wp-block-heading">예제 입력 I</h2>



<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="">10 20
..xxxxxxxxxxxxxxx...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..xxxxxx........x...
................x...
x...............x...
2
1 7</pre>



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



<h2 class="wp-block-heading">예제 출력 I</h2>



<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="">....................
..xxxxxxxxxxxxxxx...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..x.............x...
..xxxxxx........x...
................x...</pre>



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



<h2 class="wp-block-heading">예제 입력 J</h2>



<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="">9 8
........
.xxxx...
.x......
.x.xxxx.
.x....x.
.x....x.
.xxxx.x.
....xxx.
......x.
1
2</pre>



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



<h2 class="wp-block-heading">예제 출력 J</h2>



<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="">........
........
.xxxx...
.x.xxxx.
.x....x.
.x....x.
.x....x.
.xxxxxx.
......x.</pre>



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



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



<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/25" target="_blank" rel="noreferrer noopener">Croatian Highschool Competitions in Informatics</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/29" target="_blank" rel="noreferrer noopener">2009</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/91" target="_blank" rel="noreferrer noopener">Croatian Regional Competition in Informatics 2009</a>&nbsp;5번</p>



<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/25" target="_blank" rel="noreferrer noopener">Croatian Highschool Competitions in Informatics</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/29" target="_blank" rel="noreferrer noopener">2009</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/1069" target="_blank" rel="noreferrer noopener">Regional Competition &#8211; Juniors</a>&nbsp;4번</p>



<ul class="wp-block-list">
<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/heize" target="_blank" rel="noreferrer noopener">heize</a></li>
</ul>



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



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



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



<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/141" 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)"/>



<figure class="wp-block-embed is-type-wp-embed is-provider-어제와-내일의-나-그-사이의-이야기 wp-block-embed-어제와-내일의-나-그-사이의-이야기"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="EG4OUsUyN9"><a href="https://lycos7560.com/?p=2163">백준 2933번 (미네랄, C++, Simulation) / 추가 반례 [BAEKJOON]</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;백준 2933번 (미네랄, C++, Simulation) / 추가 반례 [BAEKJOON]&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/?p=2163&#038;embed=true#?secret=0JeHTukF6L#?secret=EG4OUsUyN9" data-secret="EG4OUsUyN9" 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>



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



<p class="has-medium-font-size">나는 2933번을 해결할 때 공중에 있는 미네랄 리스트의  하단부를 전부 확인하는 방법으로 구현해서 다른 것이 없다.</p>



<p class="has-medium-font-size">골드 2 문제를 해결하니 골드 1을 같이 주네?? 개꿀 </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="">#include &lt;iostream>
#include &lt;list>
#include &lt;queue>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// 방문처리 
bool mapCheck[MAX][MAX];

// BFS 사용할 Q
queue&lt;pair&lt;int, int>> myQ;

pair&lt;int, int> tempP;

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int dx, dy, dis;

int temp = 0;

// 탐색하는 방향 설정 =>  상, 하 ,좌 ,우
int dxdy[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };


list&lt;int> myList;
list&lt;int>::iterator it;

list&lt;pair&lt;int, int>> cList;
list&lt;pair&lt;int, int>>::iterator cit;

// true = left, false = right
bool check = false, leftRight = false;

void BFS(int x, int y)
{
	myQ.push(make_pair(x, y));

	while (!myQ.empty()) {
		tempP = myQ.front();
		myQ.pop();

		for (int i = 0; i &lt; 4; i++) {
			dy = tempP.second + dxdy[i][1];
			dx = tempP.first + dxdy[i][0];
			// 문제의 범위를 벗어나는 경우 => 넘어간다.
			if (dx &lt;= 0 || dy &lt;= 0 || dy > C || dx > R) continue;
			// 방문 처리가 되었거나 빈공간 => 넘어간다.
			if (mapCheck[dx][dy] == true || map[dx][dy] == '.') continue;
			mapCheck[dx][dy] = true;
			myQ.push(make_pair(dx, dy));
		}
	}
}

void CheckFloor() // 바닥을 체크합니다.
{
	for (int y = 1; y &lt;= C; y++) {
		// 바닥에 클러스터가 발견되고 방문처리가 되지 않았다면 
		if (map[1][y] == 'x' &amp;&amp; mapCheck[1][y] == false) {
			BFS(1, y); // BFS로 마킹
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {

		check = false; // 미네랄 부셔짐 체크 해제
		cList.clear(); // 공중의 미네랄 리스트 초기화

		// 해당 위치에 미네랄이 있는지 검색합니다.
		if (leftRight) { // 좌측 검색
			for (int y = C; y >= 1; y--) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}
		else { // 우측 검색
			for (int y = 1; y &lt;= C; y++) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}

		if (check) {  // 미네랄이 부셔졌다면
			// 공중에 있는 클러스트들을 리스트에 담는다.
			for (int x = R; x >= 1; x--) {
				for (int y = C; y >= 1; y--) {
					if (map[x][y] == 'x' &amp;&amp; mapCheck[x][y] == false) {
						cList.push_back(make_pair(x, y));
					}
				}
			}

			// 공중에 미네랄이 바닥과 연결될때까지 반복
			dis = 1;
			bool floor = true;
			while (floor) {

				if (cList.size() == 0) break;

				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;

					if (mapCheck[tempP.first - (dis + 1)][tempP.second] == true || tempP.first - (dis + 1) == 0) {
						floor = false;
						break;
					}
				}

				dis++;
			}

			if (!floor) {
				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;
					map[tempP.first][tempP.second] = '.';
				}

				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;
					map[tempP.first - (dis - 1)][tempP.second] = 'x';
				}	
			}

			// 방문 처리를 초기화 
			for (int x = R; x >= 1; x--) {
				for (int y = 1; y &lt;= C; y++) {
					mapCheck[x][y] = false;
				}
			}
		}
	}

	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cout &lt;&lt; map[x][y];
		}
		if (x == 1) break;
		cout &lt;&lt; "\n";
	}

	return 0;

}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1035" height="104" src="https://lycos7560.com/wp-content/uploads/image-1058.png" alt="" class="wp-image-5539" srcset="https://lycos7560.com/wp-content/uploads/image-1058.png 1035w, https://lycos7560.com/wp-content/uploads/image-1058-300x30.png 300w, https://lycos7560.com/wp-content/uploads/image-1058-768x77.png 768w" sizes="(max-width: 1035px) 100vw, 1035px" /></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-18500%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-2-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5533/">백준 18500번 (미네랄 2, C++, Simulation) / 추가 반례 [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-18500%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-2-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5533/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 2933번 (미네랄, C++, Simulation) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2933%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/2163/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2933%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/2163/#comments</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 06:00:03 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[18500]]></category>
		<category><![CDATA[18500번]]></category>
		<category><![CDATA[2933]]></category>
		<category><![CDATA[2933번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[BFS]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cin.tie(NULL)]]></category>
		<category><![CDATA[cout.tie(NULL)]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false)]]></category>
		<category><![CDATA[ios_base::sync_with_stdio(false);]]></category>
		<category><![CDATA[simulation]]></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[미네랄 2]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2933]]></category>
		<category><![CDATA[백준 2933번]]></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>
		<category><![CDATA[틀렸습니다!]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2163</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 2933번 '미네랄' 문제에 대한 글입니다. '그래프 Search'을 이용하여 해결하였습니다.<br />
추가적인 테스트 케이스를 제시합니다. (This is BAEKJOON's 2933 article on the 'Mineral' problem. I solved it using 'Graph Search'.<br />
Present additional test cases.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2933%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/2163/">백준 2933번 (미네랄, C++, Simulation) / 추가 반례 [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div style="height:42px" 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>
<!-- 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>



<h1 class="wp-block-heading">미네랄</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/2933" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/2933</a></p>



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



<figure id="problem-info" class="wp-block-table is-style-regular"><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">128 MB</td><td class="has-text-align-left" data-align="left">10752</td><td class="has-text-align-left" data-align="left">2935</td><td class="has-text-align-left" data-align="left">1917</td><td class="has-text-align-left" data-align="left">25.250%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">창영과 상근은 한 동굴을 놓고 소유권을 주장하고 있다. </p>



<p class="has-medium-font-size">두 사람은 막대기를 서로에게 던지는 방법을 이용해 누구의 소유 인지를 결정하기로 했다. <br><br>싸움은 동굴에서 벌어진다. 동굴에는 미네랄이 저장되어 있으며, 던진 막대기가 미네랄을 파괴할 수도 있다.</p>



<p class="has-medium-font-size">동굴은 R행 C열로 나타낼 수 있으며, R×C칸으로 이루어져 있다. </p>



<p class="has-medium-font-size">각 칸은 비어있거나 미네랄을 포함하고 있으며, 네 방향 중 하나로 인접한 미네랄이 포함된 두 칸은 같은 클러스터이다.</p>



<p class="has-medium-font-size">창영은 동굴의 왼쪽에 서있고, 상근은 오른쪽에 서있다. 두 사람은 턴을 번갈아가며 막대기를 던진다. </p>



<p class="has-medium-font-size">막대를 던지기 전에 던질 높이를 정해야 한다. 막대는 땅과 수평을 이루며 날아간다.</p>



<p class="has-medium-font-size">막대가 날아가다가 미네랄을 만나면, 그 칸에 있는 미네랄은 모두 파괴되고 막대는 그 자리에서 이동을 멈춘다.</p>



<p class="has-medium-font-size">미네랄이 파괴된 이후에 남은 클러스터가 분리될 수도 있다.  </p>



<p class="has-medium-font-size">새롭게 생성된 클러스터가 떠 있는 경우에는 중력에 의해서 바닥으로 떨어지게 된다. <br><br>떨어지는 동안 클러스터의 모양은 변하지 않는다. 클러스터는 다른 클러스터나 땅을 만나기 전까지 계속해서 떨어진다. <br><br>클러스터는 다른 클러스터 위에 떨어질 수 있고, 그 이후에는 합쳐지게 된다.</p>



<p class="has-medium-font-size">동굴에 있는 미네랄의 모양과 두 사람이 던진 막대의 높이가 주어진다. </p>



<p class="has-medium-font-size">모든 막대를 던지고 난 이후에 미네랄 모양을 구하는 프로그램을 작성하시오.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 동굴의 크기 R과 C가 주어진다. (1 ≤ R,C ≤ 100)</p>



<p class="has-medium-font-size">다음 R개 줄에는 C개의 문자가 주어지며, &#8216;.&#8217;는 빈 칸, &#8216;x&#8217;는 미네랄을 나타낸다.</p>



<p class="has-medium-font-size">다음 줄에는 막대를 던진 횟수 N이 주어진다. (1 ≤ N ≤ 100)</p>



<p class="has-medium-font-size">마지막 줄에는 막대를 던진 높이가 주어지며, 공백으로 구분되어져 있다. </p>



<p class="has-medium-font-size">모든 높이는 1과 R사이이며, 높이 1은 행렬의 가장 바닥, R은 가장 위를 의미한다. <br><br>첫 번째 막대는 왼쪽에서 오른쪽으로 던졌으며, 두 번째는 오른쪽에서 왼쪽으로, 이와 같은 식으로 번갈아가며 던진다.</p>



<p class="has-medium-font-size">공중에 떠 있는 미네랄 클러스터는 없으며, 두 개 또는 그 이상의 클러스터가 동시에 떨어지는 경우도 없다. </p>



<p class="has-medium-font-size">클러스터가 떨어질 때,&nbsp;그 클러스터 각 열의 맨 아래 부분 중 하나가 바닥 또는 미네랄 위로 떨어지는 입력만 주어진다.</p>



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



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



<p class="has-medium-font-size">입력 형식과 같은 형식으로 미네랄 모양을 출력한다.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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 6
......
..xx..
..x...
..xx..
.xxxx.
1
3</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">......
......
..xx..
..xx..
.xxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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 8
........
........
...x.xx.
...xxx..
..xxx...
..x.xxx.
..x...x.
.xxx..x.
5
6 6 4 3 1</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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="">........
........
........
........
.....x..
..xxxx..
..xxx.x.
..xxxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 3</h2>



<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 6
......
......
xx....
.xx...
..xx..
...xx.
....x.
2
6 4</pre>



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



<h2 class="wp-block-heading">예제 출력 3</h2>



<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="">......
......
......
......
..xx..
xx.xx.
.x..x.</pre>



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



<h2 class="wp-block-heading">예제 입력 A</h2>



<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="">13 100
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
..................................................x................................................x
..................................................x................................................x
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
..................................................x.................................................
11 
1 1 1 1 1 1 1 1 1 1 1 </pre>



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



<h2 class="wp-block-heading">예제 출력 A</h2>



<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="">....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
..................................................x................................................x
...................................................................................................x</pre>



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



<h2 class="wp-block-heading">예제 입력 B</h2>



<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 4
xxxx
xx.x
x..x
...x
1
3</pre>



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



<h2 class="wp-block-heading">예제 출력 B</h2>



<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="">xxxx
.x.x
...x
x..x</pre>



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



<h2 class="wp-block-heading">예제 입력 C</h2>



<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 2
..
.x
1
2</pre>



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



<h2 class="wp-block-heading">예제 출력 C</h2>



<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="">..
.x</pre>



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



<h2 class="wp-block-heading">예제 입력 D</h2>



<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 5
xxxxx
x....
xxxxx
x....
x....
10 1 2 3 4 5 1 2 3 4 5</pre>



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



<h2 class="wp-block-heading">예제 출력 D</h2>



<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="">.....
.....
.....
.xxxx
xxxx.</pre>



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



<h2 class="wp-block-heading">예제 입력 E</h2>



<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 4
...x
..xx
.xxx
xxxx
10 1 2 3 4 1 2 3 4 3 4</pre>



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



<h2 class="wp-block-heading">예제 출력 E</h2>



<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="">....
....
.xxx
..xx</pre>



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



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



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



<li>잘못된 조건을 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a></li>



<li>어색한 표현을 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/porrshe">po</a><a href="https://www.acmicpc.net/user/porrshe" target="_blank" rel="noreferrer noopener">rrshe</a></li>
</ul>



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



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



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



<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/141" 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)"/>



<p class="has-medium-font-size">첫째 줄에 동굴의 크기 R과 C (1 ≤ R,C ≤ 100)</p>



<p class="has-medium-font-size">다음 R개 줄에는 C개의 문자가 주어지며, &#8216;.&#8217;는 빈 칸, &#8216;x&#8217;는 미네랄을 나타낸다.</p>



<p class="has-medium-font-size">다음 줄에는 막대를 던진 횟수 N이 주어진다. (1 ≤ N ≤ 100)</p>



<p class="has-medium-font-size">모든 높이는 1과 R사이이며, 높이 1은 행렬의 가장 바닥, R은 가장 위를 의미한다.</p>



<p class="has-medium-font-size">공중에 떠 있는 미네랄 클러스터는 없으며, 두 개 또는 그 이상의 클러스터가 동시에 떨어지는 경우도 없다.</p>



<p class="has-medium-font-size"> 클러스터가 떨어질 때,&nbsp;그 클러스터 각 열의 맨 아래 부분 중 하나가 바닥 또는 미네랄 위로 떨어지는 입력만 주어진다.</p>



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



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



<p class="has-large-font-size">예제 1</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="650" height="438" src="https://lycos7560.com/wp-content/uploads/image-30.png" alt="" class="wp-image-2173" srcset="https://lycos7560.com/wp-content/uploads/image-30.png 650w, https://lycos7560.com/wp-content/uploads/image-30-300x202.png 300w" sizes="(max-width: 650px) 100vw, 650px" /></figure>



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



<p class="has-large-font-size">예제 2</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1307" height="813" src="https://lycos7560.com/wp-content/uploads/image-32.png" alt="" class="wp-image-2177" srcset="https://lycos7560.com/wp-content/uploads/image-32.png 1307w, https://lycos7560.com/wp-content/uploads/image-32-300x187.png 300w, https://lycos7560.com/wp-content/uploads/image-32-768x478.png 768w" sizes="(max-width: 1307px) 100vw, 1307px" /></figure>



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



<p class="has-large-font-size">예제 3</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="788" height="553" src="https://lycos7560.com/wp-content/uploads/image-35.png" alt="" class="wp-image-2181" srcset="https://lycos7560.com/wp-content/uploads/image-35.png 788w, https://lycos7560.com/wp-content/uploads/image-35-300x211.png 300w, https://lycos7560.com/wp-content/uploads/image-35-768x539.png 768w" sizes="(max-width: 788px) 100vw, 788px" /></figure>



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



<p class="has-medium-font-size">이번에도 문제를 이해하는 것이 오래 걸렸다.. 일단 글을 읽으면 머리 속에서 잘 정리가 되지 않는다. </p>



<p class="has-medium-font-size">한 3~4 번을 다시 글을 읽은 후에야 어느 정도 이해를 하는 듯&#8230;.</p>



<p class="has-medium-font-size">일단 동굴을 코드로 구현해보자</p>



<div style="height:45px" 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;list>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int temp = 0;


list&lt;int> myList;
list&lt;int>::iterator it;

bool debug = true;

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0){
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	if (debug) {
		for (int x = R; x >= 1; x--) {
			for (int y = 1; y &lt;= C; y++) {
				cout &lt;&lt; map[x][y] &lt;&lt; " ";
			}
			cout &lt;&lt; "\n";
		}
		cout &lt;&lt; "\n던진 막대기 높이 리스트\n";
		for (it = myList.begin(); it != myList.end(); it++) cout &lt;&lt; *it &lt;&lt; " ";
	}
	return 0;
}
</pre>



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



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



<p class="has-medium-font-size">다행히 생각대로 잘나온다.</p>



<div style="height:25px" 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/image-1052.png" alt="" class="wp-image-5501" width="806" height="453" srcset="https://lycos7560.com/wp-content/uploads/image-1052.png 639w, https://lycos7560.com/wp-content/uploads/image-1052-300x169.png 300w" sizes="(max-width: 806px) 100vw, 806px" /></figure>



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



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



<p class="has-medium-font-size">이제 막대기를 던져서 해당 위치의 미네랄을 파괴하는 것까지 구현</p>



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

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int temp = 0;


list&lt;int> myList;
list&lt;int>::iterator it;

bool debug = true;

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {
		// 해당 위치에 미네랄이 있는지 검색합니다.
		// 일단은 좌->우 검색
		for (int x = 1; x &lt;= C; x++) {
			// 만약 미네랄이 있다면
			if (map[*it][x] == 'x') {
				cout &lt;&lt; "\n찾음\n";
				// 해당 미네랄을 빈 공간
				map[*it][x] = '.';
				break;
			}
		}
	}




	if (debug) {
		for (int x = R; x >= 1; x--) {
			for (int y = 1; y &lt;= C; y++) {
				cout &lt;&lt; map[x][y] &lt;&lt; " ";
			}
			cout &lt;&lt; "\n";
		}
		cout &lt;&lt; "\n던진 막대기 높이 리스트\n";
		for (it = myList.begin(); it != myList.end(); it++) cout &lt;&lt; *it &lt;&lt; " ";
	}
	return 0;
}
</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="719" height="557" src="https://lycos7560.com/wp-content/uploads/image-1053.png" alt="" class="wp-image-5505" srcset="https://lycos7560.com/wp-content/uploads/image-1053.png 719w, https://lycos7560.com/wp-content/uploads/image-1053-300x232.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



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



<p class="has-medium-font-size">이제 좌/우에서 던지는 것을 구현해야 한다.</p>



<p class="has-medium-font-size">2가지 경우 좌/우 이므로 bool 값으로 체크해서 막대기를 던지는 것을 구현하였다.</p>



<div style="height:35px" 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;list>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int temp = 0;


list&lt;int> myList;
list&lt;int>::iterator it;

// true = left, false = right
bool leftRight = true;

bool debug = true;

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {
		
		// 해당 위치에 미네랄이 있는지 검색합니다.
		// 일단은 좌->우 검색
		if (leftRight) { // 좌측 검색
			for (int y = 1; y &lt;= C; y++) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					cout &lt;&lt; "\n찾음\n";
					// 해당 미네랄을 빈 공간
					map[*it][y] = '.';
					break;
				}
			}
			leftRight = !leftRight;
		}
		else { // 우측 검색
			for (int y = C; y >= 1; y--) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					cout &lt;&lt; "\n찾음\n";
					// 해당 미네랄을 빈 공간
					map[*it][y] = '.';
					break;
				}
			}
			leftRight = !leftRight;
		}

	}

	if (debug) {
		for (int x = R; x >= 1; x--) {
			for (int y = 1; y &lt;= C; y++) {
				cout &lt;&lt; map[x][y] &lt;&lt; " ";
			}
			cout &lt;&lt; "\n";
		}
		cout &lt;&lt; "\n던진 막대기 높이 리스트\n";
		for (it = myList.begin(); it != myList.end(); it++) cout &lt;&lt; *it &lt;&lt; " ";
	}
	return 0;
}
</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="730" height="545" src="https://lycos7560.com/wp-content/uploads/image-1054.png" alt="" class="wp-image-5508" srcset="https://lycos7560.com/wp-content/uploads/image-1054.png 730w, https://lycos7560.com/wp-content/uploads/image-1054-300x224.png 300w" sizes="(max-width: 730px) 100vw, 730px" /></figure>



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



<p class="has-medium-font-size">생각대로 미네랄이 잘 파괴가 되는 것 같다.</p>



<p class="has-medium-font-size">이제 미네랄이 파괴 되었을 경우 여기서 말하는 클러스터(상하좌우가 연결된 미네랄 덩이)가 </p>



<p class="has-medium-font-size">공중에 떠있지 못하게 하기만 하면 끝일 것 같은데&#8230;. 방법이 문제다.</p>



<p class="has-medium-font-size">미네랄이 파괴되면 바닥과 연결된 미네랄을 모두 마킹해 주었다. </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="">#include &lt;iostream>
#include &lt;list>
#include &lt;queue>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// 방문처리 
bool mapCheck[MAX][MAX];

// BFS 사용할 Q
queue&lt;pair&lt;int, int>> myQ;

pair&lt;int, int> tempP;

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int dx, dy;

int temp = 0;

// 탐색하는 방향 설정 =>  상, 하 ,좌 ,우
int dxdy[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };


list&lt;int> myList;
list&lt;int>::iterator it;

// true = left, false = right
bool check = false, leftRight = true;

bool debug = true;

void BFS(int x, int y)
{
	myQ.push(make_pair(x, y));

	while (!myQ.empty()) {
		tempP = myQ.front();
		myQ.pop();

		for (int i = 0; i &lt; 4; i++) {
			dy = tempP.second + dxdy[i][1];
			dx = tempP.first + dxdy[i][0];
			// 문제의 범위를 벗어나는 경우 => 넘어간다.
			if (dx &lt;= 0 || dy &lt;= 0 || dx > C || dy > R) continue;  // &lt;= 범위 틀림 기록용으로 남겨둠
			// 방문 처리가 되었거나 빈공간 => 넘어간다.
			if (mapCheck[dx][dy] == true || map[dx][dy] == '.') continue;
			mapCheck[dx][dy] = true;
			myQ.push(make_pair(dx, dy));
		}
	}

}

void CheckFloor() // 바닥을 체크합니다.
{
	for (int y = 1; y &lt;= C; y++) {
		// 바닥에 클러스터가 발견되고 방문처리가 되지 않았다면 
		if (map[1][y] == 'x' &amp;&amp; mapCheck[1][y] == false) {
			BFS(1, y); // BFS로 마킹
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {
		
		// 해당 위치에 미네랄이 있는지 검색합니다.
		// 일단은 좌->우 검색
		if (leftRight) { // 좌측 검색
			for (int y = 1; y &lt;= C; y++) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;

				}
			}

			leftRight = !leftRight;
		}
		else { // 우측 검색
			for (int y = C; y >= 1; y--) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}

		if (check) {  // 미네랄이 부셔졌다면 방문처리 초기화
			// 방문 처리를 초기화 
			for (int x = R; x >= 1; x--) {
				for (int y = 1; y &lt;= C; y++) {
					mapCheck[x][y] = false;
				}
			}
			check = false;
		}

	}

	if (debug) {

		for (int x = R; x >= 1; x--) {
			for (int y = 1; y &lt;= C; y++) {
				cout &lt;&lt; map[x][y] &lt;&lt; " ";
			}
			cout &lt;&lt; "\n";
		}
		cout &lt;&lt; "\n던진 막대기 높이 리스트\n";
		for (it = myList.begin(); it != myList.end(); it++) cout &lt;&lt; *it &lt;&lt; " ";
	}

	return 0;

}
</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="940" height="478" src="https://lycos7560.com/wp-content/uploads/image-41.png" alt="" class="wp-image-2190" srcset="https://lycos7560.com/wp-content/uploads/image-41.png 940w, https://lycos7560.com/wp-content/uploads/image-41-300x153.png 300w, https://lycos7560.com/wp-content/uploads/image-41-768x391.png 768w" sizes="(max-width: 940px) 100vw, 940px" /></figure>



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



<p class="has-medium-font-size">이제 공중에 있는 클러스터들의 좌표들을 저장하는 리스트를 만들고 확인</p>



<div style="height:27px" 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;list>
#include &lt;queue>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// 방문처리 
bool mapCheck[MAX][MAX];

// BFS 사용할 Q
queue&lt;pair&lt;int, int>> myQ;

pair&lt;int, int> tempP;

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int dx, dy;

int temp = 0;

// 탐색하는 방향 설정 =>  상, 하 ,좌 ,우
int dxdy[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };


list&lt;int> myList;
list&lt;int>::iterator it;

list&lt;pair&lt;int, int>> cList;
list&lt;pair&lt;int, int>>::iterator cit;

// true = left, false = right
bool check = false, leftRight = true;

bool debug = true;

void BFS(int x, int y)
{
	myQ.push(make_pair(x, y));

	while (!myQ.empty()) {
		tempP = myQ.front();
		myQ.pop();

		for (int i = 0; i &lt; 4; i++) {
			dy = tempP.second + dxdy[i][1];
			dx = tempP.first + dxdy[i][0];
			// 문제의 범위를 벗어나는 경우 => 넘어간다.
			if (dx &lt;= 0 || dy &lt;= 0 || dx > C || dy > R) continue; // &lt;= 범위 틀림 기록용으로 남겨둠
			// 방문 처리가 되었거나 빈공간 => 넘어간다.
			if (mapCheck[dx][dy] == true || map[dx][dy] == '.') continue;
			mapCheck[dx][dy] = true;
			myQ.push(make_pair(dx, dy));
		}
	}

}

void CheckFloor() // 바닥을 체크합니다.
{
	for (int y = 1; y &lt;= C; y++) {
		// 바닥에 클러스터가 발견되고 방문처리가 되지 않았다면 
		if (map[1][y] == 'x' &amp;&amp; mapCheck[1][y] == false) {
			BFS(1, y); // BFS로 마킹
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {
		cList.clear();
		// 해당 위치에 미네랄이 있는지 검색합니다.
		// 일단은 좌->우 검색
		if (leftRight) { // 좌측 검색
			for (int y = 1; y &lt;= C; y++) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;

				}
			}

			leftRight = !leftRight;
		}
		else { // 우측 검색
			for (int y = C; y >= 1; y--) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}

		if (check) {  // 미네랄이 부셔졌다면

			for (int x = R; x >= 1; x--) {
				for (int y = 1; y &lt;= C; y++) {
					if (map[x][y] == 'x' &amp;&amp; mapCheck[x][y] == false) {
						cList.push_back(make_pair(x, y));
					}
				}
			}


			// 방문 처리를 초기화 
			for (int x = R; x >= 1; x--) {
				for (int y = 1; y &lt;= C; y++) {
					mapCheck[x][y] = false;
				}
			}
			check = false;
		}

	}

	if (debug) {

		for (int x = R; x >= 1; x--) {
			for (int y = 1; y &lt;= C; y++) {
				cout &lt;&lt; map[x][y] &lt;&lt; " ";
			}
			cout &lt;&lt; "\n";
		}
		cout &lt;&lt; "\n던진 막대기 높이 리스트\n";
		for (it = myList.begin(); it != myList.end(); it++) cout &lt;&lt; *it &lt;&lt; " ";
		cout &lt;&lt; "\n떠있는 클러스터 리스트 리스트\n";
		for (cit = cList.begin(); cit != cList.end(); cit++) cout &lt;&lt; " x : " &lt;&lt; cit->first &lt;&lt; " y : " &lt;&lt; cit->second &lt;&lt; "\n";
	}

	return 0;

}
</pre>



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



<div style="height:67px" 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/image-1055.png" alt="" class="wp-image-5514" width="859" height="593" srcset="https://lycos7560.com/wp-content/uploads/image-1055.png 786w, https://lycos7560.com/wp-content/uploads/image-1055-300x207.png 300w, https://lycos7560.com/wp-content/uploads/image-1055-768x531.png 768w" sizes="(max-width: 859px) 100vw, 859px" /></figure>



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



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



<p class="has-medium-font-size">미네랄이 파괴되면 바닥과 연결된 미네랄을 방문 처리해준다.</p>



<p class="has-medium-font-size">맵 전체에서 방문처리가 되지 않은 미네랄을 리스트에 담아준다</p>



<p class="has-medium-font-size">미네랄 리스트를 순회하면서 아래 부분이 방문 처리가 된 곳인지 확인한다. (내려갈 길이를 찾기 위함)</p>



<p class="has-medium-font-size">하단부가 방문처리가 되었다면 그 거리 -1 만큼 미네랄을 옮겨준다.</p>



<p class="has-medium-font-size">막대기의 수 만큼 위의 로직을 반복</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;list>
#include &lt;queue>

using namespace std;

// RC의 범위 최대값
constexpr int MAX = 101;

// 기본 맵
char map[MAX][MAX];

// 방문처리 
bool mapCheck[MAX][MAX];

// BFS 사용할 Q
queue&lt;pair&lt;int, int>> myQ;

pair&lt;int, int> tempP;

// R 행, C 열, N 막대기를 던진 횟수
int R, C, N;

int dx, dy, dis;

int temp = 0;

// 탐색하는 방향 설정 =>  상, 하 ,좌 ,우
int dxdy[4][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };


list&lt;int> myList;
list&lt;int>::iterator it;

list&lt;pair&lt;int, int>> cList;
list&lt;pair&lt;int, int>>::iterator cit;

// true = left, false = right
bool check = false, leftRight = false;

void BFS(int x, int y)
{
	myQ.push(make_pair(x, y));

	while (!myQ.empty()) {
		tempP = myQ.front();
		myQ.pop();

		for (int i = 0; i &lt; 4; i++) {
			dy = tempP.second + dxdy[i][1];
			dx = tempP.first + dxdy[i][0];
			// 문제의 범위를 벗어나는 경우 => 넘어간다.
			if (dx &lt;= 0 || dy &lt;= 0 || dy > C || dx > R) continue;
			// 방문 처리가 되었거나 빈공간 => 넘어간다.
			if (mapCheck[dx][dy] == true || map[dx][dy] == '.') continue;
			mapCheck[dx][dy] = true;
			myQ.push(make_pair(dx, dy));
		}
	}
}

void CheckFloor() // 바닥을 체크합니다.
{
	for (int y = 1; y &lt;= C; y++) {
		// 바닥에 클러스터가 발견되고 방문처리가 되지 않았다면 
		if (map[1][y] == 'x' &amp;&amp; mapCheck[1][y] == false) {
			BFS(1, y); // BFS로 마킹
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	// 처음 맵을 초기화 해준다.
	for (int x = 1; x &lt; MAX; x++) {
		for (int y = 1; y &lt; MAX; y++) {
			map[x][y] = '.';
		}
	}

	cin >> R >> C;

	// 미네랄의 위치를 설정 (아래서 부터 시작)
	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cin >> map[x][y];
		}
	}

	cin >> N;

	/// 던진 횟수와 높이를 설정
	while (N > 0) {
		cin >> temp;
		myList.push_back(temp);
		N--;
	}

	// 던진 막대기 리스트를 순회합니다.
	for (it = myList.begin(); it != myList.end(); it++) {

		check = false; // 미네랄 부셔짐 체크 해제
		cList.clear(); // 공중의 미네랄 리스트 초기화

		// 해당 위치에 미네랄이 있는지 검색합니다.
		if (leftRight) { // 좌측 검색
			for (int y = C; y >= 1; y--) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}
		else { // 우측 검색
			for (int y = 1; y &lt;= C; y++) {
				// 만약 미네랄이 있다면
				if (map[*it][y] == 'x') {
					// 해당 미네랄을 빈 공간으로 만든다.
					map[*it][y] = '.';
					// 바닥과 연결된 모든 클러스터를 방문처리
					CheckFloor();
					check = true;
					break;
				}
			}

			leftRight = !leftRight;
		}

		if (check) {  // 미네랄이 부셔졌다면
			// 공중에 있는 클러스트들을 리스트에 담는다.
			for (int x = R; x >= 1; x--) {
				for (int y = C; y >= 1; y--) {
					if (map[x][y] == 'x' &amp;&amp; mapCheck[x][y] == false) {
						cList.push_back(make_pair(x, y));
					}
				}
			}

			// 공중에 미네랄이 바닥과 연결될때까지 반복
			dis = 1;
			bool floor = true;
			while (floor) {

				if (cList.size() == 0) break;

				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;

					if (mapCheck[tempP.first - (dis + 1)][tempP.second] == true || tempP.first - (dis + 1) == 0) {
						floor = false;
						break;
					}
				}

				dis++;
			}

			if (!floor) {
				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;
					map[tempP.first][tempP.second] = '.';
				}

				for (cit = cList.begin(); cit != cList.end(); cit++) {
					tempP.first = cit->first;
					tempP.second = cit->second;
					map[tempP.first - (dis - 1)][tempP.second] = 'x';
				}	
			}

			// 방문 처리를 초기화 
			for (int x = R; x >= 1; x--) {
				for (int y = 1; y &lt;= C; y++) {
					mapCheck[x][y] = false;
				}
			}
		}
	}

	for (int x = R; x >= 1; x--) {
		for (int y = 1; y &lt;= C; y++) {
			cout &lt;&lt; map[x][y];
		}
		if (x == 1) break;
		cout &lt;&lt; "\n";
	}

	return 0;

}
</pre>



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



<p class="has-medium-font-size"><strong>계속 틀린 원인은 바닥과 연결된 클러스터를 찾는 BFS 탐색에서 R과 C의 범위를 바꾸어 탐색</strong></p>



<p class="has-medium-font-size">이 부분 하나로 엄청난 시간을 낭비</p>



<p class="has-medium-font-size">웃긴 부분은 다른 테스트 케이스는 다 잘돌아감 ㅋㅋ </p>



<p>구현이 조금 빡센 문제&#8230;</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1038" height="847" src="https://lycos7560.com/wp-content/uploads/image-1056.png" alt="" class="wp-image-5516" srcset="https://lycos7560.com/wp-content/uploads/image-1056.png 1038w, https://lycos7560.com/wp-content/uploads/image-1056-300x245.png 300w, https://lycos7560.com/wp-content/uploads/image-1056-768x627.png 768w" sizes="(max-width: 1038px) 100vw, 1038px" /></figure>



<figure class="wp-block-image size-full"><img decoding="async" width="1039" height="453" src="https://lycos7560.com/wp-content/uploads/image-1057.png" alt="" class="wp-image-5517" srcset="https://lycos7560.com/wp-content/uploads/image-1057.png 1039w, https://lycos7560.com/wp-content/uploads/image-1057-300x131.png 300w, https://lycos7560.com/wp-content/uploads/image-1057-768x335.png 768w" sizes="(max-width: 1039px) 100vw, 1039px" /></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-2933%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/2163/">백준 2933번 (미네랄, C++, Simulation) / 추가 반례 [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-2933%eb%b2%88-%eb%af%b8%eb%84%a4%eb%9e%84-c-simulation-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/2163/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1446번 (지름길, C++, Dijkstra) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1446%eb%b2%88-%ec%a7%80%eb%a6%84%ea%b8%b8-c-dijkstra-baekjoon/5322/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1446%eb%b2%88-%ec%a7%80%eb%a6%84%ea%b8%b8-c-dijkstra-baekjoon/5322/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 23 Jan 2023 09:23:15 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1446]]></category>
		<category><![CDATA[1446번]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Dijkstra]]></category>
		<category><![CDATA[DP]]></category>
		<category><![CDATA[DynamicProgramming]]></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[백준 1446]]></category>
		<category><![CDATA[백준 1446번]]></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=5322</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 1446번 '지름길' 문제에 대한 글입니다. 'Dijkstra' 알고리즘을 이용하여 해결하였습니다. (백준(BAEKJOON) 1446번 '지름길' 문제에 대한 글입니다. 'Dijkstra' 알고리즘을 이용하여 해결하였습니다. (BAEKJOON 1446 This is about the 'shortcut' problem, solved using the 'Dijkstra' algorithm.))</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1446%eb%b2%88-%ec%a7%80%eb%a6%84%ea%b8%b8-c-dijkstra-baekjoon/5322/">백준 1446번 (지름길, C++, Dijkstra) [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>



<h1 class="wp-block-heading">지름길</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1446" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1446</a></p>



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



<figure id="problem-info" 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">5137</td><td class="has-text-align-left" data-align="left">2633</td><td class="has-text-align-left" data-align="left">1998</td><td class="has-text-align-left" data-align="left">50.995%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">매일 아침, 세준이는 학교에 가기 위해서 차를 타고 D킬로미터 길이의 고속도로를 지난다. </p>



<p class="has-medium-font-size">이 고속도로는 심각하게 커브가 많아서 정말 운전하기도 힘들다. </p>



<p class="has-medium-font-size">어느 날, 세준이는 이 고속도로에 지름길이 존재한다는 것을 알게 되었다. </p>



<p class="has-medium-font-size">모든 지름길은 일방통행이고, 고속도로를 역주행할 수는 없다.</p>



<p class="has-medium-font-size">세준이가 운전해야 하는 거리의 최솟값을 출력하시오.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 지름길의 개수 N과 고속도로의 길이 D가 주어진다. </p>



<p class="has-medium-font-size">N은 12 이하인 양의 정수이고, D는 10,000보다 작거나 같은 자연수이다. </p>



<p class="has-medium-font-size">다음 N개의 줄에 지름길의 시작 위치, 도착 위치, 지름길의 길이가 주어진다. </p>



<p class="has-medium-font-size">모든 위치와 길이는 10,000보다 작거나 같은 음이 아닌 정수이다. </p>



<p class="has-medium-font-size">지름길의 시작 위치는 도착 위치보다 작다.</p>



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



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



<p class="has-medium-font-size">세준이가 운전해야하는 거리의 최솟값을 출력하시오.</p>



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



<h2 class="wp-block-heading">예제 입력 1</h2>



<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 150
0 50 10
0 50 20
50 100 10
100 151 10
110 140 90</pre>



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



<h2 class="wp-block-heading">예제 출력 1</h2>



<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="">70</pre>



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



<h2 class="wp-block-heading">예제 입력 2</h2>



<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 100
10 60 40
50 90 20</pre>



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



<h2 class="wp-block-heading">예제 출력 2</h2>



<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="">80</pre>



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



<h2 class="wp-block-heading">예제 입력 3</h2>



<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 900
0 10 9
20 60 45
80 190 100
50 70 15
160 180 14
140 160 14
420 901 5
450 900 0</pre>



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



<h2 class="wp-block-heading">예제 출력 3</h2>



<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="">432</pre>



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



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



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



<li>문제를 다시 작성한 사람:&nbsp;<a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a></li>
</ul>



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/25" target="_blank" rel="noreferrer noopener">다이나믹 프로그래밍</a></li>



<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/22" 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)"/>



<p class="has-medium-font-size">기본적인 로직은 Dujkstra 알고리즘을 기반으로 한다. </p>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="VztkgwMIoE"><a href="https://lycos7560.com/?p=5223">알고리즘 &#8211; 다익스트라/데이크스트라(Dijkstra) 알고리즘 정리 (길찾기)</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;알고리즘 &#8211; 다익스트라/데이크스트라(Dijkstra) 알고리즘 정리 (길찾기)&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/?p=5223&#038;embed=true#?secret=rNOzQBw4eP#?secret=VztkgwMIoE" data-secret="VztkgwMIoE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<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-image size-full is-resized"><img decoding="async" width="721" height="463" src="https://lycos7560.com/wp-content/uploads/image-1034.png" alt="" class="wp-image-5326" style="width:945px;height:607px" srcset="https://lycos7560.com/wp-content/uploads/image-1034.png 721w, https://lycos7560.com/wp-content/uploads/image-1034-300x193.png 300w" sizes="(max-width: 721px) 100vw, 721px" /></figure>



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



<h2 class="wp-block-heading">주의사항</h2>



<p class="has-medium-font-size">주의할 점은 역주행이 불가능하다는 점 (현재 위치에서 지름길을 더한 값이 목적지를 넘어가면 안된다.)</p>



<p class="has-medium-font-size">또 지름길이 순서대로 이쁘게 주어지지 않는다. (정렬을 해서 처리하는 것도 하나의 방법)</p>



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



<p class="has-medium-font-size">내 풀이는 최단경로 테이블을 갱신하면 목적지 그 이후의 값을  dist[]가 더 적거나 목적지까지 +1 해주면서 업데이트 해주었다. </p>



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



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="745" height="439" src="https://lycos7560.com/wp-content/uploads/image-1035.png" alt="" class="wp-image-5328" style="width:867px;height:511px" srcset="https://lycos7560.com/wp-content/uploads/image-1035.png 745w, https://lycos7560.com/wp-content/uploads/image-1035-300x177.png 300w" sizes="(max-width: 745px) 100vw, 745px" /></figure>



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



<h2 class="wp-block-heading">통과된 코드</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;

constexpr int MAXN = 10001;

// 지름길의 개수 N, 고속도로의 길이 D
int N, D;

int A, B, C;

/*
각 노드에 연결되어 있는 노드에 대한 정보를 담는 벡터
a번 노드에서 b번 노드로 가는 비용이 c라는 의미
graph[a].push_back({b, c});
*/
vector&lt;pair&lt;int, int>> graph[MAXN];

// 임시 노드
int dist[MAXN];

int main()
{
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	// scanf와 동기화를 비활성화
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> N >> D;

	for (int i = 0; i &lt; N; i++) {
		cin >> A >> B >> C;
		graph[A].push_back(make_pair(B, C));
	}

	// 기본 초기화
	for (int i = 0; i &lt; MAXN; i++) dist[i] = i;

	int now = 0;
	while (true) {

		if (now == D) { 
			// 목적지에 도착했으므로 결과를 출력
			cout &lt;&lt; dist[now];
			break;
		}

		// 해당 노드에서 연결된 모든 경로를 확인
        for (int i = 0; i &lt; graph[now].size(); i++) {

            // disSum = 임시 노드 + 현재 노드에서 i로가는 비용
            int disSum = dist[now] + graph[now][i].second;
			
			// 역주행을 해야할 경우는 continue
			if (disSum > D) continue; 


            // 비용이 더 작다면 최단경로 테이블 값을 갱신.
            if (disSum &lt; dist[graph[now][i].first]) {
                // 임시 노드 업데이트
				dist[graph[now][i].first] = disSum;

				// 만약 업데이트 했다면 그 이후의 정점들을 순차적으로 올려준다.
				for (int j = graph[now][i].first + 1; j &lt;= D ; j++) {
					// 만약  dist[j]이 더 작거나 같다면 최단거리가 있다는 의미 => Break
					if (disSum >= dist[j]) break;
					else dist[j] = ++disSum;
				}
            }
        }

		now++;
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1039" height="138" src="https://lycos7560.com/wp-content/uploads/image-1032.png" alt="" class="wp-image-5323" srcset="https://lycos7560.com/wp-content/uploads/image-1032.png 1039w, https://lycos7560.com/wp-content/uploads/image-1032-300x40.png 300w, https://lycos7560.com/wp-content/uploads/image-1032-768x102.png 768w" sizes="(max-width: 1039px) 100vw, 1039px" /></figure>



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



<p class="has-medium-font-size">dijkstra 알고리즘이 익숙하지 않아 해결하는데 오래 걸렸다&#8230;</p>



<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-1446%eb%b2%88-%ec%a7%80%eb%a6%84%ea%b8%b8-c-dijkstra-baekjoon/5322/">백준 1446번 (지름길, C++, Dijkstra) [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-1446%eb%b2%88-%ec%a7%80%eb%a6%84%ea%b8%b8-c-dijkstra-baekjoon/5322/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1493번 (박스 채우기, C++, 분할 정복) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-1493%eb%b2%88-%eb%b0%95%ec%8a%a4-%ec%b1%84%ec%9a%b0%ea%b8%b0-c-%eb%b6%84%ed%95%a0-%ec%a0%95%eb%b3%b5/611/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-1493%eb%b2%88-%eb%b0%95%ec%8a%a4-%ec%b1%84%ec%9a%b0%ea%b8%b0-c-%eb%b6%84%ed%95%a0-%ec%a0%95%eb%b3%b5/611/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 17:07:14 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1493]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[DivideAndConquer]]></category>
		<category><![CDATA[divisionconquest]]></category>
		<category><![CDATA[박스 채우기]]></category>
		<category><![CDATA[박스채우기]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1493]]></category>
		<category><![CDATA[백준 1493번]]></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.synology.me/?p=611</guid>

					<description><![CDATA[<p>백준 1493번 '박스 채우기' 문제에 대한 글입니다. '분할 정복' 알고리즘을 이용하여 해결하였습니다. (This is an article on the question of 'fill the box' in Baekjoon 1493. Solved using the 'division conquest' algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-1493%eb%b2%88-%eb%b0%95%ec%8a%a4-%ec%b1%84%ec%9a%b0%ea%b8%b0-c-%eb%b6%84%ed%95%a0-%ec%a0%95%eb%b3%b5/611/">백준 1493번 (박스 채우기, 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-39139147      "
					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><li class="uagb-toc__list"><a href="#잘못된-로직과-코드-1" class="uagb-toc-link__trigger">잘못된 로직과 코드 1</a><li class="uagb-toc__list"><a href="#잘못된-로직과-코드-2" class="uagb-toc-link__trigger">잘못된 로직과 코드 2</a><li class="uagb-toc__list"><a href="#잘못된-로직과-코드-3" class="uagb-toc-link__trigger">잘못된 로직과 코드 3</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>



<h1 class="wp-block-heading"><strong>박스 채우기</strong></h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1493" target="_blank" rel="noreferrer noopener">www.acmicpc.net/problem/1493</a></p>



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



<figure id="problem-info" class="wp-block-table is-style-regular"><table class="has-ast-global-color-8-color has-ast-global-color-5-background-color has-text-color has-background 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">4718</td><td class="has-text-align-left" data-align="left">1271</td><td class="has-text-align-left" data-align="left">909</td><td class="has-text-align-left" data-align="left">27.224%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">세준이는 length × width × height 크기의 박스를 가지고 있다.</p>



<p class="has-medium-font-size">그리고 세준이는 이 박스를 큐브를 이용해서 채우려고 한다.</p>



<p class="has-medium-font-size">큐브는 정육면체 모양이며, 한 변의 길이는 2의 제곱꼴이다.</p>



<p class="has-medium-font-size">(1×1×1, 2×2×2, 4×4×4, 8×8×8, …)</p>



<p class="has-medium-font-size">세준이가 가지고 있는 박스의 종류와 큐브의 종류와 개수가 주어졌을 때,</p>



<p class="has-medium-font-size">박스를 채우는데 필요한 큐브의 최소 개수를 출력하는 프로그램을 작성하시오.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 세 자연수 length width height가 주어진다.</p>



<p class="has-medium-font-size">둘째 줄에 세준이가 가지고 있는 큐브의 종류의 개수 N이 주어진다.</p>



<p class="has-medium-font-size">셋째 줄부터 총 N개의 줄에 큐브의 종류 Ai와&nbsp;개수 Bi가 i가 증가하는 순서대로 주어진다.</p>



<p class="has-medium-font-size">큐브의 종류는 한 변의 길이를 나타낼 때 쓰는 2i에서 i이다.</p>



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



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



<p class="has-medium-font-size">첫째 줄에 필요한 큐브의 개수의 최솟값을 출력한다. </p>



<p class="has-medium-font-size">만약 채울 수 없다면 -1을 출력한다.</p>



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



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



<ul class="wp-block-list">
<li>1 ≤ length, width, height ≤ 10<sup>6</sup></li>



<li>1 ≤ n ≤ 20</li>



<li>0 ≤ A<sub>i</sub>&nbsp;&lt; 20</li>



<li>0 ≤ B<sub>i</sub>&nbsp;≤ 10<sup>6</sup></li>



<li>A<sub>i</sub>&nbsp;≠ A<sub>j</sub>&nbsp;(i ≠ j)</li>
</ul>



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



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



<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 4 8
3
0 10
1 10
2 1
</pre>



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



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



<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="">9
</pre>



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



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



<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 4 8
3
0 10
1 10
2 10
</pre>



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



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



<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:40px" aria-hidden="true" class="wp-block-spacer"></div>



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



<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="">10 10 11
1
0 2000
</pre>



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



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



<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="">1100
</pre>



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



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



<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="">10 10 11
1
0 1099
</pre>



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



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



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



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



<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="">37 42 59
6
0 143821
1 14382
2 1438
3 143
4 14
5 1
</pre>



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



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



<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="">5061
</pre>



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



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



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



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/ho94949" target="_blank" rel="noreferrer noopener">ho94949</a></li>
</ul>



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/33" target="_blank" rel="noreferrer noopener">그리디 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/24" 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)"/>



<p class="has-medium-font-size">length × width × height 크기의 박스</p>



<p class="has-medium-font-size">이 박스를 큐브로 채우려고 한다.</p>



<p class="has-medium-font-size">큐브의 크기는 정육면체 모양이며 한 변의 길이는 2의 제곱 꼴 1, 2, 4, 8…</p>



<p class="has-medium-font-size">박스를 채우는데 필요한 큐브의 최소 개수를 찾는 문제</p>



<p class="has-medium-font-size">4 4 8 // 박스 length × width × height</p>



<p class="has-medium-font-size">3 // 큐브의 개수</p>



<p class="has-medium-font-size">0 10 // 변의 길이 : 2^0 10개 넓이 1 10개</p>



<p class="has-medium-font-size">1 10 // 변의 길이 : 2^1 10개 넓이 8 10개</p>



<p class="has-medium-font-size">2 1 // 변의 길이 : 2^2 1개 넓이 64 1개</p>



<p class="has-medium-font-size">넓이 128 64 + 10 + 10 + 10 + 10 + 10 + 10</p>



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



<p class="has-medium-font-size">박스는 부피</p>



<p class="has-medium-font-size">큐브는 각 큐브의 한 변의 길이와 개수만 가지고 있으면 될 것 같다</p>



<p class="has-medium-font-size">박스가 큐브의 개수와는 상관없이</p>



<p class="has-medium-font-size">만들어질 수 있는 경우의 수를 조건과 비교하면서 하면 어떨까???</p>



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



<h1 class="wp-block-heading"><strong>입력 확인</strong></h1>



<div style="height:44px" 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;set>

using namespace std;

// 큐브의 변의 길이 순으로 내림차순 정렬
set&lt;int, greater&lt;int>> cubeSet;
set&lt;int, greater&lt;int>> ::iterator iter;

// 큐브의 개수를 저장 / 인덱스는 2^index
int cubeNumber[21] = { 0 };

// 박스의 가 세 높
int length, width, height = 0;

// 박스의 부피
int boxArea = 0;

// 큐브의 종류 , 큐브의 수
int type, Number = 0;

void Initializaion()
{
	cin >> length >> width >> height;
	boxArea = length * width * height;
	int N = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> type >> Number;
		cubeSet.insert(type);
		cubeNumber[type] += Number;
		N--;
	}
}

int main()
{
	Initializaion();
	cout &lt;&lt; "박스의 부피 : " &lt;&lt; boxArea &lt;&lt; "\n";
	for (iter = cubeSet.begin(); iter != cubeSet.end(); iter++)
	{
		cout &lt;&lt; "큐브 변의 길이 2^ " &lt;&lt; *iter &lt;&lt; "   박스의 개수 :  " &lt;&lt; cubeNumber[*iter] &lt;&lt; " \n";
	}
    
	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="853" height="217" src="https://lycos7560.com/wp-content/uploads/image-92.png" alt="" class="wp-image-2326" srcset="https://lycos7560.com/wp-content/uploads/image-92.png 853w, https://lycos7560.com/wp-content/uploads/image-92-300x76.png 300w, https://lycos7560.com/wp-content/uploads/image-92-768x195.png 768w" sizes="(max-width: 853px) 100vw, 853px" /></figure>



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



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



<p class="has-medium-font-size">마지막 테스트 케이스에서 망… 함 ㅠ</p>



<p class="has-medium-font-size">부피로 접근하는 방법은 잘못된 방법이다</p>



<p class="has-medium-font-size">큐브들의 부피가 박스의 부피와 같다고 큐브가 박스 모양일 거라는 착각…</p>



<div style="height:60px" 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>



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



<h1 class="wp-block-heading"><strong>잘못된 로직과 코드 1</strong></h1>



<div style="height:28px" 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;set>
#include &lt;cmath>

using namespace std;

// 큐브의 변의 길이 순으로 내림차순 정렬
set&lt;int, greater&lt;int>> cubeSet;
set&lt;int, greater&lt;int>> ::iterator iter;

// 큐브의 개수를 저장 / 인덱스는 2^index
int cubeNumber[21] = { 0 };

// 박스의 가 세 높
int length, width, height = 0;

// 박스의 넓이
int boxArea = 0;

// 큐브의 종류 , 큐브의 수
int type, Number = 0;


void Initializaion()
{
	cin >> length >> width >> height;
	boxArea = length * width * height;
	int N = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> type >> Number;
		cubeSet.insert(type);
		cubeNumber[type] += Number;
		N--;
	}
}

void CubeCheck(int cnt, int value)
{

	if (value == boxArea)
	{
		cout &lt;&lt; "찾았다 : " &lt;&lt; cnt &lt;&lt; "  boxArea : " &lt;&lt; boxArea &lt;&lt;  "  value : " &lt;&lt; value &lt;&lt; "\n";
		for (auto it = cubeSet.begin(); it != cubeSet.end(); it++)
		{
			cout &lt;&lt; "it : " &lt;&lt; *it &lt;&lt; "  cubeNumber[*it] : " &lt;&lt; cubeNumber[*it] &lt;&lt; "\n";
		}
		exit(0);
	}

	for (auto it = cubeSet.begin(); it != cubeSet.end(); it++)
	{
		if (cubeNumber[*it] == 0 || value > boxArea )
		{
			return;
		}
		//cout &lt;&lt; "cubeNumber[" &lt;&lt; *it &lt;&lt; "]  : " &lt;&lt; cubeNumber[*it] &lt;&lt; "\n";
		cubeNumber[*it]--;
		//cout &lt;&lt; "cnt : " &lt;&lt; cnt &lt;&lt; " 들어갈 때 : " &lt;&lt; value &lt;&lt; " ";
		CubeCheck(cnt + 1, value + pow(pow(2,*it),3));
		cubeNumber[*it]++;
	}
	cout &lt;&lt; -1;
	exit(0);
}

int main()
{
	Initializaion();
	CubeCheck(0, 0);
	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1174" height="318" src="https://lycos7560.com/wp-content/uploads/image-93.png" alt="" class="wp-image-2328" srcset="https://lycos7560.com/wp-content/uploads/image-93.png 1174w, https://lycos7560.com/wp-content/uploads/image-93-300x81.png 300w, https://lycos7560.com/wp-content/uploads/image-93-768x208.png 768w" sizes="(max-width: 1174px) 100vw, 1174px" /></figure>



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



<p class="has-medium-font-size">그렇다면 박스에서 접근해야 한다.</p>



<p class="has-medium-font-size">박스를 큐브의 규격을 기준으로 분할하여 그리디 알고리즘을 적용하면서 푸는 것 인가?</p>



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



<h1 class="wp-block-heading"><strong>잘못된 로직과 코드 2</strong></h1>



<div style="height:46px" 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;set>
#include &lt;cmath>
#include &lt;algorithm>

using namespace std;

// 큐브의 변의 길이 순으로 내림차순 정렬
set&lt;int, greater&lt;int>> cubeSet;
set&lt;int, greater&lt;int>> ::iterator iter;

// 큐브의 개수를 저장 / 인덱스는 2^index
int cubeNumber[21] = { 0 };
int cubeNeedNumber[21] = { 0 };

// 박스의 X,Y,Z
int BoxXYZ[3] = { 0 };
int temp[3] = { 0 };

// 큐브의 종류 , 큐브의 수
int type, Number = 0;

int cubeCNT = 0;

void Initializaion()
{

	cin >> BoxXYZ[0] >> BoxXYZ[1] >> BoxXYZ[2];
	sort(BoxXYZ, BoxXYZ + (sizeof(BoxXYZ)/sizeof(BoxXYZ[0])));
	int N = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> type >> Number;
		cubeSet.insert(type);
		cubeNumber[type] += Number;
		N--;
	}
}

// 가장 큰 X를 기준으로 Z를 채워나감
// 들어오는 값은 X의 길이/Z의 남은 길이/ 몇번 나누었는지 확인(0부터 시작)
// 이 함수의 목적은 Z가 0이 될때까지 큐브를 찾는 것
void CubeCheckZ(int N, int leftZ, int divisionCount, int st)
{

	for (;leftZ >= pow(2, N);)
	{
		cout &lt;&lt; "leftZ : " &lt;&lt; leftZ &lt;&lt; " pow(2, N) : " &lt;&lt; pow(2, N) &lt;&lt; "\n";
		if (divisionCount == 0 &amp;&amp; st == pow(2, N))
		{
			BoxXYZ[2] -= st;
			st = -1;
		}
		
		if (st == -1)
		{
			cubeNeedNumber[N] += pow(4, divisionCount);
		}
		else
		{
			cubeNeedNumber[N] += pow(4, divisionCount) * (st / pow(2, N));
		}

		leftZ -= pow(2, N);
		
		if (leftZ == 0)
		{
			return;
		}
	}

	// 남은 Z의 길이보다 pow(2, N)가 더 큰 상황 
	for (;leftZ &lt; pow(2, N);)
	{
		N--;
		divisionCount++;
		cout &lt;&lt; "남은 Z의 길이보다 작은 박스 값 찾기 : " &lt;&lt; " N : " &lt;&lt; N &lt;&lt; "  pow(2, N) : " &lt;&lt; pow(2, N) &lt;&lt; "  leftZ  :  " &lt;&lt; leftZ &lt;&lt; "\n";
	}

	CubeCheckZ(N, leftZ, divisionCount, st);
}


// 박스 전체의 X길이와 Z의 길이
void CubeCheckX(int BoxX, int BoxZ, int st, int boxY)
{
	if (BoxX == 0)
	{
		return;
	}
	// 처음 할 때
	int N = 0;
	for (int i = 0; i &lt;= 20; i++)
	{
		if (boxY &lt; pow(2, i))
		{
			N = i - 1;
			break;
		}
		else if (boxY == pow(2, i))
		{
			N = i;
			break;
		}
		
		//X의 값에 가장 근접한 2^i 를 구함
		if (BoxX &lt; pow(2, i) )
		{

			N = i - 1;
			cout &lt;&lt; "높을때 : " &lt;&lt; N ;
			//cubeNeedNumber[N]++;
			break;

		}
		else if (BoxX == pow(2, i) )
		{
			//cout &lt;&lt; "BoxX : " &lt;&lt; BoxX &lt;&lt; " 같을때" &lt;&lt; N;
			N = i;
			//cubeNeedNumber[N]++;
			break;
		}
	}
	
	if (st &lt;= pow(2,N))
	{
		st = pow(2, N);
	}

	// 박스의 Z길이보다 작거나 같은 2^N 의 N / 박스의 Z 길이 
	BoxX -= pow(2, N);
	CubeCheckZ(N , BoxZ, 0, st);
	cout &lt;&lt; "BoxX  :  " &lt;&lt; BoxX &lt;&lt; "\n";
	CubeCheckX(BoxX, BoxZ, st, boxY);
}





int main()
{
	Initializaion();

	for (;BoxXYZ[2] > 0;)
	{
		CubeCheckX(BoxXYZ[0], BoxXYZ[1], 0, BoxXYZ[2]);
		cout &lt;&lt; "BoxXYZ[2] : " &lt;&lt; BoxXYZ[2] &lt;&lt; "\n";
	}


	for (iter = cubeSet.begin(); iter != cubeSet.end(); iter++)
	{
		cout &lt;&lt; "cubeNeedNumber[" &lt;&lt; *iter &lt;&lt; "]  : " &lt;&lt; cubeNeedNumber[*iter] &lt;&lt; "\n";

	}
	return 0;
}</pre>



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



<h1 class="wp-block-heading"><strong>잘못된 로직과 코드 </strong>3</h1>



<p class="has-medium-font-size">작성하다 보니 내가 왜 이렇게 작성했는지 이해할 수 없다.</p>



<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;set>
#include &lt;cmath>
#include &lt;algorithm>

using namespace std;

set&lt;int, greater&lt;int>> cubeSet;
set&lt;int, greater&lt;int>> ::iterator iter;

int cubeNumber[21] = { 0 };
int cubeNeedNumber[21] = { 0 };

long long BoxXYZ[3] = { 0 };

int type, Number = 0;

void Initializaion()
{

	cin >> BoxXYZ[0] >> BoxXYZ[1] >> BoxXYZ[2];
	
	sort(BoxXYZ, BoxXYZ + (sizeof(BoxXYZ)/sizeof(BoxXYZ[0])));
	int N = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> type >> Number;
		
		cubeSet.insert(type);
		cubeNumber[type] += Number;
		N--;
	}
}

void CubeCheckZ(long long N, long long leftZ, long long divisionCount, long long MaxX, bool firstCheck)
{

	for (;leftZ >= pow(2, N);)
	{
		if (MaxX == pow(2, N) || leftZ >= pow(2, N) &amp;&amp; firstCheck)
		{ 
			if (N == 0)
			{
				cubeNeedNumber[N] += leftZ;
				leftZ = 0;
				continue;
			}
			cubeNeedNumber[N] += pow(4, divisionCount);
			cout &lt;&lt; "pow(4, divisionCount) : " &lt;&lt; pow(4, divisionCount) &lt;&lt; "  divisionCount  :  " &lt;&lt; divisionCount &lt;&lt; "  N :   "&lt;&lt; N &lt;&lt; "\n";
			leftZ -= pow(2, N);
			continue;
		}

		if (leftZ >= pow(2, N) &amp;&amp; !firstCheck)
		{
			if (N == 0)
			{
				cubeNeedNumber[N] += leftZ * MaxX / pow(2, N);
				leftZ = 0;
				continue;
			}
			cubeNeedNumber[N] += MaxX / pow(2, N);
			cout &lt;&lt; "MaxX / pow(2, N) :  " &lt;&lt; MaxX / pow(2, N) &lt;&lt; "  " &lt;&lt; MaxX &lt;&lt; "  /  " &lt;&lt; pow(2, N) &lt;&lt; "\n";
			leftZ -= pow(2, N);

		}
	}

	if (leftZ == 0)
	{
		cout &lt;&lt; "leftZ :  " &lt;&lt; leftZ &lt;&lt; "\n";
		return;
	}


	while(leftZ &lt; pow(2, N))
	{
		N--;
		divisionCount++;
	}
	CubeCheckZ(N, leftZ, divisionCount, MaxX, firstCheck);
}

void CubeCheckX(long long BoxX, long long BoxZ, long long MaxX, long long boxY, bool firstCheck)
{
	if (BoxX == 0)
	{   
		BoxXYZ[2] -= MaxX;
		return;
	}

	int N = 0;
	for (int i = 0; i &lt;= 20; i++)
	{
		if (BoxX &lt; pow(2, i) || (BoxXYZ[2] &lt; pow(2, i)))
		{
			N = i - 1;
			BoxX -= pow(2, N);
			break;
		}
		else if (BoxX == pow(2, i) || (BoxXYZ[2] == pow(2, i)))
		{
			N = i;
			BoxX -= pow(2, N);
			break;
		}
	}
	
	if (MaxX &lt; pow(2,N))
	{
		MaxX = pow(2, N);
	}
	
	CubeCheckZ(N , BoxZ, 0, MaxX, firstCheck);
	firstCheck = false;
	CubeCheckX(BoxX , BoxZ, MaxX, boxY, firstCheck);
}

int main()
{
	Initializaion();
	
	while (BoxXYZ[2] != 0)
	{
		CubeCheckX(BoxXYZ[0], BoxXYZ[1], 0, BoxXYZ[2], true);
		cout &lt;&lt; BoxXYZ[2] &lt;&lt; " \n";
	}

	for (iter = cubeSet.begin(); iter != cubeSet.end(); iter++)
	{
		cout &lt;&lt; "cubeNeedNumber[" &lt;&lt; *iter &lt;&lt; "]  : " &lt;&lt; cubeNeedNumber[*iter] &lt;&lt; "\n";
	}

	return 0;
}</pre>



<div style="height:102px" 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)"/>



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="1007" height="1146" src="https://lycos7560.com/wp-content/uploads/image-94.png" alt="" class="wp-image-2329" srcset="https://lycos7560.com/wp-content/uploads/image-94.png 1007w, https://lycos7560.com/wp-content/uploads/image-94-264x300.png 264w, https://lycos7560.com/wp-content/uploads/image-94-768x874.png 768w" sizes="(max-width: 1007px) 100vw, 1007px" /></figure>



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



<p class="has-medium-font-size">위와 같이 분할 된 박스를 다시 분할 X, Y, Z 가 0일 때까지</p>



<p class="has-medium-font-size">상자의 개수 조건에 부합하지 않으면 체크하고 -1 출력</p>



<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;map>
#include &lt;cmath>

using namespace std;

//cubeMultimap 은 내림차순으로 정렬된다. 
multimap&lt;int, int, greater&lt;int>> cubeMultimap;
//cubeMultimap 순회를 위한 반복자
multimap&lt;int, int, greater&lt;int>>::iterator iter;


int length, width, height;
int numberOfCubes, cnt = 0;
int tempOne, tempTwo;
bool failCheck = false;

// 조건을 초기화 해주는 함수
void Initializaion()
{
	cin >> length >> width >> height >> numberOfCubes;
	while (numberOfCubes > 0)
	{
		cin >> tempOne >> tempTwo;
		cubeMultimap.insert(make_pair(pow(2, tempOne), tempTwo));
		numberOfCubes--;
	}
}

// 분할 정복을 위한 함수 (X, Y, Z, 반복자)
void divisionConquest(int length, int width, int height, multimap&lt;int, int, greater&lt;int>>::iterator iter)
{
	// 만약 X, Y, Z 중에서 0이 되는 값이 있다면 리턴
	if (length == 0 || width == 0 || height == 0) return;

    // 분할정복 로직부분
	for (;iter != cubeMultimap.end(); iter++)
	{
		if (iter->second != 0 &amp;&amp; length >= iter->first &amp;&amp; width >= iter->first &amp;&amp; height >= iter->first)
		{
			iter->second--;
			cnt++;
			divisionConquest(iter->first, iter->first, width - (iter->first), iter);
			divisionConquest(length - iter->first, height, width, iter);
			divisionConquest(height - iter->first, width, iter->first, iter);
			return;
		}
	}

	// 만약 큐브의 조건이 만족하지 않는다면 실패 마킹
	failCheck = true;
	return;
}


int main()
{

	Initializaion();

	// cubeMultimap의 가장 높은 값부터 시작
	iter = cubeMultimap.begin();
	divisionConquest(length, width, height, iter);

	// 실패 마킹이 true 면 항상 -1 출력
	if (failCheck) cout &lt;&lt; -1;
	else cout &lt;&lt; cnt; // 아니면 큐브의 개수를 출력한다.

	return 0;
}</pre>



<div style="height:81px" 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/image-95.png" alt="" class="wp-image-2330" width="1450" height="121" srcset="https://lycos7560.com/wp-content/uploads/image-95.png 1189w, https://lycos7560.com/wp-content/uploads/image-95-300x25.png 300w, https://lycos7560.com/wp-content/uploads/image-95-768x64.png 768w" sizes="(max-width: 1450px) 100vw, 1450px" /></figure>



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



<p class="has-medium-font-size">분할 정복의 개념과 구현 방법은 몰라서 오래 고민한 문제</p>



<p class="has-medium-font-size">재귀 구현 어려웠다.</p>



<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; 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:28px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-1493%eb%b2%88-%eb%b0%95%ec%8a%a4-%ec%b1%84%ec%9a%b0%ea%b8%b0-c-%eb%b6%84%ed%95%a0-%ec%a0%95%eb%b3%b5/611/">백준 1493번 (박스 채우기, C++, 분할 정복) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-1493%eb%b2%88-%eb%b0%95%ec%8a%a4-%ec%b1%84%ec%9a%b0%ea%b8%b0-c-%eb%b6%84%ed%95%a0-%ec%a0%95%eb%b3%b5/611/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 11000번 (강의실 배정, C++, Greedy) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon-11000%eb%b2%88-%ea%b0%95%ec%9d%98%ec%8b%a4-%eb%b0%b0%ec%a0%95-c-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/546/</link>
					<comments>https://lycos7560.com/cpp/baekjoon-11000%eb%b2%88-%ea%b0%95%ec%9d%98%ec%8b%a4-%eb%b0%b0%ec%a0%95-c-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/546/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 12:50:15 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[11000번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Greedy]]></category>
		<category><![CDATA[강의실 배정]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 11000]]></category>
		<category><![CDATA[백준 11000번]]></category>
		<category><![CDATA[시간 초과]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[예제]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[틀렸습니다]]></category>
		<guid isPermaLink="false">https://lycos7560.synology.me/?p=546</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 11000번 '강의실 배정' 문제에 대한 글입니다. 'Greedy' 알고리즘을 이용하여 해결하였습니다. (This is an article about the 'classroom assignment' problem in BAEKJOON No. 11000. We solved it using the 'Greedy' algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-11000%eb%b2%88-%ea%b0%95%ec%9d%98%ec%8b%a4-%eb%b0%b0%ec%a0%95-c-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/546/">백준 11000번 (강의실 배정, C++, Greedy) / 추가 반례 [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>



<h1 class="wp-block-heading"><strong>강의실 배정</strong></h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/11000" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/11000</a> </p>



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



<figure id="problem-info" class="wp-block-table is-style-stripes"><table class="has-ast-global-color-8-color has-ast-global-color-6-background-color has-text-color has-background 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">25367</td><td class="has-text-align-left" data-align="left">7462</td><td class="has-text-align-left" data-align="left">5481</td><td class="has-text-align-left" data-align="left">28.998%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size">수강 신청의 마스터 김종혜 선생님에게 새로운 과제가 주어졌다.&nbsp;<br> 김종혜 선생님한테는 S<sub>i</sub>에 시작해서 T<sub>i</sub>에 끝나는 N개의 수업이 주어지는데, <br>최소의 강의실을 사용해서 모든 수업을 가능하게 해야 한다.&nbsp; <br>참고로, 수업이 끝난 직후에 다음 수업을 시작할 수 있다. <br>(즉, T<sub>i</sub>&nbsp;≤ S<sub>j</sub>&nbsp;일 경우 i 수업과 j 수업은 같이 들을 수 있다.)<br>수강 신청 대충 한 게 찔리면, 선생님을 도와드리자!  </p>



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



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



<p class="has-medium-font-size">첫 번째 줄에 N이 주어진다. (1 ≤ N ≤ 200,000)<br>이후 N개의 줄에 S<sub>i</sub>, T<sub>i</sub>가 주어진다. (0 ≤ S<sub>i</sub>&nbsp;&lt; T<sub>i</sub>&nbsp;≤&nbsp;10<sup>9</sup>) </p>



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



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



<p class="has-medium-font-size">강의실의 개수를 출력하라.</p>



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



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



<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
1 3
2 4
3 5
</pre>



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



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



<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:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="has-medium-font-size wp-block-heading">출처</h2>



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



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



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



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



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/33" target="_blank" rel="noreferrer noopener">그리디 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/59" target="_blank" rel="noreferrer noopener">우선순위 큐</a></li>
</ul>



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



<hr class="wp-block-separator has-css-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"><strong>추가 반례</strong></h2>



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



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



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



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



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



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



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



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



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
999999999 1000000000
999999998 999999999 
1 999999998</pre>



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



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



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



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 C</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
999999999 1000000000
999999998 999999999 
1 999999998</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 C</h2>



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



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 D</h2>



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



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 D</h2>



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



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



<h2 class="has-medium-font-size wp-block-heading">예제 입력 E</h2>



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



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 E</h2>



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



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



<p class="has-medium-font-size">Si ~ Ti에 끝나는 N개의 수업<br><br>최소의 강의실을 사용하여 모든 수업을 한다<br><br>수업이 끝난 직후에 다음 수업을 시작할 수 있다.<br><br>즉 Ti &lt;= Sj 일 경우 i 수업과 j수업을 같이 들을 수 있다.<br><br>1 ≤ N ≤ 200,000<br><br>0 ≤ Si &lt; Ti ≤ 109</p>



<p class="has-medium-font-size">무슨 소리야?</p>



<p class="has-medium-font-size">항상 문제를 이해하는 것이 가장 어렵다</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="659" height="192" src="https://lycos7560.com/wp-content/uploads/image-52.png" alt="" class="wp-image-2262" srcset="https://lycos7560.com/wp-content/uploads/image-52.png 659w, https://lycos7560.com/wp-content/uploads/image-52-300x87.png 300w" sizes="(max-width: 659px) 100vw, 659px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="911" height="257" src="https://lycos7560.com/wp-content/uploads/image-53.png" alt="" class="wp-image-2263" srcset="https://lycos7560.com/wp-content/uploads/image-53.png 911w, https://lycos7560.com/wp-content/uploads/image-53-300x85.png 300w, https://lycos7560.com/wp-content/uploads/image-53-768x217.png 768w" sizes="(max-width: 911px) 100vw, 911px" /></figure>



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



<p class="has-medium-font-size">멀티맵의<br>key 값을 시작 값<br>value값을 끝나는 값으로 설정하면서<br>해당 value 값과 다른 key 값이 같으면 해당 맵을 지우고 value를 바꾸어주면 어떨까?</p>



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



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

using namespace std;

multimap&lt;int, int> curriculum;

void Initialization()
{
	int N = 0;
	int S = 0;
	int T = 0;
	cin >> N;

	while (N > 0)
	{
		cin >> S >> T;
		curriculum.insert({ S,T });
		N--;
	}
}

int main()
{
    // 초기화
	Initialization();
    
    // 멀티맵 출력 
	for (auto&amp; elem : curriculum)
	{
		cout &lt;&lt; " S : " &lt;&lt; elem.first &lt;&lt; " T : " &lt;&lt; elem.second &lt;&lt; "\n";
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="668" height="133" src="https://lycos7560.com/wp-content/uploads/image-54.png" alt="" class="wp-image-2264" srcset="https://lycos7560.com/wp-content/uploads/image-54.png 668w, https://lycos7560.com/wp-content/uploads/image-54-300x60.png 300w" sizes="(max-width: 668px) 100vw, 668px" /></figure>



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



<h2 class="wp-block-heading"><strong>틀린 코드 1</strong></h2>



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



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

using namespace std;

multimap&lt;int, int> curriculumMultiMap;
multimap&lt;int, int>::iterator it;

int result = 0;

void Initialization()
{
	int N = 0;
	int S = 0;
	int T = 0;
	cin >> N;
	result = N;
	while (N > 0)
	{
		cin >> S >> T;
		curriculumMultiMap.insert({ S,T });
		N--;
	}
}

int main()
{
	Initialization();
	
	// key 값이 낮은 값부터 시작
	for (auto&amp; elem : curriculumMultiMap)
	{
		//cout &lt;&lt; " S : " &lt;&lt; elem.first &lt;&lt; " T : " &lt;&lt; elem.second &lt;&lt; "\n";
		for (it = curriculumMultiMap.lower_bound(elem.second);it != curriculumMultiMap.end(); it++)
		{
			elem.second = it->second;
			cout &lt;&lt; elem.second;
			result--;
			curriculumMultiMap.erase(it->first);
		}
	}
	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"><img decoding="async" width="766" height="288" src="https://lycos7560.com/wp-content/uploads/image-55.png" alt="" class="wp-image-2265" srcset="https://lycos7560.com/wp-content/uploads/image-55.png 766w, https://lycos7560.com/wp-content/uploads/image-55-300x113.png 300w" sizes="(max-width: 766px) 100vw, 766px" /></figure>



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



<p class="has-medium-font-size"><a href="https://wordbe.tistory.com/entry/STL-erase" target="_blank" rel="noreferrer noopener">wordbe.tistory.com/entry/STL-erase</a>  &lt;- 참고글</p>



<p class="has-medium-font-size">연관 컨테이너의 경우(Associate container)<br>: set, map, multiset, multimap의 경우.<br>컨테이너의 어떤 요소가 erase 될 때, 이 요소를 가리키고 있는 모든 반복자들이 무효화됩니다.<br>c.erase(i)가 복귀하자마자 i는 바로 무효화됩니다.<br>따라서 루프에 있는 ++i는 무효화되어 에러가 납니다.<br>이를 해결하기 위해서는,<br>erase를 호출하기 전에 반복자 i가 c의 다음 요소를 가리키도록 세팅하면 됩니다.</p>



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



<h2 class="wp-block-heading"><strong>틀린 코드 2</strong></h2>



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



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

using namespace std;

multimap&lt;int, int> curriculumMultiMap;
int result = 0;

void Initialization()
{
	int N = 0;
	int S = 0;
	int T = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> S >> T;
		curriculumMultiMap.insert({ S,T });
		N--;
	}
}

int main()
{
	Initialization();

	for (auto&amp; elem : curriculumMultiMap)
	{
		cout &lt;&lt; "elem.first" &lt;&lt; elem.first &lt;&lt; "\n";
		for (auto it = curriculumMultiMap.lower_bound(elem.second);it != curriculumMultiMap.end();)
		{
			if (elem.second &lt;= it->first)
			{
				cout &lt;&lt; "elem.first : " &lt;&lt; elem.first &lt;&lt; " elem.second : " &lt;&lt; elem.second &lt;&lt; " it->first : " &lt;&lt; it->first &lt;&lt; " it->second : " &lt;&lt; it->second &lt;&lt; "\n";
				elem.second = it->second;
				curriculumMultiMap.erase(it++);
			}
			else
			{
				it++;
			}
		}
		result++;
	}



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



<div style="height:86px" 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>



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



<p class="has-medium-font-size">multimap으로 풀었지만 시간 초과 벗어날 수 없어서 포기….<br>insert<br>erase<br>의 속도가 느리다…</p>



<p class="has-medium-font-size">시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간초과시간</p>



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



<h2 class="wp-block-heading"><strong>틀린 코드 3</strong></h2>



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



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

using namespace std;

priority_queue &lt; pair&lt;int, int>, vector&lt;pair&lt;int, int>>, greater&lt;pair&lt;int, int>>> myQueue;

int result = 1;
pair&lt;int, int> mypair;
multiset&lt;int> mymultiset;

void Initialization()
{
	int N = 0;
	int S = 0;
	int T = 0;
	
	cin >> N;
	while (N > 0)
	{
		cin >> S >> T;
		myQueue.push(make_pair(S, T));
		N--;
	}
}

int main()
{
	Initialization();
	mypair = myQueue.top();
	myQueue.pop();
	mymultiset.insert(mypair.second);

	while (!myQueue.empty())
	{
		mypair = myQueue.top();
		myQueue.pop();
		for (auto iter = mymultiset.begin();iter != mymultiset.end();iter++)
		{
			if (mypair.first &lt; *iter)
			{
				mymultiset.insert(mypair.second);
				result++;
				break;
			}
			
			if (mypair.first >= *iter)
			{
				mymultiset.erase(*iter);
				mymultiset.insert(mypair.second);
				break;
			}
		}
	}
	
	cout &lt;&lt; result;
	return 0;
}</pre>



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



<p class="has-medium-font-size">우선 수업들을 Priority_Queue에 넣고 강의의 시작 시간을 기준으로 오름차순 정렬해준다.&nbsp;<br> (내 풀이에서는 7 8 / 7 11의 순서는 의미가 없다.) </p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="669" height="194" src="https://lycos7560.com/wp-content/uploads/image-56.png" alt="" class="wp-image-2266" srcset="https://lycos7560.com/wp-content/uploads/image-56.png 669w, https://lycos7560.com/wp-content/uploads/image-56-300x87.png 300w" sizes="(max-width: 669px) 100vw, 669px" /></figure>



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



<p class="has-medium-font-size">처음에는 무조건 Priority_Queue에서 하나의 pair 값을 꺼내고 Multiset에 강의가 끝나는 시간을 넣어준다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="879" height="195" src="https://lycos7560.com/wp-content/uploads/image-57.png" alt="" class="wp-image-2267" srcset="https://lycos7560.com/wp-content/uploads/image-57.png 879w, https://lycos7560.com/wp-content/uploads/image-57-300x67.png 300w, https://lycos7560.com/wp-content/uploads/image-57-768x170.png 768w" sizes="(max-width: 879px) 100vw, 879px" /></figure>



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



<p class="has-medium-font-size">그 다음 Priority_Queue에서 하나의 pair 값을 꺼내고<br>강의 시작 시간(first)과 Multiset에서 가장 작은 수와 비교한다.<br>만약 강의의 시작 시간이 Multiset의 가장 낮은 수와 비교하여 작을 경우 강의실에 끝나는 시간을 추가해준다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="804" height="203" src="https://lycos7560.com/wp-content/uploads/image-58.png" alt="" class="wp-image-2268" srcset="https://lycos7560.com/wp-content/uploads/image-58.png 804w, https://lycos7560.com/wp-content/uploads/image-58-300x76.png 300w, https://lycos7560.com/wp-content/uploads/image-58-768x194.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



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



<p class="has-medium-font-size">그 다음 Priority_Queue 에서 하나의 pair 값을 꺼내고<br>강의 시작 시간(first)과 Multiset에서 가장 작은 수와 비교한다.<br>만약 강의의 시작 시간이 Multiset의 가장 낮은 수와 비교하여 크다면<br>Multiset에서 강의 시작 시간(first) 보다 작거나 같은 수 중에서 제일 높은 숫자를 Multiset에서 지우고<br>-&gt; 강의가 끝나고 같은 강의실에서 다음 수업을 진행한다는 의미<br>강의가 끝나는 시간을 Multiset에 추가한다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="846" height="217" src="https://lycos7560.com/wp-content/uploads/image-59.png" alt="" class="wp-image-2269" srcset="https://lycos7560.com/wp-content/uploads/image-59.png 846w, https://lycos7560.com/wp-content/uploads/image-59-300x77.png 300w, https://lycos7560.com/wp-content/uploads/image-59-768x197.png 768w" sizes="(max-width: 846px) 100vw, 846px" /></figure>



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



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



<p class="has-medium-font-size">해당 과정을&nbsp; Queue가 비어있을 때까지 진행한다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="902" height="204" src="https://lycos7560.com/wp-content/uploads/image-60.png" alt="" class="wp-image-2270" srcset="https://lycos7560.com/wp-content/uploads/image-60.png 902w, https://lycos7560.com/wp-content/uploads/image-60-300x68.png 300w, https://lycos7560.com/wp-content/uploads/image-60-768x174.png 768w" sizes="(max-width: 902px) 100vw, 902px" /></figure>



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="670" height="209" src="https://lycos7560.com/wp-content/uploads/image-61.png" alt="" class="wp-image-2271" srcset="https://lycos7560.com/wp-content/uploads/image-61.png 670w, https://lycos7560.com/wp-content/uploads/image-61-300x94.png 300w" sizes="(max-width: 670px) 100vw, 670px" /></figure>



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="773" height="192" src="https://lycos7560.com/wp-content/uploads/image-62.png" alt="" class="wp-image-2272" srcset="https://lycos7560.com/wp-content/uploads/image-62.png 773w, https://lycos7560.com/wp-content/uploads/image-62-300x75.png 300w, https://lycos7560.com/wp-content/uploads/image-62-768x191.png 768w" sizes="(max-width: 773px) 100vw, 773px" /></figure>



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



<figure class="wp-block-image size-full"><img decoding="async" width="817" height="148" src="https://lycos7560.com/wp-content/uploads/image-63.png" alt="" class="wp-image-2273" srcset="https://lycos7560.com/wp-content/uploads/image-63.png 817w, https://lycos7560.com/wp-content/uploads/image-63-300x54.png 300w, https://lycos7560.com/wp-content/uploads/image-63-768x139.png 768w" sizes="(max-width: 817px) 100vw, 817px" /></figure>



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



<p class="has-medium-font-size">알고리즘을 생각하는 시간보다 iterator 사용법을 익히는 시간이 더 들었다.</p>



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



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



<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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;set>
#include &lt;queue>

using namespace std;

//우선 순위 Q를 사용하여 입력값을 정렬해준다.
priority_queue &lt; pair&lt;int, int>, vector&lt;pair&lt;int, int>>, greater&lt;pair&lt;int, int>>> myQueue;

int result = 1;

// 강의들을 저장해 놓음
pair&lt;int, int> mypair;

// 멀티맵을 사용하기 위한 준비
multiset&lt;int> mymultiset;
multiset&lt;int>::iterator iter;

// 입력값 초기화 함수
void Initialization()
{
	int N = 0;
	int S = 0;
	int T = 0;
	cin >> N;
	while (N > 0)
	{
		cin >> S >> T;
		myQueue.push(make_pair(S, T));
		N--;
	}
}

int main()
{
	// 입력값을 받아줍니다.
	Initialization();
	mypair = myQueue.top();
	myQueue.pop();
	mymultiset.insert(mypair.second);

	while (!myQueue.empty())
	{
		mypair = myQueue.top();
		myQueue.pop();
	 
		if (mypair.first &lt; *mymultiset.begin())
		{
			mymultiset.insert(mypair.second);
			result++;
			continue;
		}

		iter = mymultiset.lower_bound(mypair.first);

		// 값이 같을 때도 같이 set에서 제거하고 페어를 추가해준다.
		if (*iter == mypair.first)
		{
			mymultiset.erase(iter);
		}
		else
		{
			mymultiset.erase(--iter);
		}
		
		mymultiset.insert(mypair.second);
	}
    
	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/image-64.png" alt="" class="wp-image-2274" width="1076" height="801" srcset="https://lycos7560.com/wp-content/uploads/image-64.png 834w, https://lycos7560.com/wp-content/uploads/image-64-300x223.png 300w, https://lycos7560.com/wp-content/uploads/image-64-768x572.png 768w" sizes="(max-width: 1076px) 100vw, 1076px" /></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; 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>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-11000%eb%b2%88-%ea%b0%95%ec%9d%98%ec%8b%a4-%eb%b0%b0%ec%a0%95-c-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/546/">백준 11000번 (강의실 배정, C++, Greedy) / 추가 반례 [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon-11000%eb%b2%88-%ea%b0%95%ec%9d%98%ec%8b%a4-%eb%b0%b0%ec%a0%95-c-greedy-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80/546/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
