<?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>SET Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/set/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Mon, 08 May 2023 16:24:20 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>SET Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>백준 15666번 (N과 M (12), C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15666%eb%b2%88-n%ea%b3%bc-m-12-c-baekjoon/34467/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15666%eb%b2%88-n%ea%b3%bc-m-12-c-baekjoon/34467/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 08 May 2023 10:19:23 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[15666]]></category>
		<category><![CDATA[15666번]]></category>
		<category><![CDATA[Backtracking]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[N과 M (12)]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 15666]]></category>
		<category><![CDATA[백준 15666번]]></category>
		<category><![CDATA[백트레킹]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=34467</guid>

					<description><![CDATA[<p>백준 15666번 'N과 M (12)' 문제에 대한 글입니다. (This is an article on the question "N and M (12)" of Baekjoon  Number 15666.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15666%eb%b2%88-n%ea%b3%bc-m-12-c-baekjoon/34467/">백준 15666번 (N과 M (12), 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-d69170fb      "
					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="#n과-m-12" class="uagb-toc-link__trigger">N과 M (12)</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">N과 M (12)</h1>



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



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



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



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



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



<p class="has-medium-font-size wp-block-paragraph">N개의 자연수와 자연수 M이 주어졌을 때, </p>



<p class="has-medium-font-size wp-block-paragraph">아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.</p>



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



<p class="wp-block-paragraph">N개의 자연수 중에서 M개를 고른 수열</p>



<p class="wp-block-paragraph">같은 수를 여러 번 골라도 된다.</p>



<p class="wp-block-paragraph">고른 수열은 비내림차순이어야 한다.</p>



<p class="wp-block-paragraph"> => 길이가 K인 수열 A가 A<sub>1</sub> ≤ A<sub>2</sub> ≤ &#8230; ≤ A<sub>K-1</sub> ≤ A<sub>K</sub>를 만족하면, 비내림차순이라고 한다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8)</p>



<p class="has-medium-font-size wp-block-paragraph">둘째 줄에 N개의 수가 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. </p>



<p class="has-medium-font-size wp-block-paragraph">중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.</p>



<p class="has-medium-font-size wp-block-paragraph">수열은 사전 순으로 증가하는 순서로 출력해야 한다.</p>



<div style="height:62px" 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="">3 1
4 4 2</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="">2
4</pre>



<div style="height:50px" 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 2
9 7 9 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 1
1 7
1 9
7 7
7 9
9 9</pre>



<div style="height:50px" 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 4
1 1 2 2</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="">1 1 1 1
1 1 1 2
1 1 2 2
1 2 2 2
2 2 2 2</pre>



<div style="height:50px" 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/chogahui05" target="_blank" rel="noreferrer noopener">chogahui05</a>, <a href="https://www.acmicpc.net/user/thak00" target="_blank" rel="noreferrer noopener">thak00</a></li>
</ul>



<div style="height:50px" 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/5" target="_blank" rel="noreferrer noopener">백트래킹</a></li>
</ul>



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



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



<p class="has-medium-font-size wp-block-paragraph">자료구조 set을 이용하여 숫자의 중복을 제거 및 정렬</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;set>

using namespace std;

int _N, _M, _Temp, _Arr[8], _Num[8];

void RecursiveFunction(int _X, int _Len) 
{
    if (_Len == _M) {
        for (int i = 0; i &lt; _M; i++)
            cout &lt;&lt; _Arr[i] &lt;&lt; " ";
        cout &lt;&lt; "\n";
        return;
    }

    for (int i = _X; i &lt; _N; i++) {
        _Arr[_Len] = _Num[i];
        RecursiveFunction(i, _Len + 1);
    }
    return;
}

int main()
{
    set&lt;int> _MySet;
    cin >> _N >> _M;
    for (int i = 0; i &lt; _N; i++) {
        cin >> _Temp;
        _MySet.insert(_Temp);
    }

    int _Cnt = 0;

    for (auto&amp; iter : _MySet) 
        _Num[_Cnt++] = iter;
    
    _N = _MySet.size();
    RecursiveFunction(0, 0);
    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 fetchpriority="high" decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/05/image-10.png" alt="" class="wp-image-34469" width="969" height="96" srcset="https://lycos7560.com/wp-content/uploads/2023/05/image-10.png 829w, https://lycos7560.com/wp-content/uploads/2023/05/image-10-300x30.png 300w, https://lycos7560.com/wp-content/uploads/2023/05/image-10-768x76.png 768w" sizes="(max-width: 969px) 100vw, 969px" /></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-15666%eb%b2%88-n%ea%b3%bc-m-12-c-baekjoon/34467/">백준 15666번 (N과 M (12), 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-15666%eb%b2%88-n%ea%b3%bc-m-12-c-baekjoon/34467/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 15663번 (N과 M (9), C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15663%eb%b2%88-n%ea%b3%bc-m-9-c-baekjoon/34472/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15663%eb%b2%88-n%ea%b3%bc-m-9-c-baekjoon/34472/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 16 Apr 2023 15:48:19 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[15663]]></category>
		<category><![CDATA[15663번]]></category>
		<category><![CDATA[Backtracking]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[N과 M (9)]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 15663]]></category>
		<category><![CDATA[백준 15663번]]></category>
		<category><![CDATA[백트레킹]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=34472</guid>

					<description><![CDATA[<p>백준 15663번 'N과 M (9)' 문제에 대한 글입니다. (This is an article on the question of BAEKJOON Number 15663 'N and M (9)')</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-15663%eb%b2%88-n%ea%b3%bc-m-9-c-baekjoon/34472/">백준 15663번 (N과 M (9), 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-b0f74a2d      "
					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="#n과-m-9" class="uagb-toc-link__trigger">N과 M (9)</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">N과 M (9)</h1>



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



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



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">512 MB</td><td class="has-text-align-left" data-align="left">29219</td><td class="has-text-align-left" data-align="left">14418</td><td class="has-text-align-left" data-align="left">10819</td><td class="has-text-align-left" data-align="left">49.001%</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 wp-block-paragraph">N개의 자연수와 자연수 M이 주어졌을 때, </p>



<p class="has-medium-font-size wp-block-paragraph">아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.</p>



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



<p class="wp-block-paragraph">N개의 자연수 중에서 M개를 고른 수열</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 wp-block-paragraph">첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8)</p>



<p class="has-medium-font-size wp-block-paragraph">둘째 줄에 N개의 수가 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">입력으로 주어지는 수는 10,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 wp-block-paragraph">한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. </p>



<p class="has-medium-font-size wp-block-paragraph">중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.</p>



<p class="has-medium-font-size wp-block-paragraph">수열은 사전 순으로 증가하는 순서로 출력해야 한다.</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="">3 1
4 4 2</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="">2
4</pre>



<div style="height:50px" 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 2
9 7 9 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 7
1 9
7 1
7 9
9 1
9 7
9 9</pre>



<div style="height:50px" 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 4
1 1 1 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="">1 1 1 1</pre>



<div style="height:50px" 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/kid7ho" target="_blank" rel="noreferrer noopener">kid7ho</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/5">백트</a><a href="https://www.acmicpc.net/problem/tag/5" target="_blank" rel="noreferrer noopener">래</a><a href="https://www.acmicpc.net/problem/tag/5">킹</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)"/>



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



<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/05/KakaoTalk_20230509_012310585.jpg" alt="" class="wp-image-34479" width="1358" height="1409" srcset="https://lycos7560.com/wp-content/uploads/2023/05/KakaoTalk_20230509_012310585.jpg 1600w, https://lycos7560.com/wp-content/uploads/2023/05/KakaoTalk_20230509_012310585-289x300.jpg 289w, https://lycos7560.com/wp-content/uploads/2023/05/KakaoTalk_20230509_012310585-768x797.jpg 768w, https://lycos7560.com/wp-content/uploads/2023/05/KakaoTalk_20230509_012310585-1480x1536.jpg 1480w" sizes="(max-width: 1358px) 100vw, 1358px" /></figure>



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

using namespace std;

int _N, _M, _Arr[8], _Num[8];
bool _NumBool[8]; // 중복을 확인

void RecursiveFunction(int _Len) 
{
    if (_Len == _M) {
        for (int i = 0; i &lt; _M; i++)
            cout &lt;&lt; _Arr[i] &lt;&lt; " ";
        cout &lt;&lt; "\n";
        return;
    }

    int _Temp = 0;
    for (int i = 0; i &lt; _N; i++) {
        if (!_NumBool[i] &amp;&amp; _Num[i] != _Temp) {
            _Arr[_Len] = _Num[i];
            _Temp = _Arr[_Len];
            _NumBool[i] = true;
            RecursiveFunction(_Len + 1);
            _NumBool[i] = false;    
        }
    }
    return;
}

int main()
{
    cin >> _N >> _M;
    for (int i = 0; i &lt; _N; i++) 
        cin >> _Num[i];
    sort(_Num, _Num + _N);
    RecursiveFunction(0);
    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/05/image-11.png" alt="" class="wp-image-34474" width="943" height="173" srcset="https://lycos7560.com/wp-content/uploads/2023/05/image-11.png 828w, https://lycos7560.com/wp-content/uploads/2023/05/image-11-300x55.png 300w, https://lycos7560.com/wp-content/uploads/2023/05/image-11-768x141.png 768w" sizes="(max-width: 943px) 100vw, 943px" /></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-15663%eb%b2%88-n%ea%b3%bc-m-9-c-baekjoon/34472/">백준 15663번 (N과 M (9), 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-15663%eb%b2%88-n%ea%b3%bc-m-9-c-baekjoon/34472/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Programmers 17677 [1차] 뉴스 클러스터링 [2018 KAKAO BLIND RECRUITMENT]</title>
		<link>https://lycos7560.com/cpp/programmers/programmers-17677-1%ec%b0%a8-%eb%89%b4%ec%8a%a4-%ed%81%b4%eb%9f%ac%ec%8a%a4%ed%84%b0%eb%a7%81-2018-kakao-blind-recruitment/33753/</link>
					<comments>https://lycos7560.com/cpp/programmers/programmers-17677-1%ec%b0%a8-%eb%89%b4%ec%8a%a4-%ed%81%b4%eb%9f%ac%ec%8a%a4%ed%84%b0%eb%a7%81-2018-kakao-blind-recruitment/33753/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 05 Mar 2023 14:57:12 +0000</pubDate>
				<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[[1차] 뉴스 클러스터링]]></category>
		<category><![CDATA[17677]]></category>
		<category><![CDATA[17677번]]></category>
		<category><![CDATA[2018 KAKAO BLIND RECRUITMENT]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[multimap]]></category>
		<category><![CDATA[Multiset]]></category>
		<category><![CDATA[programmers 17677]]></category>
		<category><![CDATA[programmers 17677번]]></category>
		<category><![CDATA[SET]]></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>
		<guid isPermaLink="false">https://lycos7560.com/?p=33753</guid>

					<description><![CDATA[<p>programmers 17677 '[1차] 뉴스 클러스터링' 문제에 대한 글입니다. 집합에 대한 문제 입니다. [2018 KAKAO BLIND RECRUITMENT] (This article is about programmers 17677 '[primary] news clustering' problem. This is a problem with the set. [2018 KAKAO BLIND RECRUITMENT])</p>
<p>The post <a href="https://lycos7560.com/cpp/programmers/programmers-17677-1%ec%b0%a8-%eb%89%b4%ec%8a%a4-%ed%81%b4%eb%9f%ac%ec%8a%a4%ed%84%b0%eb%a7%81-2018-kakao-blind-recruitment/33753/">Programmers 17677 [1차] 뉴스 클러스터링 [2018 KAKAO BLIND RECRUITMENT]</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-711369de      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#뉴스-클러스터링" class="uagb-toc-link__trigger">뉴스 클러스터링</a><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ol>					</div>
									</div>
				</div>
			


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



<h1 class="wp-block-heading">뉴스 클러스터링</h1>



<p class="has-medium-font-size wp-block-paragraph"><a href="https://school.programmers.co.kr/learn/courses/30/lessons/17677" target="_blank" rel="noreferrer noopener">https://school.programmers.co.kr/learn/courses/30/lessons/17677</a></p>



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



<p class="has-medium-font-size wp-block-paragraph">여러 언론사에서 쏟아지는 뉴스, 특히 속보성 뉴스를 보면 비슷비슷한 제목의 기사가 많아 정작 필요한 기사를 찾기가 어렵다. </p>



<p class="has-medium-font-size wp-block-paragraph">Daum 뉴스의 개발 업무를 맡게 된 신입사원 튜브는 사용자들이 편리하게 다양한 뉴스를 찾아볼 수 있도록 문제점을 개선하는 업무를 맡게 되었다.</p>



<p class="has-medium-font-size wp-block-paragraph">개발의 방향을 잡기 위해 튜브는 우선 최근 화제가 되고 있는 &#8220;카카오 신입 개발자 공채&#8221; 관련 기사를 검색해보았다.</p>



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



<p class="has-medium-font-size wp-block-paragraph">카카오 첫 공채..&#8217;블라인드&#8217; 방식 채용</p>



<p class="has-medium-font-size wp-block-paragraph">카카오, 합병 후 첫 공채.. 블라인드 전형으로 개발자 채용</p>



<p class="has-medium-font-size wp-block-paragraph">카카오, 블라인드 전형으로 신입 개발자 공채</p>



<p class="has-medium-font-size wp-block-paragraph">카카오 공채, 신입 개발자 코딩 능력만 본다</p>



<p class="has-medium-font-size wp-block-paragraph">카카오, 신입 공채.. &#8220;코딩 실력만 본다&#8221;</p>



<p class="has-medium-font-size wp-block-paragraph">카카오 &#8220;코딩 능력만으로 2018 신입 개발자 뽑는다&#8221;</p>



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



<p class="has-medium-font-size wp-block-paragraph">기사의 제목을 기준으로 &#8220;블라인드 전형&#8221;에 주목하는 기사와 &#8220;코딩 테스트&#8221;에 주목하는 기사로 나뉘는 걸 발견했다. </p>



<p class="has-medium-font-size wp-block-paragraph">튜브는 이들을 각각 묶어서 보여주면 카카오 공채 관련 기사를 찾아보는 사용자에게 유용할 듯싶었다.</p>



<p class="has-medium-font-size wp-block-paragraph">유사한 기사를 묶는 기준을 정하기 위해서 논문과 자료를 조사하던 튜브는 &#8220;자카드 유사도&#8221;라는 방법을 찾아냈다.</p>



<p class="has-medium-font-size wp-block-paragraph">자카드 유사도는 집합 간의 유사도를 검사하는 여러 방법 중의 하나로 알려져 있다. </p>



<p class="has-medium-font-size wp-block-paragraph">두 집합&nbsp;<code>A</code>,&nbsp;<code>B</code>&nbsp;사이의 자카드 유사도&nbsp;<code>J(A, B)</code>는 두 집합의 교집합 크기를 두 집합의 합집합 크기로 나눈 값으로 정의된다.</p>



<p class="has-medium-font-size wp-block-paragraph">예를 들어 집합&nbsp;<code>A</code>&nbsp;= {1, 2, 3}, 집합&nbsp;<code>B</code>&nbsp;= {2, 3, 4}라고 할 때, 교집합&nbsp;<code>A ∩ B</code>&nbsp;= {2, 3}, 합집합&nbsp;<code>A ∪ B</code>&nbsp;= {1, 2, 3, 4}이 되므로, </p>



<p class="has-medium-font-size wp-block-paragraph">집합&nbsp;<code>A</code>,&nbsp;<code>B</code>&nbsp;사이의 자카드 유사도&nbsp;<code>J(A, B)</code>&nbsp;= 2/4 = 0.5가 된다. </p>



<p class="has-medium-font-size wp-block-paragraph">집합 A와 집합 B가 모두 공집합일 경우에는 나눗셈이 정의되지 않으니 따로&nbsp;<code>J(A, B)</code>&nbsp;= 1로 정의한다.</p>



<p class="has-medium-font-size wp-block-paragraph">자카드 유사도는 원소의 중복을 허용하는 다중집합에 대해서 확장할 수 있다. </p>



<p class="has-medium-font-size wp-block-paragraph">다중집합&nbsp;<code>A</code>는 원소 &#8220;1&#8221;을 3개 가지고 있고, 다중집합&nbsp;<code>B</code>는 원소 &#8220;1&#8221;을 5개 가지고 있다고 하자. </p>



<p class="has-medium-font-size wp-block-paragraph">이 다중집합의 교집합&nbsp;<code>A ∩ B</code>는 원소 &#8220;1&#8221;을 min(3, 5)인 3개, 합집합&nbsp;<code>A ∪ B</code>는 원소 &#8220;1&#8221;을 max(3, 5)인 5개 가지게 된다. </p>



<p class="has-medium-font-size wp-block-paragraph">다중집합&nbsp;<code>A</code>&nbsp;= {1, 1, 2, 2, 3}, 다중집합&nbsp;<code>B</code>&nbsp;= {1, 2, 2, 4, 5}라고 하면, 교집합&nbsp;<code>A ∩ B</code>&nbsp;= {1, 2, 2}, 합집합&nbsp;<code>A ∪ B</code>&nbsp;= {1, 1, 2, 2, 3, 4, 5}가 되므로, </p>



<p class="has-medium-font-size wp-block-paragraph">자카드 유사도&nbsp;<code>J(A, B)</code>&nbsp;= 3/7, 약 0.42가 된다.</p>



<p class="wp-block-paragraph">이를 이용하여 문자열 사이의 유사도를 계산하는데 이용할 수 있다. </p>



<p class="wp-block-paragraph">문자열 &#8220;FRANCE&#8221;와 &#8220;FRENCH&#8221;가 주어졌을 때, 이를 두 글자씩 끊어서 다중집합을 만들 수 있다. </p>



<p class="wp-block-paragraph">각각 {FR, RA, AN, NC, CE}, {FR, RE, EN, NC, CH}가 되며, 교집합은 {FR, NC}, 합집합은 {FR, RA, AN, NC, CE, RE, EN, CH}가 되므로, </p>



<p class="wp-block-paragraph">두 문자열 사이의 자카드 유사도&nbsp;<code>J("FRANCE", "FRENCH")</code>&nbsp;= 2/8 = 0.25가 된다.</p>



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



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



<ul class="wp-block-list">
<li>입력으로는&nbsp;<code>str1</code>과&nbsp;<code>str2</code>의 두 문자열이 들어온다. 각 문자열의 길이는 2 이상, 1,000 이하이다.</li>



<li>입력으로 들어온 문자열은 두 글자씩 끊어서 다중집합의 원소로 만든다. 이때 영문자로 된 글자 쌍만 유효하고, <br>기타 공백이나 숫자, 특수 문자가 들어있는 경우는 그 글자 쌍을 버린다. 예를 들어 &#8220;ab+&#8221;가 입력으로 들어오면, &#8220;ab&#8221;만 다중집합의 원소로 삼고, &#8220;b+&#8221;는 버린다.</li>



<li>다중집합 원소 사이를 비교할 때, 대문자와 소문자의 차이는 무시한다. &#8220;AB&#8221;와 &#8220;Ab&#8221;, &#8220;ab&#8221;는 같은 원소로 취급한다.</li>
</ul>



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



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



<p class="has-medium-font-size wp-block-paragraph">입력으로 들어온 두 문자열의 자카드 유사도를 출력한다. </p>



<p class="has-medium-font-size wp-block-paragraph">유사도 값은 0에서 1 사이의 실수이므로, 이를 다루기 쉽도록 65536을 곱한 후에 소수점 아래를 버리고 정수부만 출력한다.</p>



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



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



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-ast-global-color-0-color">str1</mark></th><th class="has-text-align-left" data-align="left"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-ast-global-color-0-color">str2</mark></th><th class="has-text-align-left" data-align="left"><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-ast-global-color-0-color">answer</mark></th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">FRANCE</td><td class="has-text-align-left" data-align="left">french</td><td class="has-text-align-left" data-align="left">16384</td></tr><tr><td class="has-text-align-left" data-align="left">handshake</td><td class="has-text-align-left" data-align="left">shake hands</td><td class="has-text-align-left" data-align="left">65536</td></tr><tr><td class="has-text-align-left" data-align="left">aa1+aa2</td><td class="has-text-align-left" data-align="left">AAAA12</td><td class="has-text-align-left" data-align="left">43690</td></tr><tr><td class="has-text-align-left" data-align="left">E=M*C^2</td><td class="has-text-align-left" data-align="left">e=m*c^2</td><td class="has-text-align-left" data-align="left">65536</td></tr><tr><td class="has-text-align-left" data-align="left">&#8220;A+C&#8221;</td><td class="has-text-align-left" data-align="left">&#8220;DEF&#8221;</td><td class="has-text-align-left" data-align="left">0</td></tr></tbody></table></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>



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

using namespace std;

unordered_map&lt;string, int> mMap1;
unordered_map&lt;string, int> mMap2;
unordered_map&lt;string, int> uMap;

int solution(string str1, string str2) {
    int answer = 0;
    string tempstr1, tempstr2;

    // 대문자를 소문자로 변환
    for (int i = 0; i &lt; str1.length(); i++) {
        if (str1[i] >= 'A' &amp;&amp; str1[i] &lt;= 'Z') {
            str1[i] = tolower(str1[i]);
            tempstr1.push_back(str1[i]);
        }
        else if (str1[i] >= 'a' &amp;&amp; str1[i] &lt;= 'z') tempstr1.push_back(str1[i]);
        else tempstr1.push_back(' ');
    }

    for (int i = 0; i &lt; tempstr1.length() - 1; i++) {
        string temp = tempstr1.substr(i, 2);
        if (temp[0] == ' ' || temp[1] == ' ') continue;
        auto it = mMap1.find(temp);
        if (it != mMap1.end()) mMap1.find(temp)->second++;
        else mMap1.insert(make_pair(temp, 1));
        
    }

    // 대문자를 소문자로 변환
    for (int i = 0; i &lt; str2.length(); i++) {
        if (str2[i] >= 'A' &amp;&amp; str2[i] &lt;= 'Z') {
            str2[i] = tolower(str2[i]);
            tempstr2.push_back(str2[i]);
        }
        else if (str2[i] >= 'a' &amp;&amp; str2[i] &lt;= 'z') tempstr2.push_back(str2[i]);
        else tempstr2.push_back(' ');
    }

    for (int i = 0; i &lt; tempstr2.length() - 1; i++) {
        string temp = tempstr2.substr(i, 2);
        if (temp[0] == ' ' || temp[1] == ' ') continue;
        auto it = mMap2.find(temp);
        if (it != mMap2.end()) mMap2.find(temp)->second++;
        else mMap2.insert(make_pair(temp, 1));

    }

    float Union = 0, intersection = 0;

    for (auto &amp;it : mMap1) {

        auto it2 = mMap2.find(it.first);

        if (it2 != mMap2.end()) intersection += min(it.second, it2->second);
        
        uMap.insert(make_pair(it.first, it.second));
    }

    for (auto&amp; it : mMap2) {

        auto it2 = mMap1.find(it.first);

        if (it2 != mMap1.end()) it.second = max(it.second, it2->second);

        if (uMap.find(it.first) != uMap.end()) uMap.find(it.first)->second = max(uMap.find(it.first)->second, it.second);
        else uMap.insert(make_pair(it.first, it.second));

    }

    for (auto&amp; it : uMap) Union += it.second;
    
    if (mMap1.size() || mMap2.size()) answer = (intersection / Union) * 65536;
    else answer = 1 * 65536;

    return answer;
}
</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1163" height="384" src="https://lycos7560.com/wp-content/uploads/2023/03/image-23.png" alt="" class="wp-image-33756" srcset="https://lycos7560.com/wp-content/uploads/2023/03/image-23.png 1163w, https://lycos7560.com/wp-content/uploads/2023/03/image-23-300x99.png 300w, https://lycos7560.com/wp-content/uploads/2023/03/image-23-768x254.png 768w" sizes="(max-width: 1163px) 100vw, 1163px" /></figure>



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



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/programmers/programmers-17677-1%ec%b0%a8-%eb%89%b4%ec%8a%a4-%ed%81%b4%eb%9f%ac%ec%8a%a4%ed%84%b0%eb%a7%81-2018-kakao-blind-recruitment/33753/">Programmers 17677 [1차] 뉴스 클러스터링 [2018 KAKAO BLIND RECRUITMENT]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/programmers/programmers-17677-1%ec%b0%a8-%eb%89%b4%ec%8a%a4-%ed%81%b4%eb%9f%ac%ec%8a%a4%ed%84%b0%eb%a7%81-2018-kakao-blind-recruitment/33753/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 11723번 (집합, C++, 비트마스킹) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11723%eb%b2%88-%ec%a7%91%ed%95%a9-c-%eb%b9%84%ed%8a%b8%eb%a7%88%ec%8a%a4%ed%82%b9-baekjoon/5573/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11723%eb%b2%88-%ec%a7%91%ed%95%a9-c-%eb%b9%84%ed%8a%b8%eb%a7%88%ec%8a%a4%ed%82%b9-baekjoon/5573/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 26 Jan 2023 10:42:15 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[11723]]></category>
		<category><![CDATA[11723번]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Baekjoon]]></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[SET]]></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[백준 11723]]></category>
		<category><![CDATA[백준 11723번]]></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=5573</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 11723번 '집합' 문제에 대한 글 입니다. 비트마스킹, 배열, Set을 이용하여 해결하였습니다. (This is an article about the 'collection' problem in BAEKJOON 11723. It was solved using bit masking, arrangement, and Set.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11723%eb%b2%88-%ec%a7%91%ed%95%a9-c-%eb%b9%84%ed%8a%b8%eb%a7%88%ec%8a%a4%ed%82%b9-baekjoon/5573/">백준 11723번 (집합, 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 wp-block-paragraph"><a href="https://www.acmicpc.net/problem/11723" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/11723</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.5 초</td><td class="has-text-align-left" data-align="left">4 MB</td><td class="has-text-align-left" data-align="left">69837</td><td class="has-text-align-left" data-align="left">21400</td><td class="has-text-align-left" data-align="left">15369</td><td class="has-text-align-left" data-align="left">29.201%</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 wp-block-paragraph">비어있는 공집합 S가 주어졌을 때, 아래 연산을 수행하는 프로그램을 작성하시오.</p>



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



<p class="has-medium-font-size wp-block-paragraph"><code>add x</code>: S에 x를 추가한다. (1&nbsp;≤ x ≤ 20) S에 x가 이미 있는 경우에는 연산을 무시한다.</p>



<p class="has-medium-font-size wp-block-paragraph"><code>remove&nbsp;x</code>: S에서 x를 제거한다. (1&nbsp;≤ x ≤ 20)&nbsp;S에 x가 없는 경우에는 연산을 무시한다.</p>



<p class="has-medium-font-size wp-block-paragraph"><code>check x</code>: S에 x가 있으면 1을, 없으면 0을 출력한다.&nbsp;(1 ≤ x ≤ 20)</p>



<p class="has-medium-font-size wp-block-paragraph"><code>toggle x</code>: S에 x가 있으면 x를 제거하고, 없으면 x를 추가한다. (1&nbsp;≤ x ≤ 20)</p>



<p class="has-medium-font-size wp-block-paragraph"><code>all</code>: S를 {1, 2, &#8230;, 20} 으로 바꾼다.</p>



<p class="has-medium-font-size wp-block-paragraph"><code>empty</code>: S를 공집합으로 바꾼다.&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 wp-block-paragraph">첫째 줄에 수행해야 하는 연산의 수 M (1 ≤ M ≤ 3,000,000)이 주어진다.</p>



<p class="has-medium-font-size wp-block-paragraph">둘째 줄부터 M개의 줄에 수행해야 하는 연산이 한 줄에 하나씩 주어진다.</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 wp-block-paragraph"><code>check</code>&nbsp;연산이 주어질때마다, 결과를 출력한다.</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
add 1
add 2
check 1
check 2
check 3
remove 2
check 1
check 2
toggle 3
check 1
check 2
check 3
check 4
all
check 10
check 20
toggle 10
remove 20
check 10
check 20
empty
check 1
toggle 1
check 1
toggle 1
check 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
1
0
1
0
1
0
1
0
1
1
0
0
0
1
0</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/djm03178" target="_blank" rel="noreferrer noopener">djm03178</a></li>



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



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/pichulia" target="_blank" rel="noreferrer noopener">pichulia</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/14" 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 wp-block-paragraph">3가지 방법으로 해결</p>



<p class="has-medium-font-size wp-block-paragraph">=&gt; 비트 마스킹. 배열, set </p>



<p class="has-medium-font-size wp-block-paragraph"><strong>비트 마스킹</strong>이 가장 빠르다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph"><strong>1. 자료구조 Set</strong></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;set>

using namespace std;

set&lt;int> mySet;

int N, temp;

string str;

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

	cin >> N;
	while (N-- > 0) {
		cin >> str;
		if (str == "add") {
			// add x: S에 x를 추가한다. (1 ≤ x ≤ 20) 
			// S에 x가 이미 있는 경우에는 연산을 무시한다.
			cin >> temp;
			mySet.insert(temp);
		}
		else if (str == "remove") {
			//remove x : S에서 x를 제거한다. (1 ≤ x ≤ 20) 
			// S에 x가 없는 경우에는 연산을 무시한다.
			cin >> temp;
			mySet.erase(temp);
		}
		else if (str == "check") {
			// check x: S에 x가 있으면 1을, 
			// 없으면 0을 출력한다. (1 ≤ x ≤ 20)
			cin >> temp;
			if (mySet.count(temp)) cout &lt;&lt; "1" &lt;&lt; "\n";
			else cout &lt;&lt; "0" &lt;&lt; "\n";
		}
		else if (str == "toggle") {
			// toggle x : S에 x가 있으면 x를 제거하고, 
			// 없으면 x를 추가한다. (1 ≤ x ≤ 20)
			cin >> temp;
			if (mySet.count(temp)) mySet.erase(temp);
			else mySet.insert(temp);
		}
		else if (str == "all") {
			// all: S를 {1, 2, ..., 20} 으로 바꾼다.
			for (int i = 1; i &lt;= 20; i++) mySet.insert(i);
		}
		else { 
			// empty: S를 공집합으로 바꾼다. 
			mySet.clear();
		}
	}

	return 0;
}</pre>



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



<p class="has-medium-font-size wp-block-paragraph"><strong>2. 배열</strong></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>
using namespace std;

bool arr[20];
int N, temp;

string str;

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

	cin >> N;
	while (N-- > 0) {
		cin >> str;
		if (str == "add") {
			// add x: S에 x를 추가한다. (1 ≤ x ≤ 20) 
			// S에 x가 이미 있는 경우에는 연산을 무시한다.
			cin >> temp;
			arr[temp-1] = 1;
		}
		else if (str == "remove") {
			//remove x : S에서 x를 제거한다. (1 ≤ x ≤ 20) 
			// S에 x가 없는 경우에는 연산을 무시한다.
			cin >> temp;
			arr[temp-1] = 0;
		}
		else if (str == "check") {
			// check x: S에 x가 있으면 1을, 
			// 없으면 0을 출력한다. (1 ≤ x ≤ 20)
			cin >> temp;
			cout &lt;&lt; arr[temp-1] &lt;&lt; "\n";
		}
		else if (str == "toggle") {
			// toggle x : S에 x가 있으면 x를 제거하고, 
			// 없으면 x를 추가한다. (1 ≤ x ≤ 20)
			cin >> temp;
			if (arr[temp-1] == 1) arr[temp-1] = 0;
			else  arr[temp-1] = 1;
		}
		else if (str == "all") {
			// all: S를 {1, 2, ..., 20} 으로 바꾼다.
			for (int i = 0; i &lt; 20; i++) arr[i] = 1;
		}
		else {
			// empty: S를 공집합으로 바꾼다. 
			fill(arr, arr + 20, 0);
		}
	}

	return 0;
}
</pre>



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



<p class="has-medium-font-size wp-block-paragraph"><strong>3. 비트 마스킹</strong></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>

using namespace std;

int S = 0; // 비트마스킹
string str;
int N, temp;

int main() {

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

	cin >> N;
	while(N-- > 0) {

		cin >> str;
		if (str == "add") {
			// add x: S에 x를 추가한다. (1 ≤ x ≤ 20) 
			// S에 x가 이미 있는 경우에는 연산을 무시한다.
			cin >> temp;
			S = S | (1 &lt;&lt; temp);
		}
		else if (str == "remove") {
			//remove x : S에서 x를 제거한다. (1 ≤ x ≤ 20) 
			// S에 x가 없는 경우에는 연산을 무시한다.
			cin >> temp;
			S = S &amp; ~(1 &lt;&lt; temp);
		}
		else if (str == "check") {
			// check x: S에 x가 있으면 1을, 
			// 없으면 0을 출력한다. (1 ≤ x ≤ 20)
			cin >> temp;
			if (S &amp; (1 &lt;&lt; temp)) cout &lt;&lt; "1\n";
			else cout &lt;&lt; "0\n";
		}
		else if (str == "toggle") {
			// toggle x : S에 x가 있으면 x를 제거하고, 
			// 없으면 x를 추가한다. (1 ≤ x ≤ 20)
			cin >> temp;
			if (S &amp; (1 &lt;&lt; temp)) {
				S = S &amp; ~(1 &lt;&lt; temp);
			}
			else {
				S = S | (1 &lt;&lt; temp);
			}
		}
		else if (str == "all") {
			// all: S를 {1, 2, ..., 20} 으로 바꾼다.
			S = (1 &lt;&lt; 21) - 1;
		}
		else {
			// empty: S를 공집합으로 바꾼다. 
			S = 0;
		}
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1030" height="221" src="https://lycos7560.com/wp-content/uploads/image-1062.png" alt="" class="wp-image-5582" srcset="https://lycos7560.com/wp-content/uploads/image-1062.png 1030w, https://lycos7560.com/wp-content/uploads/image-1062-300x64.png 300w, https://lycos7560.com/wp-content/uploads/image-1062-768x165.png 768w" sizes="(max-width: 1030px) 100vw, 1030px" /></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-11723%eb%b2%88-%ec%a7%91%ed%95%a9-c-%eb%b9%84%ed%8a%b8%eb%a7%88%ec%8a%a4%ed%82%b9-baekjoon/5573/">백준 11723번 (집합, 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-11723%eb%b2%88-%ec%a7%91%ed%95%a9-c-%eb%b9%84%ed%8a%b8%eb%a7%88%ec%8a%a4%ed%82%b9-baekjoon/5573/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 7662번 (이중 우선순위 큐, C++, Multiset) / 추가 반례 [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-7662%eb%b2%88-%ec%9d%b4%ec%a4%91-%ec%9a%b0%ec%84%a0%ec%88%9c%ec%9c%84-%ed%81%90-c-multiset-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5467/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-7662%eb%b2%88-%ec%9d%b4%ec%a4%91-%ec%9a%b0%ec%84%a0%ec%88%9c%ec%9c%84-%ed%81%90-c-multiset-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5467/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 24 Jan 2023 16:11:17 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[7662]]></category>
		<category><![CDATA[7662번]]></category>
		<category><![CDATA[algorithm]]></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[Multiset]]></category>
		<category><![CDATA[priority_queue]]></category>
		<category><![CDATA[PriorityQueue]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[반례]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 7662]]></category>
		<category><![CDATA[백준 7662번]]></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=5467</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 7662번 '이중 우선순위' 문제에 대한 글입니다. 'multiset' 자료구조를 이용하여 해결하였습니다. (his is BAEKJOON's No. 7662 on the 'double priority queue' problem. We solved it using the 'multiset' data structure.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-7662%eb%b2%88-%ec%9d%b4%ec%a4%91-%ec%9a%b0%ec%84%a0%ec%88%9c%ec%9c%84-%ed%81%90-c-multiset-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5467/">백준 7662번 (이중 우선순위 큐, C++, Multiset) / 추가 반례 [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 wp-block-paragraph"><a href="https://www.acmicpc.net/problem/7662" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/7662</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">6 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">41775</td><td class="has-text-align-left" data-align="left">9599</td><td class="has-text-align-left" data-align="left">7027</td><td class="has-text-align-left" data-align="left">22.163%</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 wp-block-paragraph">이중 우선순위 큐(dual priority queue)는 전형적인 우선순위 큐처럼 데이터를 삽입, 삭제할 수 있는 자료 구조이다. </p>



<p class="has-medium-font-size wp-block-paragraph">전형적인 큐와의 차이점은 데이터를 삭제할 때 연산(operation) 명령에 따라 </p>



<p class="has-medium-font-size wp-block-paragraph">우선순위가 가장 높은 데이터 또는 가장 낮은 데이터 중 하나를 삭제하는 점이다. </p>



<p class="has-medium-font-size wp-block-paragraph">이중 우선순위 큐를 위해선 두 가지 연산이 사용되는데, </p>



<p class="has-medium-font-size wp-block-paragraph">하나는 데이터를 삽입하는 연산이고 다른 하나는 데이터를 삭제하는 연산이다. </p>



<p class="has-medium-font-size wp-block-paragraph">데이터를 삭제하는 연산은 또 두 가지로 구분되는데 하나는 우선순위가 가장 높은 것을 삭제하기 위한 것이고 </p>



<p class="has-medium-font-size wp-block-paragraph">다른 하나는 우선순위가 가장 낮은 것을 삭제하기 위한 것이다.&nbsp;</p>



<p class="has-medium-font-size wp-block-paragraph">정수만 저장하는 이중 우선순위 큐 Q가 있다고 가정하자. </p>



<p class="has-medium-font-size wp-block-paragraph">Q에 저장된 각 정수의 값 자체를 우선순위라고 간주하자.&nbsp;</p>



<p class="has-medium-font-size wp-block-paragraph">Q에 적용될 일련의 연산이 주어질 때 이를 처리한 후 최종적으로 Q에 저장된 데이터 중 </p>



<p class="has-medium-font-size wp-block-paragraph">최댓값과 최솟값을 출력하는 프로그램을 작성하라.</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 wp-block-paragraph">입력 데이터는 표준입력을 사용한다. 입력은 T개의 테스트 데이터로 구성된다. </p>



<p class="has-medium-font-size wp-block-paragraph">입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">각 테스트 데이터의 첫째 줄에는 Q에 적용할 연산의 개수를 나타내는 정수 k (k ≤ 1,000,000)가 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">이어지는 k 줄 각각엔 연산을 나타내는 문자(‘D’ 또는 ‘I’)와 정수 n이 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">‘I n’은 정수 n을 Q에 삽입하는 연산을 의미한다. 동일한 정수가 삽입될 수 있음을 참고하기 바란다. </p>



<p class="has-medium-font-size wp-block-paragraph">‘D 1’는 Q에서 최댓값을 삭제하는 연산을 의미하며, ‘D -1’는 Q 에서 최솟값을 삭제하는 연산을 의미한다.</p>



<p class="has-medium-font-size wp-block-paragraph"> 최댓값(최솟값)을 삭제하는 연산에서 최댓값(최솟값)이 둘 이상인 경우, 하나만 삭제됨을 유념하기 바란다.</p>



<p class="has-medium-font-size wp-block-paragraph">만약 Q가 비어있는데 적용할 연산이 ‘D’라면 이 연산은 무시해도 좋다. Q에 저장될 모든 정수는 32-비트 정수이다.&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 wp-block-paragraph">출력은 표준출력을 사용한다. 각 테스트 데이터에 대해, 모든 연산을 처리한 후 Q에 남아 있는 값 중 최댓값과 최솟값을 출력하라. </p>



<p class="has-medium-font-size wp-block-paragraph">두 값은 한 줄에 출력하되 하나의 공백으로 구분하라. </p>



<p class="has-medium-font-size wp-block-paragraph">만약 Q가 비어있다면 ‘EMPTY’를 출력하라.</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="">2
7
I 16
I -5643
D -1
D 1
D 1
I 123
D -1
9
I -45
I 653
D 1
I -642
I 45
I 97
D 1
D -1
I 333</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="">EMPTY
333 -45</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="">2
9
I 36
I 37
I 38
D 1
D 1
I 39
I 40
D -1
D -1
4
I 40
I 40
D 1
D -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="">40 40
EMPTY</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="">3
2
I 2147483647
I -2147483648
3
I 5
D -1
I 4
7
D 1
D -1
I 2147483647
I -2147483648
D 1
D -1
I 0</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="">2147483647 -2147483648
4 4
0 0</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
16
I -1
I -2
I 1
I 10
I 2
I 3
I 4
I 5
I 6
I 7
I 8
D 1
D -1
D 1
D -1
D 1
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="">6 1
EMPTY</pre>



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



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



<p class="wp-block-paragraph"><a href="https://www.acmicpc.net/category/1" target="_blank" rel="noreferrer noopener">ICPC</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/7" target="_blank" rel="noreferrer noopener">Regionals</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/42" target="_blank" rel="noreferrer noopener">Asia Pacific</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/211" target="_blank" rel="noreferrer noopener">Korea</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/256" target="_blank" rel="noreferrer noopener">Nationwide Internet Competition</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/1124" target="_blank" rel="noreferrer noopener">Daejeon Nationalwide Internet Competition 2013</a>&nbsp;D번</p>



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



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



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



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



<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 wp-block-paragraph">최소힙과 최대힙 문제</p>



<p class="has-medium-font-size wp-block-paragraph">자료구조 multiset은 자동으로 오름차순으로 정렬되고 중복도 가능하다.</p>



<p class="has-medium-font-size wp-block-paragraph">이를 이용하여 최댓값은 맨뒤에서 하나 지우고 최솟값은 맨 앞에서 하나 지우는 방법으로 문제를 해결하였다.</p>



<p class="has-medium-font-size wp-block-paragraph">문제의 이름이 &#8220;이중 우선순위 큐&#8221; 지만 multiset이 더 좋은 방법 같아서 사용</p>



<div style="height:50px" 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;set>
#include &lt;list>

using namespace std;

int T, N;

pair&lt;char,int> temp;

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

	cin >> T;

	while (T-- > 0) {

		cin >> N;

		multiset&lt;int> myMSet;

		while (N-- > 0) {

			cin >> temp.first >> temp.second;

			if (temp.first == 'I') myMSet.insert(temp.second);
			else if (temp.second == -1) {
				if (myMSet.empty()) continue; // 비어 있다면 연산 무시
				else myMSet.erase(myMSet.begin()); // 최솟값 지우기
			}
			else {
				if (myMSet.empty()) continue; // 비어 있다면 연산 무시
				else myMSet.erase(--myMSet.end()); // 최댓값 지우기
			}
		}

		if (!myMSet.empty()) cout &lt;&lt; *--myMSet.end() &lt;&lt; " " &lt;&lt; *myMSet.begin() &lt;&lt; "\n";
		else cout &lt;&lt; "EMPTY" &lt;&lt; "\n"; // 비어 있다면 출력
	}

	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="184" src="https://lycos7560.com/wp-content/uploads/image-1051.png" alt="" class="wp-image-5468" srcset="https://lycos7560.com/wp-content/uploads/image-1051.png 1039w, https://lycos7560.com/wp-content/uploads/image-1051-300x53.png 300w, https://lycos7560.com/wp-content/uploads/image-1051-768x136.png 768w" sizes="(max-width: 1039px) 100vw, 1039px" /></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-7662%eb%b2%88-%ec%9d%b4%ec%a4%91-%ec%9a%b0%ec%84%a0%ec%88%9c%ec%9c%84-%ed%81%90-c-multiset-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5467/">백준 7662번 (이중 우선순위 큐, C++, Multiset) / 추가 반례 [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-7662%eb%b2%88-%ec%9d%b4%ec%a4%91-%ec%9a%b0%ec%84%a0%ec%88%9c%ec%9c%84-%ed%81%90-c-multiset-%ec%b6%94%ea%b0%80-%eb%b0%98%eb%a1%80-baekjoon/5467/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1764번 (듣보잡, C++, Set) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1764%eb%b2%88-%eb%93%a3%eb%b3%b4%ec%9e%a1-c-set-baekjoon/4613/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1764%eb%b2%88-%eb%93%a3%eb%b3%b4%ec%9e%a1-c-set-baekjoon/4613/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 15 Jan 2023 22:24:58 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[unordered_set]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[문자열]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1764]]></category>
		<category><![CDATA[백준 1764번]]></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=4613</guid>

					<description><![CDATA[<p>백준 1764번 '듣보잡' 문제에 대한 글입니다.  자료구조 "unordered_set","set"의 성질을 이용하여 해결하였습니다.</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1764%eb%b2%88-%eb%93%a3%eb%b3%b4%ec%9e%a1-c-set-baekjoon/4613/">백준 1764번 (듣보잡, C++, Set) [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>



<h2 class="wp-block-heading">듣보잡</h2>



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



<div style="height:36px" 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">67422</td><td class="has-text-align-left" data-align="left">28319</td><td class="has-text-align-left" data-align="left">21683</td><td class="has-text-align-left" data-align="left">40.383%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size wp-block-paragraph">김진영이 듣도 못한 사람의 명단과, 보도 못한 사람의 명단이 주어질 때, </p>



<p class="has-medium-font-size wp-block-paragraph">듣도 보도 못한 사람의 명단을 구하는 프로그램을 작성하시오.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, </p>



<p class="has-medium-font-size wp-block-paragraph">N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">이름은 띄어쓰기 없이 알파벳 소문자로만 이루어지며, 그 길이는 20 이하이다. </p>



<p class="has-medium-font-size wp-block-paragraph">N, M은 500,000 이하의 자연수이다.</p>



<p class="has-medium-font-size wp-block-paragraph">듣도 못한 사람의 명단에는 중복되는 이름이 없으며, </p>



<p class="has-medium-font-size wp-block-paragraph">보도 못한 사람의 명단도 마찬가지이다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">듣보잡의 수와 그 명단을 사전순으로 출력한다.</p>



<div style="height:37px" 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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3 4
ohhenrie
charlie
baesangwook
obama
baesangwook
ohhenrie
clinton</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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2
baesangwook
ohhenrie</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/author5" target="_blank" rel="noreferrer noopener">author5</a></li>
</ul>



<div style="height:52px" 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/158" 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/136" target="_blank" rel="noreferrer noopener">해시를 사용한 집합과 맵</a></li>
</ul>



<div style="height:56px" 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 wp-block-paragraph">자료구조 unordered_set과 set을 이용하여 해결한 문제</p>



<p class="has-medium-font-size wp-block-paragraph">처음 문자열을 입력받고 unordered_set에 저장한다.</p>



<p class="has-medium-font-size wp-block-paragraph">그 이후 M을 받을 때 unordered_set에 존재한다면 </p>



<p class="has-medium-font-size wp-block-paragraph">Set에 저장하여 정렬하는 방식으로 해결하였다. </p>



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



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



<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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;unordered_set>
#include &lt;set>

using namespace std;

string arr[1000000];

unordered_set&lt;string> uSet;

set&lt;string> mySet;

string str;

int N, M;

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 = 0; i &lt; N + M; i++) cin >> arr[i];

	for (int i = 0; i &lt; N; i++) uSet.insert(arr[i]);

	for (int i = N; i &lt; N + M; i++) if (uSet.count(arr[i])) mySet.insert(arr[i]);

	cout &lt;&lt; mySet.size() &lt;&lt; "\n";

	for (auto it = mySet.begin(); it != mySet.end(); it++) cout &lt;&lt; *it &lt;&lt; "\n";

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1035" height="99" src="https://lycos7560.com/wp-content/uploads/image-945.png" alt="" class="wp-image-4614" srcset="https://lycos7560.com/wp-content/uploads/image-945.png 1035w, https://lycos7560.com/wp-content/uploads/image-945-300x29.png 300w, https://lycos7560.com/wp-content/uploads/image-945-768x73.png 768w" sizes="(max-width: 1035px) 100vw, 1035px" /></figure>



<div style="height:63px" 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-1764%eb%b2%88-%eb%93%a3%eb%b3%b4%ec%9e%a1-c-set-baekjoon/4613/">백준 1764번 (듣보잡, C++, Set) [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-1764%eb%b2%88-%eb%93%a3%eb%b3%b4%ec%9e%a1-c-set-baekjoon/4613/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1920번 (수 찾기, C++, set) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/1920-finding-numbers-c-baekjoon/4309/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/1920-finding-numbers-c-baekjoon/4309/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 09 Jan 2023 15:43:51 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1920]]></category>
		<category><![CDATA[1920번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1920]]></category>
		<category><![CDATA[백준 1920번]]></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=4309</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 1920번 '수 찾기' 문제에 대한 글입니다. set 을 이용하여 해결하였습니다. (This is an article about the question of 'finding numbers' in BAEKJOON 1920. I solved it using set.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/1920-finding-numbers-c-baekjoon/4309/">백준 1920번 (수 찾기, C++, set) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-5698326622209671" data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



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



<h1 class="wp-block-heading">수 찾기</h1>



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



<div style="height:44px" 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">128 MB</td><td class="has-text-align-left" data-align="left">178424</td><td class="has-text-align-left" data-align="left">53533</td><td class="has-text-align-left" data-align="left">35489</td><td class="has-text-align-left" data-align="left">29.831%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size wp-block-paragraph">N개의 정수 A[1], A[2], …, A[N]이 주어져 있을 때, </p>



<p class="has-medium-font-size wp-block-paragraph">이 안에 X라는 정수가 존재하는지 알아내는 프로그램을 작성하시오.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 자연수 N(1 ≤ N ≤ 100,000)이 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">다음 줄에는 N개의 정수 A[1], A[2], …, A[N]이 주어진다. 다음 줄에는 M(1 ≤ M ≤ 100,000)이 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">다음 줄에는 M개의 수들이 주어지는데, 이 수들이 A안에 존재하는지 알아내면 된다. </p>



<p class="has-medium-font-size wp-block-paragraph">모든 정수의 범위는 -2<sup>31</sup>&nbsp;보다 크거나 같고 2<sup>31</sup>보다 작다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">M개의 줄에 답을 출력한다. </p>



<p class="has-medium-font-size wp-block-paragraph">존재하면 1을, 존재하지 않으면 0을 출력한다.</p>



<div style="height:51px" 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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
4 1 5 2 3
5
1 3 7 9 5</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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1
1
0
0
1</pre>



<div style="height:59px" 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/BaaaaaaaaaaarkingDog" target="_blank" rel="noreferrer noopener">BaaaaaaaaaaarkingDog</a>,&nbsp;<a href="https://www.acmicpc.net/user/djm03178" target="_blank" rel="noreferrer noopener">djm03178</a></li>



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



<li>잘못된 데이터를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/tncks0121" target="_blank" rel="noreferrer noopener">tncks0121</a></li>
</ul>



<div style="height:36px" 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/97" target="_blank" rel="noreferrer noopener">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/12" 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 wp-block-paragraph">문제를 정리하면 처음에 N을 입력받고 N의 수 만큼 숫자를 입력받는다.</p>



<p class="has-medium-font-size wp-block-paragraph">다음으로 M을 입력받고 M의 수 만큼 숫자가 주어지는 데</p>



<p class="has-medium-font-size wp-block-paragraph">그 숫자들이 전에 N의 수 만큼을 입력받을 때 존재했다면 1을 출력 아니면 0을 출력하는 문제</p>



<p class="has-medium-font-size wp-block-paragraph">나는 set에 N의 수들을 넣어주고 (Set은 중복을 허용하지 않는다.)</p>



<p class="has-medium-font-size wp-block-paragraph">M의 수 만큼의 숫자를 입력 받을 때 중복을 체크하여 답을 구하였다.</p>



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



<h2 class="wp-block-heading">시간 초과된 코드</h2>



<div style="height:31px" 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>

using namespace std;

set&lt;int> mySet;

int N, temp;

int main()
{
	cin >> N;
	while (N-- > 0) {
		cin >> temp;
		mySet.insert(temp);
	}

	cin >> N;
	while (N-- > 0) {
		cin >> temp; // m을 입력받고 
                // 입력 받은 수가 N에 있는지 확인
		if (mySet.find(temp) != mySet.end()) { cout &lt;&lt; "1\n"; }
		else { cout &lt;&lt; "0\n"; }
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1244" height="114" src="https://lycos7560.com/wp-content/uploads/image-890.png" alt="" class="wp-image-4310" srcset="https://lycos7560.com/wp-content/uploads/image-890.png 1244w, https://lycos7560.com/wp-content/uploads/image-890-300x27.png 300w, https://lycos7560.com/wp-content/uploads/image-890-768x70.png 768w" sizes="(max-width: 1244px) 100vw, 1244px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">시간 초과의 원인은 내 성질이 급해서 입력을 받는 즉시 판별을 하려고 해서 그렇다. </p>



<p class="has-medium-font-size wp-block-paragraph">(입력 단에서 시간초과라고 인지하는 것)</p>



<p class="has-medium-font-size wp-block-paragraph">그래서 입력과 판별을 분리하여 다시 작성하였다.</p>



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



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



<div style="height:39px" 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;list>

using namespace std;

set&lt;int> mySet;
list&lt;int> myList;
int N, temp;

int main()
{
	cin >> N;
	while (N-- > 0) {
		cin >> temp;
		mySet.insert(temp);
	}

	cin >> N;

	while (N-- > 0) {
		cin >> temp;
		myList.push_back(temp);
	}

	for (auto it = myList.begin(); it != myList.end(); it++) {
		if (mySet.find(*it) != mySet.end()) { cout &lt;&lt; "1\n"; }
		else { cout &lt;&lt; "0\n"; }
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1241" height="228" src="https://lycos7560.com/wp-content/uploads/image-891.png" alt="" class="wp-image-4311" srcset="https://lycos7560.com/wp-content/uploads/image-891.png 1241w, https://lycos7560.com/wp-content/uploads/image-891-300x55.png 300w, https://lycos7560.com/wp-content/uploads/image-891-768x141.png 768w" sizes="(max-width: 1241px) 100vw, 1241px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">다른 분들의 풀이를 보니 이진 탐색을 사용하는 문제였던 것 같다.</p>



<p class="has-medium-font-size wp-block-paragraph">(set도 &#8216;이진탐색트리&#8217; 라서 상관 없을 듯)</p>



<div style="height:47px" 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/1920-finding-numbers-c-baekjoon/4309/">백준 1920번 (수 찾기, C++, set) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/1920-finding-numbers-c-baekjoon/4309/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 8911번 (거북이, C++, Simulation) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-8911%eb%b2%88-%ea%b1%b0%eb%b6%81%ec%9d%b4-c-simulation/2967/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-8911%eb%b2%88-%ea%b1%b0%eb%b6%81%ec%9d%b4-c-simulation/2967/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 02 Dec 2022 20:40:21 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[8911]]></category>
		<category><![CDATA[8911번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[거북이]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 8911]]></category>
		<category><![CDATA[백준 8911번]]></category>
		<category><![CDATA[시뮬레이션]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=2967</guid>

					<description><![CDATA[<p>백준 8911번 거북이 문제를 풀이한 글입니다.</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/baekjoon-8911%eb%b2%88-%ea%b1%b0%eb%b6%81%ec%9d%b4-c-simulation/2967/">백준 8911번 (거북이, 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:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">거북이&nbsp;&nbsp;&nbsp;</h1>



<p class="wp-block-paragraph"><a href="https://www.acmicpc.net/problem/8911" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/8911</a></p>



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



<figure id="problem-info" class="wp-block-table"><table><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">3605</td><td class="has-text-align-left" data-align="left">1936</td><td class="has-text-align-left" data-align="left">1511</td><td class="has-text-align-left" data-align="left">52.465%</td></tr></tbody></table></figure>



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



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



<p class="has-medium-font-size wp-block-paragraph">상근이는 2차원 평면 위에서 움직일 수 있는 거북이 로봇을 하나 가지고 있다. 거북이 로봇에게 내릴 수 있는 명령은 다음과 같이 네가지가 있다.</p>



<p class="has-medium-font-size wp-block-paragraph">F: 한 눈금 앞으로</p>



<p class="has-medium-font-size wp-block-paragraph">B: 한 눈금 뒤로</p>



<p class="has-medium-font-size wp-block-paragraph">L: 왼쪽으로 90도 회전</p>



<p class="has-medium-font-size wp-block-paragraph">R: 오른쪽으로 90도 회전</p>



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



<p class="has-medium-font-size wp-block-paragraph">L과 R명령을 내렸을 때, 로봇은 이동하지 않고, 방향만 바꾼다. 명령을 나열한 것을 거북이 로봇의 컨트롤 프로그램이라고 한다.</p>



<p class="has-medium-font-size wp-block-paragraph">상근이는 자신의 컨트롤 프로그램으로 거북이가 이동한 영역을 계산해보려고 한다. 거북이는 항상 x축과 y축에 평행한 방향으로만 이동한다. </p>



<p class="has-medium-font-size wp-block-paragraph">거북이가 지나간 영역을 모두 포함할 수 있는 가장 작은 직사각형의 넓이를 구하는 프로그램을 작성하시오.&nbsp;</p>



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



<p class="has-medium-font-size wp-block-paragraph">단, 직사각형의 모든 변은 x축이나 y축에 평행이어야 한다.</p>



<p class="has-medium-font-size wp-block-paragraph">아래 그림에서 거북이는 가장 처음에 (0, 0)에 있고, 북쪽을 쳐다보고 있다.&nbsp;컨트롤 프로그램이 FLFRFLBRBLB인 경우에 거북이는 아래와 같이 움직인다. </p>



<p class="has-medium-font-size wp-block-paragraph">회색으로 빗금친 부분이 거북이가 지나간 영역을 모두 포함할 수 있는 가장 작은 직사각형이다. 넓이는 4가 된다.</p>



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



<figure class="wp-block-image"><img decoding="async" src="https://onlinejudgeimages.s3-ap-northeast-1.amazonaws.com/upload/images/turtle.png" alt=""/></figure>



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



<p class="has-medium-font-size wp-block-paragraph">거북이가 지나간 영역이 직사각형을 만들지 않는 경우도 있다. 예를 들어, FFLLFF인 경우에 거북이는 y축의 위로만 지나다닌다. </p>



<p class="has-medium-font-size wp-block-paragraph">이 경우에 거북이가 지나간 영역을 모두 포함하는 직사각형은 선분이고, 선분은 한 변이 0인 직사각형으로 생각할 수 있다. </p>



<p class="has-medium-font-size wp-block-paragraph">따라서, 선분의 경우에 넓이는 0이 된다.</p>



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



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



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 컨트롤 프로그램이 주어진다. </p>



<p class="has-medium-font-size wp-block-paragraph">프로그램은 항상 문제의 설명에 나와있는 네가지 명령으로만 이루어져 있고, 길이는 500을 넘지 않는다. </p>



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



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



<p class="has-medium-font-size wp-block-paragraph">각 테스트 케이스에 대해서, 거북이가 이동한 영역을 모두 포함하는 가장 작은 직사각형의 넓이를 출력한다.</p>



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



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



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



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



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



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



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



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



<p class="wp-block-paragraph"><a href="https://www.acmicpc.net/category/1" target="_blank" rel="noreferrer noopener">ICPC</a> > <a href="https://www.acmicpc.net/category/7" target="_blank" rel="noreferrer noopener">Regionals</a> > <a href="https://www.acmicpc.net/category/42" target="_blank" rel="noreferrer noopener">Asia Pacific</a> > <a href="https://www.acmicpc.net/category/211" target="_blank" rel="noreferrer noopener">Korea</a> > <a href="https://www.acmicpc.net/category/detail/1061" target="_blank" rel="noreferrer noopener">Asia Regional &#8211; Daejeon 2011</a> L번</p>



<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/djm03178" target="_blank" rel="noreferrer noopener">djm03178</a>,&nbsp;<a href="https://www.acmicpc.net/user/hist0613" target="_blank" rel="noreferrer noopener">hist0613</a></li>
</ul>



<div style="height:24px" 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/141" target="_blank" rel="noreferrer noopener">시뮬레이션</a></li>
</ul>



<div style="height:33px" 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 wp-block-paragraph">거북이가 지나간 영역을 모두 포함할 수 있는 가장 작은 직사각형을 구하는 문제</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="340" height="254" src="https://lycos7560.com/wp-content/uploads/image-472.png" alt="" class="wp-image-2972" srcset="https://lycos7560.com/wp-content/uploads/image-472.png 340w, https://lycos7560.com/wp-content/uploads/image-472-300x224.png 300w" sizes="(max-width: 340px) 100vw, 340px" /></figure>



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



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



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



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



<figure class="wp-block-image size-full"><img decoding="async" width="474" height="283" src="https://lycos7560.com/wp-content/uploads/image-476.png" alt="" class="wp-image-2976" srcset="https://lycos7560.com/wp-content/uploads/image-476.png 474w, https://lycos7560.com/wp-content/uploads/image-476-300x179.png 300w" sizes="(max-width: 474px) 100vw, 474px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">거북이가 할 수 있는 행동</p>



<p class="has-medium-font-size wp-block-paragraph">F: 한 눈금 앞으로</p>



<p class="has-medium-font-size wp-block-paragraph">B: 한 눈금 뒤로</p>



<p class="has-medium-font-size wp-block-paragraph">L: 왼쪽으로 90도 회전</p>



<p class="has-medium-font-size wp-block-paragraph">R: 오른쪽으로 90도 회전</p>



<p class="has-medium-font-size wp-block-paragraph">을 구현하는 것과 이 행동으로 나온 결과물로 영역을 모두 포함 할 수 있는 가장 작은 직사각형의 넓이를 구하면 될 것 같다.</p>



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



<p class="has-medium-font-size wp-block-paragraph">명령어는 string 입력 받아서 처리할 예정 </p>



<p class="has-medium-font-size wp-block-paragraph">테스트 케이스들은 list에 넣어서 처리</p>



<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="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;list>

using namespace std;

int T;

string tempString;

list&lt;string> testCase;

void Initializtion()
{
	cin >> T;
	while (T > 0)
	{
		cin >> tempString;
		testCase.push_back(tempString);
		T--;
	}

}

// 거북이가 지나간 영역을 포함하는 가장 작은 직사각형 계산 함수
int SizeCalculation(string testcase)
{




	return 0;
}


int main()
{
	// 초기화
	Initializtion();
	 
	for (auto iter = testCase.begin(); iter != testCase.end(); iter++)
	{
		cout &lt;&lt; SizeCalculation(*iter) &lt;&lt; "\n";
	}

	return 0;
}</pre>



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



<div style="height:70px" 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 wp-block-paragraph">배열로 거북이가 취할 수 있는 행동을 정의</p>



<figure class="wp-block-image size-full"><img decoding="async" width="499" height="168" src="https://lycos7560.com/wp-content/uploads/image-477.png" alt="" class="wp-image-2977" srcset="https://lycos7560.com/wp-content/uploads/image-477.png 499w, https://lycos7560.com/wp-content/uploads/image-477-300x101.png 300w" sizes="(max-width: 499px) 100vw, 499px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">명령어에서 실제로 좌표가 움직이는 명령은 F B </p>



<p class="has-medium-font-size wp-block-paragraph">나머지 명령어는 거북이의 conditionTurtle를 변경해 준다.</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="772" height="653" src="https://lycos7560.com/wp-content/uploads/image-478.png" alt="" class="wp-image-2978" srcset="https://lycos7560.com/wp-content/uploads/image-478.png 772w, https://lycos7560.com/wp-content/uploads/image-478-300x254.png 300w, https://lycos7560.com/wp-content/uploads/image-478-768x650.png 768w" sizes="(max-width: 772px) 100vw, 772px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">직사각형의 넓이는 Set&lt;int&gt;를 이용하여 최소값과 최대값을 구하여 해결 </p>



<figure class="wp-block-image size-full"><img decoding="async" width="850" height="175" src="https://lycos7560.com/wp-content/uploads/image-479.png" alt="" class="wp-image-2979" srcset="https://lycos7560.com/wp-content/uploads/image-479.png 850w, https://lycos7560.com/wp-content/uploads/image-479-300x62.png 300w, https://lycos7560.com/wp-content/uploads/image-479-768x158.png 768w" sizes="(max-width: 850px) 100vw, 850px" /></figure>



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



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



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



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

using namespace std;

int T;

string tempString;

list&lt;string> testCase;

int directionTurtle[4][2] = {
	{0, 1 },
	{1, 0 },
	{0, -1},
	{-1, 0}
};

// 초기화
void Initializtion()
{
	cin >> T;
	while (T > 0)
	{
		cin >> tempString;
		testCase.push_back(tempString);
		T--;
	}

}

// 거북이가 지나간 영역을 포함하는 가장 작은 직사각형 계산 함수 
int SizeCalculation(string testcase)
{
	int curX = 0;
	int curY = 0;
	int conditionTurtle = 0;
	set&lt;int> xSet;
	set&lt;int> ySet;
	xSet.insert(curX);
	ySet.insert(curY);

	// 명령어를 처리하는 부분
	for (int i = 0; i &lt; testcase.size(); i++)
	{
		switch (testcase[i])
		{
			case 'F': // 전진
				curX += directionTurtle[conditionTurtle][0];
				curY += directionTurtle[conditionTurtle][1];
				break;

			case 'B': // 후진
				curX -= directionTurtle[conditionTurtle][0];
				curY -= directionTurtle[conditionTurtle][1];
				break;

			case 'L': // 왼쪽으로 90도 회전
				conditionTurtle--;
				if (conditionTurtle &lt;= -1) {
					conditionTurtle = 3; }
				break;

			case 'R': // 우측으로 90도 회전
				conditionTurtle++;
				if (conditionTurtle >= 4) {
					conditionTurtle = 0; }
				break;

			default:
				cout &lt;&lt; "이거 나오면 큰일남";
				break;
		}

		xSet.insert(curX);
		ySet.insert(curY);
	}

	// Set&lt;int>를 이용하여 x,y의 가장 낮은 값과 높은 값을 계산하여 직사각형 가로 세로를 구한다.
	int width = *xSet.begin() - *--xSet.end();
	int height = *ySet.begin() - *--ySet.end();

	return abs(width * height);
}


int main()
{
	Initializtion();
	 
	//테스트 케이스 만큼 반복
	for (auto iter = testCase.begin(); iter != testCase.end(); iter++)
	{
		cout &lt;&lt; SizeCalculation(*iter) &lt;&lt; "\n";
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="837" height="80" src="https://lycos7560.com/wp-content/uploads/image-480.png" alt="" class="wp-image-2980" srcset="https://lycos7560.com/wp-content/uploads/image-480.png 837w, https://lycos7560.com/wp-content/uploads/image-480-300x29.png 300w, https://lycos7560.com/wp-content/uploads/image-480-768x73.png 768w" sizes="(max-width: 837px) 100vw, 837px" /></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_online_judge/baekjoon-8911%eb%b2%88-%ea%b1%b0%eb%b6%81%ec%9d%b4-c-simulation/2967/">백준 8911번 (거북이, 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/baekjoon-8911%eb%b2%88-%ea%b1%b0%eb%b6%81%ec%9d%b4-c-simulation/2967/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1449번 (수리공 항승, C++, set) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/</link>
					<comments>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 16:40:01 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1449번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[iterator]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[맞았습니다]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1449]]></category>
		<category><![CDATA[백준 1449번]]></category>
		<category><![CDATA[수리공 항승]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[예제]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.synology.me/?p=597</guid>

					<description><![CDATA[<p>백준 1449번(BAEKJOON) '수리공 항승' 문제에 대한 글입니다. 자료구조 set을 사용하여 해결하였습니다. (This is an article on the issue of 'Supervisor Hangseung' by BAEKJOON. I solved it using the data structure set.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/">백준 1449번 (수리공 항승, C++, set) [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">수리공 항승</h1>



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



<div style="height:100px" 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-6-background-color has-text-color has-background"><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">15241</td><td class="has-text-align-left" data-align="left">6921</td><td class="has-text-align-left" data-align="left">5785</td><td class="has-text-align-left" data-align="left">45.351%</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 wp-block-paragraph">항승이는 품질이 심각하게 나쁜 수도 파이프 회사의 수리공이다. <br>항승이는 세준 지하철 공사에서 물이 샌다는 소식을 듣고 수리를 하러 갔다.<br> 파이프에서 물이 새는 곳은 신기하게도 가장 왼쪽에서 정수만큼 떨어진 거리만 물이 샌다. <br>항승이는 길이가 L인 테이프를 무한 개 가지고 있다. <br>항승이는 테이프를 이용해서 물을 막으려고 한다. <br><br>항승이는 항상 물을 막을 때, <br>적어도 그 위치의 좌우 0.5만큼 간격을 줘야 물이 다시는 안 샌다고 생각한다. </p>



<p class="has-medium-font-size wp-block-paragraph">물이 새는 곳의 위치와, 항승이가 가지고 있는 테이프의 길이 L이 주어졌을 때, <br>항승이가 필요한 테이프의 최소 개수를 구하는 프로그램을 작성하시오. <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 wp-block-paragraph">첫째 줄에 물이 새는 곳의 개수 N과 테이프의 길이 L이 주어진다. <br>둘째 줄에는 물이 새는 곳의 위치가 주어진다. <br>N과 L은 1,000보다 작거나 같은 자연수이고, <br>물이 새는 곳의 위치는 1,000보다 작거나 같은 자연수이다.</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 wp-block-paragraph">첫째 줄에 항승이가 필요한 테이프의 개수를 출력한다.</p>



<div style="height:100px" 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="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4 2
1 2 100 101
</pre>



<div style="height:40px" 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="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">예제 입력 2</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 3
1 2 3 4
</pre>



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



<h2 class="has-medium-font-size wp-block-heading">예제 출력 2</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">예제 입력 3</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 1
3 2 1
</pre>



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



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



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
</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/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



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



<li>잘못된 데이터를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/tncks0121" target="_blank" rel="noreferrer noopener">tncks0121</a></li>
</ul>



<div style="height:50px" 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/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>
</ul>



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



<p class="has-medium-font-size wp-block-paragraph">파이프에서 물이 새는 곳은 가장 왼쪽에서 정수만큼 떨어진 거리<br>길이가 L인 테이프를 무한 가지고 있음<br>물을 막을 때 좌우 0.5 만큼 간격을 줘야 물이 안샘<br>물이 새는 곳의 위치와 테이프의 길이 L 이 주어졌을 때 필요한 테이프의 최소 개수<br>테이프는 자를 수 없고 겹쳐서 붙이는 것도 가능</p>



<p class="has-medium-font-size wp-block-paragraph">첫째 줄에 물이 새는 곳의 개수 N / 테이프의 길이 L<br>둘째 줄에는 물이 새는 곳의 위치 (N)</p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="1206" height="483" src="https://lycos7560.com/wp-content/uploads/image-82.png" alt="" class="wp-image-2312" srcset="https://lycos7560.com/wp-content/uploads/image-82.png 1206w, https://lycos7560.com/wp-content/uploads/image-82-300x120.png 300w, https://lycos7560.com/wp-content/uploads/image-82-768x308.png 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></figure>



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



<p class="has-medium-font-size wp-block-paragraph">물이 세는 곳은 겹치지 않고 정렬되어 들어온다는 보장도 없으니<br>위치를 set에 저장하고 테이프를 추가하는 형식으로 구현해보려고 한다.</p>



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



<h2 class="has-large-font-size wp-block-heading"><strong>데이터 입력 확인</strong></h2>



<div style="height:39px" 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>

using namespace std;

set&lt;int> myset;
set&lt;int> :: iterator iter;

int temp = 0;
int lenghtTape = 0;

void Intialization()
{
	int N = 0;
	cin >> N >> lenghtTape;
	while (N > 0)
	{
		cin >> temp;
		myset.insert(temp);
		N--;
	}
}


int main()
{
	Intialization();
    
	cout &lt;&lt; "\n";
    
	for (iter = myset.begin(); iter != myset.end(); iter++)
	{
		cout &lt;&lt; *iter &lt;&lt; " ";
	}

	return 0;
}</pre>



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



<figure class="wp-block-image size-full"><img decoding="async" width="392" height="104" src="https://lycos7560.com/wp-content/uploads/image-83.png" alt="" class="wp-image-2314" srcset="https://lycos7560.com/wp-content/uploads/image-83.png 392w, https://lycos7560.com/wp-content/uploads/image-83-300x80.png 300w" sizes="(max-width: 392px) 100vw, 392px" /></figure>



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



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



<div style="height:37px" 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>

using namespace std;

set&lt;int> myset;
set&lt;int> :: iterator iter;

int temp = 0;
int lenghtTape = 0;
int result = 0;

// 초기화 함수
void Intialization()
{
	int N = 0;
	cin >> N >> lenghtTape;
	while (N > 0)
	{
		cin >> temp;
		myset.insert(temp);
		N--;
	}
}

int main()
{
	// 조건을 초기화한다.
	Intialization();

	// 테이프가 커버 할 수 있는 끝 위치를 표시
	int pos = 0;

	// 셋에 넣어서 정렬된 물이 새는 위치를 순회한다.
	for (iter = myset.begin(); iter != myset.end(); iter++)
	{
		// 만약 새는 위치가 테이프가 커버 가능한 범위라면 넘어간다.
		if (*iter &lt;= pos)
		{
			continue;
		}

		// 테이프가 커버 가능한 위치가 아니므로 테이프를 추가하고 커버 범위를 넘겨준다.
		pos = *iter + (lenghtTape - 1);
		result++;
	}

	// 결과 출력
	cout &lt;&lt; result;
	return 0;
}</pre>



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



<p class="wp-block-paragraph"><strong>처음에는 코드를 어떻게 작성할지 막막했지만 한번 길을 잡으니 쉽게 해결됐다.</strong></p>



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



<figure class="wp-block-image size-full"><img decoding="async" width="908" height="109" src="https://lycos7560.com/wp-content/uploads/image-86.png" alt="" class="wp-image-2315" srcset="https://lycos7560.com/wp-content/uploads/image-86.png 908w, https://lycos7560.com/wp-content/uploads/image-86-300x36.png 300w, https://lycos7560.com/wp-content/uploads/image-86-768x92.png 768w" sizes="(max-width: 908px) 100vw, 908px" /></figure>



<div style="height:74px" 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-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/">백준 1449번 (수리공 항승, C++, set) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon-1449%eb%b2%88-%ec%88%98%eb%a6%ac%ea%b3%b5-%ed%95%ad%ec%8a%b9-c-set/597/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
