<?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>Programmers 17683 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/programmers-17683/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Tue, 14 Mar 2023 17:36:19 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>Programmers 17683 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Programmers 17683 [3차] 방금그곡 [2018 KAKAO BLIND RECRUITMENT]</title>
		<link>https://lycos7560.com/cpp/programmers/programmers-17683-3%ec%b0%a8-%eb%b0%a9%ea%b8%88%ea%b7%b8%ea%b3%a1-2018-kakao-blind-recruitment/33916/</link>
					<comments>https://lycos7560.com/cpp/programmers/programmers-17683-3%ec%b0%a8-%eb%b0%a9%ea%b8%88%ea%b7%b8%ea%b3%a1-2018-kakao-blind-recruitment/33916/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 12 Mar 2023 16:52:00 +0000</pubDate>
				<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[[3차] 방금그곡]]></category>
		<category><![CDATA[17683]]></category>
		<category><![CDATA[17683번]]></category>
		<category><![CDATA[2018 KAKAO BLIND RECRUITMENT]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[cstdlib]]></category>
		<category><![CDATA[Programmers 17683]]></category>
		<category><![CDATA[Programmers 17683번]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[tuple]]></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=33916</guid>

					<description><![CDATA[<p>Programmers 17683 '[3차] 방금그곡' 문제에 대한 글입니다. (Programmers 17683 This article is about the '[Third] Just Now Song' problem. ) [2018 KAKAO BLIND RECRUITMENT]</p>
<p>The post <a href="https://lycos7560.com/cpp/programmers/programmers-17683-3%ec%b0%a8-%eb%b0%a9%ea%b8%88%ea%b7%b8%ea%b3%a1-2018-kakao-blind-recruitment/33916/">Programmers 17683 [3차] 방금그곡 [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-7d914654      "
					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"><a href="https://school.programmers.co.kr/learn/courses/30/lessons/17683" target="_blank" rel="noreferrer noopener">https://school.programmers.co.kr/learn/courses/30/lessons/17683</a></p>



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



<p class="has-medium-font-size">라디오를 자주 듣는 네오는 라디오에서 방금 나왔던 음악이 무슨 음악인지 궁금해질 때가 많다. </p>



<p class="has-medium-font-size">그럴 때 네오는 다음 포털의 &#8216;방금그곡&#8217; 서비스를 이용하곤 한다. </p>



<p class="has-medium-font-size">방금그곡에서는 TV, 라디오 등에서 나온 음악에 관해 제목 등의 정보를 제공하는 서비스이다.</p>



<p class="has-medium-font-size">네오는 자신이 기억한 멜로디를 가지고 방금그곡을 이용해 음악을 찾는다. </p>



<p class="has-medium-font-size">그런데 라디오 방송에서는 한 음악을 반복해서 재생할 때도 있어서 네오가 기억하고 있는 멜로디는 </p>



<p class="has-medium-font-size">음악 끝부분과 처음 부분이 이어서 재생된 멜로디일 수도 있다. </p>



<p class="has-medium-font-size">반대로, 한 음악을 중간에 끊을 경우 원본 음악에는 네오가 기억한 멜로디가 들어있다 해도 그 곡이 네오가 들은 곡이 아닐 수도 있다. </p>



<p class="has-medium-font-size">그렇기 때문에 네오는 기억한 멜로디를 재생 시간과 제공된 악보를 직접 보면서 비교하려고 한다. </p>



<p class="has-medium-font-size">다음과 같은 가정을 할 때 네오가 찾으려는 음악의 제목을 구하여라.</p>



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



<p class="has-medium-font-size">방금그곡 서비스에서는 음악 제목, 재생이 시작되고 끝난 시각, 악보를 제공한다.</p>



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



<p class="has-medium-font-size">네오가 기억한 멜로디와 악보에 사용되는 음은 C, C#, D, D#, E, F, F#, G, G#, A, A#, B 12개이다.</p>



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



<p class="has-medium-font-size">각 음은 1분에 1개씩 재생된다. 음악은 반드시 처음부터 재생되며 음악 길이보다 재생된 시간이 길 때는 <br>음악이 끊김 없이 처음부터 반복해서 재생된다. 음악 길이보다 재생된 시간이 짧을 때는 처음부터 재생 시간만큼만 재생된다.</p>



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



<p class="has-medium-font-size">음악이 00:00를 넘겨서까지 재생되는 일은 없다.</p>



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



<p class="has-medium-font-size">조건이 일치하는 음악이 여러 개일 때에는 라디오에서 재생된 시간이 제일 긴 음악 제목을 반환한다. <br>재생된 시간도 같을 경우 먼저 입력된 음악 제목을 반환한다.</p>



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



<p class="has-medium-font-size">조건이 일치하는 음악이 없을 때에는 “(None)”을 반환한다.</p>



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



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



<p class="has-medium-font-size">입력으로 네오가 기억한 멜로디를 담은 문자열&nbsp;<code>m</code>과 방송된 곡의 정보를 담고 있는 배열&nbsp;<code>musicinfos</code>가 주어진다.</p>



<ul class="wp-block-list">
<li><code>m</code>은 음&nbsp;<code>1</code>개 이상&nbsp;<code>1439</code>개 이하로 구성되어 있다.</li>



<li><code>musicinfos</code>는&nbsp;<code>100</code>개 이하의 곡 정보를 담고 있는 배열로, 각각의 곡 정보는 음악이 시작한 시각, 끝난 시각, 음악 제목, 악보 정보가 &#8216;<code>,</code>&#8216;로 구분된 문자열이다.
<ul class="wp-block-list">
<li>음악의 시작 시각과 끝난 시각은 24시간&nbsp;<code>HH:MM</code>&nbsp;형식이다.</li>



<li>음악 제목은 &#8216;<code>,</code>&#8216; 이외의 출력 가능한 문자로 표현된 길이&nbsp;<code>1</code>&nbsp;이상&nbsp;<code>64</code>&nbsp;이하의 문자열이다.</li>



<li>악보 정보는 음&nbsp;<code>1</code>개 이상&nbsp;<code>1439</code>개 이하로 구성되어 있다.</li>
</ul>
</li>
</ul>



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



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



<p class="has-medium-font-size">조건과 일치하는 음악 제목을 출력한다.</p>



<div style="height:62px" 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">m</th><th class="has-text-align-left" data-align="left">musicinfos</th><th class="has-text-align-left" data-align="left">answer</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">&#8220;ABCDEFG&#8221;</td><td class="has-text-align-left" data-align="left">[&#8220;12:00,12:14,HELLO,CDEFGAB&#8221;, &#8220;13:00,13:05,WORLD,ABCDEF&#8221;]</td><td class="has-text-align-left" data-align="left">&#8220;HELLO&#8221;</td></tr><tr><td class="has-text-align-left" data-align="left">&#8220;CC#BCC#BCC#BCC#B&#8221;</td><td class="has-text-align-left" data-align="left">[&#8220;03:00,03:30,FOO,CC#B&#8221;, &#8220;04:00,04:08,BAR,CC#BCC#BCC#B&#8221;]</td><td class="has-text-align-left" data-align="left">&#8220;FOO&#8221;</td></tr><tr><td class="has-text-align-left" data-align="left">&#8220;ABC&#8221;</td><td class="has-text-align-left" data-align="left">[&#8220;12:00,12:14,HELLO,C#DEFGAB&#8221;, &#8220;13:00,13:05,WORLD,ABCDEF&#8221;]</td><td class="has-text-align-left" data-align="left">&#8220;WORLD&#8221;</td></tr></tbody></table></figure>



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



<h3 class="wp-block-heading">설명</h3>



<p>첫 번째 예시에서 HELLO는 길이가 7분이지만 12:00부터 12:14까지 재생되었으므로 실제로 CDEFGABCDEFGAB로 재생되었고, 이 중에 기억한 멜로디인 ABCDEFG가 들어있다.<br>세 번째 예시에서 HELLO는 C#DEFGABC#DEFGAB로, WORLD는 ABCDE로 재생되었다. HELLO 안에 있는 ABC#은 기억한 멜로디인 ABC와 일치하지 않고, WORLD 안에 있는 ABC가 기억한 멜로디와 일치한다.</p>



<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;vector>
#include &lt;algorithm>
#include &lt;tuple>


using namespace std;

string DistinguishMelody(string m) // # 부분을 처리
{
    string str;
    for (int i = m.length() - 1; i >= 0; i--) {
        if (m[i] == '#') {
            str.push_back(m[i - 1] + 32);
            i--;
        }
        else str.push_back(m[i]);
    }
    reverse(str.begin(), str.end());
    return str;
}

tuple&lt;string, string, int> Slicing(string str)
{
    int startH = atoi(str.substr(0, 2).c_str());
    int endH = atoi(str.substr(6, 2).c_str());
    int startM = atoi(str.substr(3, 2).c_str());
    int endM = atoi(str.substr(9, 2).c_str());
    int resInt = (endH - startH) * 60 + (endM - startM);
    string str2 = str.substr(12, str.length() - 1);
    int pv = 0;
    for (int i = 0; i &lt; str2.length(); i++) {
        if (str2[i] == ',') {
            pv = i;
            break;
        }
    }
    string name = str2.substr(0, pv);
    string melody = DistinguishMelody(str2.substr(pv + 1, str.length() - 1));
    int cnt = melody.length();
    for (int i = melody.length(); i &lt; resInt; i++) {
        melody.push_back(melody[i % cnt]);
    }
    melody = melody.substr(0, resInt);

    tuple&lt;string, string, int> res = make_tuple(name, melody, resInt);
    return res;
}

string solution(string m, vector&lt;string> musicinfos) {
    string answer = "";
    m = DistinguishMelody(m);
    int answerlength = 0;
    for (auto &amp;it : musicinfos) {
        tuple&lt;string, string, int> res = Slicing(it);
        string str = get&lt;1>(res);

        for (int i = 0; i &lt; str.length(); i++) {
           for (int j = 0; j &lt; m.length(); j++) {
              if (str[j + i] != m[j]) break;
              if (j == m.length() - 1) {
                  if (get&lt;2>(res) > answerlength) {
                      answerlength = get&lt;2>(res);
                      answer = get&lt;0>(res);
                  }
              }
           }
        }
    }
    
    if (answerlength == 0) answer = "(None)";

    return answer;
}</pre>



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



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



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="709" height="785" src="https://lycos7560.com/wp-content/uploads/2023/03/image-46.png" alt="" class="wp-image-33918" srcset="https://lycos7560.com/wp-content/uploads/2023/03/image-46.png 709w, https://lycos7560.com/wp-content/uploads/2023/03/image-46-271x300.png 271w" sizes="(max-width: 709px) 100vw, 709px" /></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/programmers/programmers-17683-3%ec%b0%a8-%eb%b0%a9%ea%b8%88%ea%b7%b8%ea%b3%a1-2018-kakao-blind-recruitment/33916/">Programmers 17683 [3차] 방금그곡 [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-17683-3%ec%b0%a8-%eb%b0%a9%ea%b8%88%ea%b7%b8%ea%b3%a1-2018-kakao-blind-recruitment/33916/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
