<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>컴영의 기록지</title>
    <link>https://comyoung.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Tue, 28 Jul 2026 14:02:23 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>컴영</managingEditor>
    <image>
      <title>컴영의 기록지</title>
      <url>https://tistory1.daumcdn.net/tistory/3789458/attach/b2c124d25ba34b8098763eae08b452c3</url>
      <link>https://comyoung.tistory.com</link>
    </image>
    <item>
      <title>[프로그래머스] 스티커 모으기(2)</title>
      <link>https://comyoung.tistory.com/292</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;스티커 모으기(2)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;문제)&amp;nbsp;https://programmers.co.kr/learn/courses/30/lessons/12971&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;background-color: rgb(250, 236, 197);&quot;&gt;dp&lt;/span&gt;&lt;/b&gt;를 이용해서 풀어야 하는 문제다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;점화식&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;dp[i] = i번째 스티커를 뗄 경우, 지금까지 얻을 수 있었던 점수의 최대값&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;dp[i] = max(dp[i-2] + sticker[i], dp[i-1])&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//i번째 스티커를 뗄 경우, i-2번째 스티커를 뜯어낸 후 합쳐왔던 점수에 i번째 스티커 점수 합침&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; i번째 스티커를 떼지 않을 경우, i-1번째&amp;nbsp;스티커를 뜯어낸 후 합쳐왔던 점수 가져옴&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(152, 0, 0);&quot;&gt;* 주의점 *&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;원형으로 연결되어 있기에, 첫번째 스티커를 뜯어낼 경우 마지막 스티커를 뜯지 못한다.&lt;/p&gt;&lt;p&gt;이를 위해&amp;nbsp;첫번째 스티커를 뜯었을 경우와 아닐 경우를 나눠서 계산해본다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드)&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt;&lt;p style=&quot;color: rgb(147, 161, 161);&quot;&gt;&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;include &amp;lt;algorithm&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;vector&amp;gt;
&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot; style=&quot;box-sizing: border-box; color: rgb(38, 139, 210);&quot;&gt;solution&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//0번째 스티커 제거 -&amp;gt; 마지막 스티커 제거 못함&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt; &lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//0번째 제거 시 1번째는 제거 못함&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//i번째 스티커를 제거할 경우, 제거하지 않을 경우&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;

    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()); &lt;/span&gt;&lt;span style=&quot;color: rgb(88, 110, 117); letter-spacing: -0.144px;&quot;&gt;//dp 배열 재사용&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;&quot;&gt;
    &lt;span class=&quot;c1&quot; style=&quot;color: rgb(88, 110, 117); box-sizing: border-box;&quot;&gt;//0번째 스티커 제거 안함 -&amp;gt; 마지막 스티커 제거 가능&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
    &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
    &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;];&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
    &lt;/font&gt;&lt;span class=&quot;k&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;color: rgb(220, 50, 47); box-sizing: border-box;&quot;&gt;int&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;();&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;){&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
        &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;+&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;],&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;]);&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
    &lt;/font&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;

    &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;=&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; max(answer, &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;sticker&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;color: rgb(42, 161, 152); box-sizing: border-box;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;

    &lt;/font&gt;&lt;span class=&quot;k&quot; style=&quot;color: rgb(133, 153, 0); box-sizing: border-box;&quot;&gt;return&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt; &lt;/font&gt;&lt;span class=&quot;n&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;font color=&quot;#93a1a1&quot;&gt;
&lt;/font&gt;&lt;span class=&quot;p&quot; style=&quot;color: rgb(147, 161, 161); box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>DP</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/292</guid>
      <comments>https://comyoung.tistory.com/292#entry292comment</comments>
      <pubDate>Fri, 2 Oct 2020 17:56:27 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] JadenCase 문자열 만들기</title>
      <link>https://comyoung.tistory.com/291</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Jaden&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Case 문자열 만들기&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제)&amp;nbsp;https://programmers.co.kr/learn/courses/30/lessons/12951&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;&lt;b&gt;A의 아스키 코드가 65, a의 아스키 코드가 97 임을 이용해서 소문자↔대문자를 바꿔줬는데&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding: 6px; border-right: 2px solid rgb(79, 79, 79); height: 600px;&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding: 6px 0px; text-align: left; height: 600px;&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;string&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;vector&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;std;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;string&amp;nbsp;solution(string&amp;nbsp;s)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//A&amp;nbsp;65&amp;nbsp;a&amp;nbsp;97&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(s[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'a'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;s[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'z'&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;32&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;i&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;s.length();i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(s[i&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'&amp;nbsp;'&lt;/span&gt;){&lt;span style=&quot;color:#999999&quot;&gt;//공백다음&amp;nbsp;문자&amp;nbsp;-&amp;gt;&amp;nbsp;소문자일&amp;nbsp;경우&amp;nbsp;대문자로&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'a'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'z'&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;32&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;{&lt;span style=&quot;color:#999999&quot;&gt;//문자&amp;nbsp;내의&amp;nbsp;대문자일&amp;nbsp;경우&amp;nbsp;소문자로&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'A'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Z'&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;32&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; height: 600px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;tolower(), toupper()함수를 이용하면 더 쉽게 코드를 작성할 수 있었다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(5, 0, 153);&quot;&gt;#include &amp;lt;ctype.h&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(5, 0, 153);&quot;&gt;int tolower(int C) // 대문자 C를 소문자로 바꿔준다.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(5, 0, 153);&quot;&gt;int toupper(int c) //소문자 c를 대문자로 바꿔준다.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;string&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;std;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;string&amp;nbsp;solution(string&amp;nbsp;s)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;toupper(s[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;s.length();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(s[i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'&amp;nbsp;'&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;toupper(s[i]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;tolower(s[i]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>tolower</category>
      <category>toupper</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/291</guid>
      <comments>https://comyoung.tistory.com/291#entry291comment</comments>
      <pubDate>Thu, 1 Oct 2020 16:47:20 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 쿠키 구입</title>
      <link>https://comyoung.tistory.com/290</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;쿠키구입&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;문제) https://programmers.co.kr/learn/courses/30/lessons/49995&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(0, 51, 153);&quot;&gt;투포인터&lt;/span&gt;&lt;/b&gt;를 이용해서 푼 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;과정&lt;/p&gt;&lt;p&gt;1.&amp;nbsp;for문을 통해 인덱스 0 ~ cookie.size() - 2&amp;nbsp;까지 차례로&amp;nbsp;&lt;b&gt;시작 인덱스 start &lt;/b&gt;로&amp;nbsp;정한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;1.1. 시작인덱스 start + 1 을 &lt;b&gt;마지막 인덱스 end &lt;/b&gt;로 둔다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;1.2. &lt;b&gt;(0 ~ 시작 인덱스 start)&lt;/b&gt; /&lt;b&gt; (마지막 인덱스 end&amp;nbsp;~ cookie.size() - 1)&amp;nbsp;&lt;/b&gt; 범위로 나눠&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; start와 end 두&amp;nbsp;인덱스 포인터를 이동시키며 두 쿠기 구간의 합을 비교한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*&lt;b&gt;start 포인터는 왼쪽&lt;/b&gt;으로 이동, &lt;b&gt;end 포인터는 오른쪽&lt;/b&gt;으로 이동한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*&lt;b&gt;오른쪽 구간의 합이 크면, 왼쪽 구간을 늘린다 = start 포인터를 한칸 왼쪽으로 이동&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*&lt;b&gt;왼쪽 구간의 합이 크면, 오른쪽 구간을 늘린다 = end 포인터를 한칸 오른쪽으로 이동&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; color: rgb(147, 161, 161); padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt;&lt;p&gt;&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot; style=&quot;box-sizing: border-box; color: rgb(38, 139, 210);&quot;&gt;solution&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
       &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
       &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
       &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
       &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
       &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
           &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
               &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
           &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
           &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
               &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
           &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
           &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;start_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
               &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end_sum&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
           &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
           &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
       &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
   &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>투포인터</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/290</guid>
      <comments>https://comyoung.tistory.com/290#entry290comment</comments>
      <pubDate>Wed, 30 Sep 2020 17:37:32 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 캠핑</title>
      <link>https://comyoung.tistory.com/289</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;캠핑&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제)&lt;/p&gt;&lt;p&gt;https://programmers.co.kr/learn/courses/30/lessons/1833#&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;처음에 서로 대각선에 위치해 있는 쐐기들만 골라서 텐트를 쳐야하는지 착각해서 헤맸던 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;과정&lt;/p&gt;&lt;p&gt;&lt;b&gt;1. 쐐기의 좌표들을 &lt;span style=&quot;color: rgb(0, 51, 153);&quot;&gt;오름차순&lt;/span&gt;으로 정렬해준다.&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. 각 쐐기마다 다른 쐐기들과 비교하여 텐트를 칠 수 있는지 확인해준다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; =&amp;gt; &lt;span style=&quot;color: rgb(0, 51, 153);&quot;&gt;삼중포문&lt;/span&gt;을 이용해서 풀어줬다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt;for(int i=0; i&amp;lt;data.size(); i++) &lt;/b&gt;//기준 쐐기 위치 {y,x}&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;b&gt;for(int j=i+1; j&amp;lt;data.size(); j++) &lt;/b&gt;//비교할 쐐기 위치 {ty,tx}&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;for(int k=i+1; k&amp;lt;j; k++)&lt;/b&gt; //기준쐐기와 비교할 쐐기 사이에 존재하는&amp;nbsp;쐐기 위치 {ky,kx}&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 만약 &lt;b&gt;중간에 존재하는 쐐기{ky,kx}&lt;/b&gt;가 &lt;b&gt;기준쐐기와 비교할 쐐기가 이루는 직사각형 범위 내에 존재하면&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 기준 쐐기 {y,x}와 비교할 쐐기{ty,tx}는 쌍을 이루지 못한다.&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;코드)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;전역&amp;nbsp;변수를&amp;nbsp;정의할&amp;nbsp;경우&amp;nbsp;함수&amp;nbsp;내에&amp;nbsp;초기화&amp;nbsp;코드를&amp;nbsp;꼭&amp;nbsp;작성해주세요.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;data)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sort(data.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),data.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;());&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;data.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;******확인&amp;nbsp;좌표&amp;nbsp;:&quot;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;y&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;&amp;nbsp;,&quot;&amp;nbsp;&amp;lt;&amp;lt;x&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;j&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;data.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();j&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;ty&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[j][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;tx&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[j][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(ty&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;tx&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;x)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;span style=&quot;color:#999999&quot;&gt;//같은&amp;nbsp;라인에&amp;nbsp;있으면&amp;nbsp;직사각형의&amp;nbsp;넓이&amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;&amp;nbsp;-&quot;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;ty&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;,&amp;nbsp;&quot;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;tx&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;suc&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;j;&amp;nbsp;k&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;span style=&quot;color:#999999&quot;&gt;//{y,x}&amp;nbsp;와&amp;nbsp;{ty,tx}사이에&amp;nbsp;있으면서&amp;nbsp;같은&amp;nbsp;영역내에&amp;nbsp;있는가&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;ky&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[k][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;kx&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;data[k][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;((y&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;ky&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;ky&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;ty)){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(min(x,tx)&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;kx&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;kx&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;max(x,tx))&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;suc&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(suc)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;성공&quot;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/289</guid>
      <comments>https://comyoung.tistory.com/289#entry289comment</comments>
      <pubDate>Tue, 29 Sep 2020 14:57:20 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 보석 쇼핑</title>
      <link>https://comyoung.tistory.com/288</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;보석 쇼핑&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;처음에는&lt;/p&gt;&lt;p&gt;인덱스 0부터 ~ 모든 보석을 포함하는 마지막 인덱스를 찾고, 그 안에서 구간을 줄여나가면서 풀었더니&lt;/p&gt;&lt;p&gt;틀렸던 문제다.&lt;/p&gt;&lt;p&gt;예외 존재) [&quot;DIA&quot;,&quot;EM&quot;,&quot;EM&quot;,&quot;RUB&quot;,&quot;DIA&quot;] 일경우&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&amp;nbsp; answer = [3, 5]&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&amp;nbsp; output = [1, 4] 가 나옴&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그렇다고 2중 포문을 사용해서 구간을 찾기에는 보석 배열이 100,000 크기까지 될 수 있으므로 시간초과가 생긴다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;=&amp;gt; &lt;b&gt;&lt;span style=&quot;background-color: rgb(250, 236, 197);&quot;&gt;투포인터 방법&lt;/span&gt;&lt;/b&gt;을 사용해서 풀어야 하는 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;unordered_map, 투 포인터 사용 풀이법&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;1. 먼저 보석의 총 개수를 unordered_map을 이용해서 구한다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. left, right 두 개의 인덱스 포인터를 이용해서 가장 짧은 구간을 찾는다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;-&amp;gt; left와 right 인덱스를 조건을 생각하며 한칸씩 이동시켜&amp;nbsp;모든 보석을 포함하는 구간을 찾는다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; (구간 내에 모든 보석이 포함되있는지는&lt;b&gt; unordered_map&lt;/b&gt;을 이용해서 판단한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;unordered_map 사이즈가 보석의 총 개수와 같다면, 그 구간내에 모든 보석이 포함되어 있다는 뜻이다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;44&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;45&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;46&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;47&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;48&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;49&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;50&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;51&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;52&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;53&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;54&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;55&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;56&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;57&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;58&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;59&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;60&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;61&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;62&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;63&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;64&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;unordered_map&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;gems)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;unordered_map&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;,&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;juwel;&lt;span style=&quot;color:#999999&quot;&gt;//맨&amp;nbsp;처음에는&amp;nbsp;보석&amp;nbsp;종류구하는&amp;nbsp;용도&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;두번째에는&amp;nbsp;구간내에&amp;nbsp;보석&amp;nbsp;종류&amp;nbsp;빈도&amp;nbsp;구하는&amp;nbsp;용도&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;kind&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color:#999999&quot;&gt;//보석&amp;nbsp;종류&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;gems.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(juwel.find(gems[i])&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;juwel.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;()){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;juwel[gems[i]]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;kind&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;kind&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(kind&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;){&lt;span style=&quot;color:#999999&quot;&gt;//보석이&amp;nbsp;한&amp;nbsp;종류뿐일때&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(kind&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;gems.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;()){&lt;span style=&quot;color:#999999&quot;&gt;//각각&amp;nbsp;모두&amp;nbsp;다른&amp;nbsp;보석일때&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(gems.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;());&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;juwel.clear();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;left&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;,&amp;nbsp;right&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;result&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;987654321&lt;/span&gt;;&lt;span style=&quot;color:#999999&quot;&gt;//나올&amp;nbsp;수&amp;nbsp;없는&amp;nbsp;구간&amp;nbsp;거리&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;left&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;,&amp;nbsp;&quot;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;right&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(juwel.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;kind){//보석이 모든 종류가 포함되어 있을 때&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;juwel[gems[left]]&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;; //맨 왼쪽 인덱스의 보석 하나 제외&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(juwel[gems[left]]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;gems[left]&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;삭제&amp;nbsp;&quot;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;juwel.erase(gems[left]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;left&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(right&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;gems.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;())&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;juwel[gems[right]]&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;//맨 오른쪽 인덱스 보석 포함&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;right&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(juwel.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;kind){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;per&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;abs(right&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;left);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(result&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;per){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;per;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;left&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;right;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>two pointer</category>
      <category>unordered_set</category>
      <category>unorered_map</category>
      <category>투포인터</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/288</guid>
      <comments>https://comyoung.tistory.com/288#entry288comment</comments>
      <pubDate>Mon, 28 Sep 2020 15:22:42 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 수식 최대화</title>
      <link>https://comyoung.tistory.com/287</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;수식 최대화&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제)&lt;/p&gt;&lt;p&gt;https://programmers.co.kr/learn/courses/30/lessons/67257&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;next_permutation으로 연산자의 우선순위를 바꿔주면서 푼 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; color: rgb(147, 161, 161); padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt;&lt;p&gt;&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;algorithm&amp;gt;
&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cardi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;// + - *&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;nf&quot; style=&quot;box-sizing: border-box; color: rgb(38, 139, 210);&quot;&gt;solution&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'+'&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cardi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;));&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'-'&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cardi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;));&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'*'&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cardi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;));&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cardi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_oper&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;

                &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;

                    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//+&lt;/span&gt;
                        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;= &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
                    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{//-&lt;/span&gt;
                        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
                    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//*&lt;/span&gt;
                        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
                    }&lt;/p&gt;&lt;p style=&quot;margin-left: 10em;&quot;&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;erase&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p&gt;                    &lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;erase&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;t_oper&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;letter-spacing: -0.144px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;j--&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;letter-spacing: -0.144px; box-sizing: border-box;&quot;&gt;);//j 줄여줌. 연산자 개수 하나줄었으므로&lt;/span&gt;
                &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;t_number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_permutation&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()));&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;+ 숫자와 연산자 저장할 때 &lt;b&gt;substr&lt;/b&gt;을 이용한 간단한 방법&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; color: rgb(147, 161, 161); padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt;&lt;p&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;    int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'*'&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'+'&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;'-'&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
            oper&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;);&lt;/span&gt;
            number&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)));&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;stoi&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;substr&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)));&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;/p&gt;&lt;/pre&gt;&lt;div&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;+ next_permutation을 사용하지 말고 그냥 &lt;b&gt;연산자 우선순위를 따로 저장해서 사용하는&lt;/b&gt; 방법(연산자 3개를 default로 둔다)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; color: rgb(147, 161, 161); padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;prior&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;*+-&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;*-+&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;+*-&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;+-*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; 
        &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;-*+&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;&quot;-+*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/287</guid>
      <comments>https://comyoung.tistory.com/287#entry287comment</comments>
      <pubDate>Sat, 26 Sep 2020 18:42:05 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 경주로 건설</title>
      <link>https://comyoung.tistory.com/286</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;경주로 건설&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;문제) https://programmers.co.kr/learn/courses/30/lessons/67259&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;헤매다가 질문글을 보고 오류를 찾은 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;참고 질문글)&amp;nbsp;https://programmers.co.kr/questions/12180&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;PQ와 DP&lt;/b&gt;를 이용하고, 새로운 비용이 작거나 같을&amp;nbsp;경우만 무조건 업데이트 시키면서 이동가능하게 했었는데&lt;/p&gt;&lt;p&gt;이동 방향에 따라 비용의 대소가 역전되는 경우가 있었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 DP를 이용할 때 &lt;b&gt;방향&lt;/b&gt;까지 저장해서 풀었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;int dp[i][j][k] = (i,j)위치에 k방향으로 도달했을 때까지 든&amp;nbsp;최소 비용&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;과정&lt;/p&gt;&lt;p&gt;1. 비용을 Memoization할 배열을 모두 나올 수 없는 최대 비용으로 초기화.( INF = 987654321 )&lt;/p&gt;&lt;p&gt;2. 처음 출발할 칸 즉, (0,0)위치의 배열 값은 0으로 초기화.&lt;/p&gt;&lt;p&gt;3. PQ를 이용해서 비용을 갱신하며 이동.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* 코너&amp;nbsp;판단은 따로 bool 함수를 선언해서 해줬다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;방향이 상 0 하 1 인데 이동할 방향이 좌 2 , 우 3 이면 코너를 만들었다고&amp;nbsp;판단.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;p&gt;4. (n-1, n-1)위치의 배열 값 중 최소값을 answer에 저장하여 return.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;box-sizing: border-box; font-family: Hack, Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace, &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, Dotum, sans-serif; font-size: 14px; margin-top: 0px; margin-bottom: 0px; overflow: auto; color: rgb(147, 161, 161); padding: 0px; word-break: break-all; overflow-wrap: break-word; background: none rgb(38, 55, 71); border: none; border-radius: 0.25rem; line-height: 1.625rem; letter-spacing: -0.144px;&quot;&gt;&lt;p&gt;&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;queue&amp;gt;
&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;cp&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;#define INF 987654321
&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dy&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;curve&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d2&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d1&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d1&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;c1&quot; style=&quot;box-sizing: border-box; color: rgb(88, 110, 117);&quot;&gt;//상하&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;d2&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot; style=&quot;box-sizing: border-box; color: rgb(181, 137, 0);&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{}&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cmp&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;operator&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;()(&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot; style=&quot;box-sizing: border-box; color: rgb(38, 139, 210);&quot;&gt;solution&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;INF&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;INF&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;priority_queue&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;Info&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cmp&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dy&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;

            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;curve&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_cost&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt;  &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_cost&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;qu&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;next_cost&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;});&lt;/span&gt;
            &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;box-sizing: border-box; color: rgb(220, 50, 47);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt; &lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;dp&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;box-sizing: border-box; color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot; style=&quot;box-sizing: border-box; color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot; style=&quot;box-sizing: border-box;&quot;&gt;answer&lt;/span&gt;&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot; style=&quot;box-sizing: border-box;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>DP</category>
      <category>priority queue</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/286</guid>
      <comments>https://comyoung.tistory.com/286#entry286comment</comments>
      <pubDate>Fri, 25 Sep 2020 18:01:02 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 동굴 탐험</title>
      <link>https://comyoung.tistory.com/285</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;동굴 탐험&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제) https://programmers.co.kr/learn/courses/30/lessons/67260&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;처음에&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;dfs(방 탐색시 이용),&lt;/b&gt;&amp;nbsp;&lt;b&gt;before[]배열(이전에 꼭 방문해야하는 방 번호 저장), parent[]배열(트리 상에서 자식보다 먼저 방문해야하는 방 번호 저장)&lt;/b&gt;&amp;nbsp;을 이용해서 풀어보았지만&amp;nbsp;효율성면에서 떨어져서 다르게 풀어야했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;효율성을 통과하지 못한 코드)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;44&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;45&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;46&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;47&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;48&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;49&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;50&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;51&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;52&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;53&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;54&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;55&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;56&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;57&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;58&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;59&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;60&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;61&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;62&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;63&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;64&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;65&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;66&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;67&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;.h&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;adj[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;before[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;visited[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;parent[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;void&lt;/span&gt;&amp;nbsp;get_parent(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;here)&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//트리상에서&amp;nbsp;부모번호를&amp;nbsp;저장하는&amp;nbsp;함수&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;adj[here].&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;next&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;adj[here][i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(parent[next]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent[next]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;here;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get_parent(next);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;void&lt;/span&gt;&amp;nbsp;dfs(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;here)&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//다음&amp;nbsp;정점을&amp;nbsp;방문처리하는 함수&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[here]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cnt&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;adj[here].&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;next&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;adj[here][i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(visited[next]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;visited[before[next]])&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dfs(next);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;path,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;order)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;path.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;path[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;path[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adj[a].&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(b);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adj[b].&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(a);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;order.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;order[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;order[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;before[b]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;a;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;div style=&quot;padding: 0px 6px; line-height: 19.5px;&quot;&gt;&lt;span style=&quot;color: rgb(255, 51, 153);&quot;&gt;   if&lt;/span&gt;(before[&lt;span style=&quot;color: rgb(193, 10, 255);&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: rgb(170, 255, 170);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 51, 153);&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: rgb(170, 255, 170);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(193, 10, 255);&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: rgb(255, 51, 153);&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(255, 51, 153);&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;memset(parent,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;sizeof&lt;/span&gt;(parent));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get_parent(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dfs(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;result_cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;cnt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;visited[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;visited[before[i]]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;visited[parent[i]])&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dfs(i);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result_cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;cnt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(result_cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n)&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 &lt;b&gt;bfs&lt;/b&gt; 방법을 사용하고 &lt;b&gt;before[]배열과 after[]배열(다음에 방문해야하는 방 번호)&lt;/b&gt;을 사용해줬다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;효율성&amp;nbsp;통과한 코드)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;44&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;45&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;46&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;47&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;48&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;49&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;50&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;51&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;52&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;53&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;54&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;55&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;56&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;57&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;58&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;string&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;queue&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;string.h&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;#include&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;std;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;vector&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;adj[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;before[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;visited[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;after[&lt;span style=&quot;color:#c10aff&quot;&gt;200001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;path,&amp;nbsp;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;vector&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;order)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a,b;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;path.size();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;path[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;path[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adj[a].push_back(b);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;adj[b].push_back(a);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;order.size();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;order[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;order[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;before[b]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;a;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(before[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;queue&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;qu;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;adj[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;].size();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push(adj[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;][i]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;(&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;qu.empty()){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;here&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;qu.front();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.pop();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(visited[here])&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;visited[before[here]]){&lt;span style=&quot;color:#999999&quot;&gt;//이전에&amp;nbsp;들려어야하는&amp;nbsp;곳을&amp;nbsp;아직&amp;nbsp;방문&amp;nbsp;안했다면&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;after[before[here]]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;here;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;here&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&quot;-&amp;gt;&amp;nbsp;&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[here]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;adj[here].size();i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;next&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;adj[here][i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push(next);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push(after[here]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;n;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;visited[i]){&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;answer;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(204, 61, 61);&quot;&gt;참고사항&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;자꾸 테스트케이스 30번 틀리는 경우!&lt;/p&gt;&lt;p&gt;-&amp;gt; 동굴을 들어가는 입구는 0번 방과 연결되어 있어서, 시작은 무조건 0번 방부터 해야하나&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; order배열 중에 0번 방으로 입장 전에 다른 방 번호를 먼저 방문해야한다는 케이스가&amp;nbsp;들어있을 수 있다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; 이때는 바로 false를 return 해주도록 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>tree</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/285</guid>
      <comments>https://comyoung.tistory.com/285#entry285comment</comments>
      <pubDate>Thu, 24 Sep 2020 15:46:40 +0900</pubDate>
    </item>
    <item>
      <title>[프로그래머스] 단어 퍼즐</title>
      <link>https://comyoung.tistory.com/284</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;단어 퍼즐&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;문제)&amp;nbsp;https://programmers.co.kr/learn/courses/30/lessons/12983&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;풀이)&lt;/p&gt;&lt;p&gt;처음에 &lt;b&gt;BFS&lt;/b&gt;를 이용해서 풀었으나 효율성을 통과하지 못했다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;효율성 통과 x 코드)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;cmp(&lt;span style=&quot;color:#ff3399&quot;&gt;const&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;a,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;const&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;b)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;a.length()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;b.length();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;strs,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;t)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sort(strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),&amp;nbsp;strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;(),&amp;nbsp;cmp);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;qu;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;check(t.length(),&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;cnt&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;qu.empty())&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;compare&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;front&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;pop&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(compare&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;t)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;cnt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;next&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;compare&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;strs[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(check[next.length()])&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(next.length()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;t.length()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;t.substr(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;next.length())&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;next)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;check[next.length()]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push(next);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cnt&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래서 다른 분의 글을 참고해서&lt;b&gt; &lt;span style=&quot;background-color: rgb(250, 236, 197);&quot;&gt;재귀적 dp&lt;/span&gt;&lt;/b&gt;로 풀었다.(최단 비용 도로 개수 구하는 방법처럼)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;효율성 통과 o 코드)&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;44&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#define&lt;/span&gt;&amp;nbsp;INF&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;987654321&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;dp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;cmp(&lt;span style=&quot;color:#ff3399&quot;&gt;const&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;a,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;const&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;b)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;a.length()&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;b.length();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dfs(&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;strs,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;len)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(len&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;t.length())&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(dp[len]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;dp[len];&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//이전에&amp;nbsp;계산한&amp;nbsp;값이&amp;nbsp;존재&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dp[len]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;INF;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;i&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(strs[i].length()&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;len&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;t.length())&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;strs[i].&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;();&amp;nbsp;j&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(t[len&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;j]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;strs[i][j])&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;(flag)&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dp[len]&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;min(dp[len],&amp;nbsp;dfs(strs,&amp;nbsp;t,&amp;nbsp;strs[i].length()&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;len)&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;dp[len];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;solution(&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;strs,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;t)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sort(strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),&amp;nbsp;strs.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;(),&amp;nbsp;cmp);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dp.assign(t.length(),&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;dfs(strs,&amp;nbsp;t,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;INF&amp;nbsp;?&amp;nbsp;&lt;span style=&quot;color:#aaffaa&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;dp[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>DP</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/284</guid>
      <comments>https://comyoung.tistory.com/284#entry284comment</comments>
      <pubDate>Wed, 23 Sep 2020 17:25:46 +0900</pubDate>
    </item>
    <item>
      <title>[백준] 2842번 집배원 한상덕</title>
      <link>https://comyoung.tistory.com/279</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;2842 집배원 한상덕&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(88, 95, 105); font-size: 22px; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(88, 95, 105); font-size: 22px; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;문제&lt;/span&gt;&lt;/p&gt;&lt;hr&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;상덕이는 언덕 위에 있는 마을의 우체국에 직업을 얻었다. 마을은 N×N 행렬로 나타낼 수 있다. 행렬로 나뉘어진 각 지역은 우체국은 'P', 집은 'K', 목초지는 '.' 중 하나로 나타낼 수 있다. 또, 각 지역의 고도도 알고 있다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;매일 아침 상덕이는 마을의 모든 집에 우편을 배달해야 한다. 배달은 마을에 하나밖에 없는 우체국 'P'가 있는 곳에서 시작한다. 상덕이는 현재 있는 칸과 수평, 수직, 대각선으로 인접한 칸으로 이동할 수 있다. 마지막 편지를 배달하고 난 이후에는 다시 우체국으로 돌아와야 한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;상덕이는 이렇게 매일 아침 배달을 하는 것이 얼마나 힘든지 궁금해졌다. 상덕이가 배달하면서 방문한 칸 중 가장 높은 곳과 낮은 곳의 고도 차이를 피로도라고 하자. 이때, 가장 작은 피로도로 모든 집에 배달을 하려면 어떻게 해야 하는지 구하는 프로그램을 작성하시오.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(88, 95, 105); font-size: 22px; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(88, 95, 105); font-size: 22px; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;입력&lt;/span&gt;&lt;/p&gt;&lt;hr&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;첫째 줄에 N이 주어진다. (2 ≤ N ≤ 50)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;다음 N개 줄에는 마을을 나타내는 행렬이 주어진다. 'P'는 한 번만 주어지며, 'K'는 적어도 한 번 주어진다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;다음 N개 줄에는 행렬로 나뉘어진 지역의 고도가 행렬 형태로 주어진다. 고도는 1,000,000보다 작거나 같은 자연수이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(88, 95, 105); font-size: 22px; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;출력&lt;/span&gt;&lt;/p&gt;&lt;hr&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(85, 85, 85); font-size: medium; font-family: &amp;quot;Open Sans&amp;quot;, &amp;quot;Apple SD Gothic Neo&amp;quot;, &amp;quot;Noto Sans CJK KR&amp;quot;, &amp;quot;Noto Sans KR&amp;quot;, 나눔바른고딕, 나눔고딕, 맑은고딕, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif;&quot;&gt;첫째 줄에 가장 작은 피로도를 출력한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;hr class=&quot;tx-hr-image-3&quot; style=&quot;background: url(//i1.daumcdn.net/deco/contents/horizontalrule/line06.gif?v=2) repeat-x scroll left; height: 15px; border:0&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;풀이)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;1981번 배열에서의 이동문제처럼&lt;/span&gt;&lt;/p&gt;&lt;p&gt;이분탐색을 이용해서&amp;nbsp;풀어보려했으나, 범위 값 설정의 어려움으로&amp;nbsp;&lt;/p&gt;&lt;p&gt;계속 틀려서 결국 다른 분 풀이의 도움을 받았다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;background-color: rgb(250, 236, 197);&quot;&gt;두 개의 포인터와 bfs&lt;/span&gt;&lt;/b&gt;를 이용해서 풀 수 있다.(bfs말고 dfs를 이용해도 된다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;과정&lt;/p&gt;&lt;p&gt;&lt;b&gt;1. 고도 값들을 따로 저장한 다음에 그것들을 오름차순으로 정렬한 뒤, 중복된 고도 값은&amp;nbsp;없애준다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. 고도값을 저장한 벡터를 height[]라고 할때,&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; 초기 left 와 right는 0으로 두고&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: rgb(0, 51, 153);&quot;&gt;상원이가 이동할 수 있는 고도 값의 범위를 height[left&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 51, 153);&quot;&gt;] ~ height[right]&lt;/span&gt;라고 한다.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;b&gt;&amp;nbsp;while(right &amp;lt; height.size()){&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;b&gt;while(1){&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;//상원이가 height[left] ~ height[right] 범위의 고도들만 이동해서&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;&amp;nbsp; 모든 집에 우편을 배달할 수 있는지 체크&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;배달할 수 있을 경우 :&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 16em;&quot;&gt;&lt;b&gt;피로도를 계산(height[right] - height[left])&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 16em;&quot;&gt;&lt;b&gt;고도값 범위의 낮은 고도 가리키는 인덱스를 높여준다 left++;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 6em;&quot;&gt;&lt;b&gt;없을 경우 :&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 10em;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; break;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;&lt;b&gt;고도값 범위의 높은 고도 가리키는 인덱스를 높여준다. right++;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;ex) 그림으로 예를 들어서 보면&lt;/p&gt;&lt;pre class=&quot;sampledata&quot; id=&quot;sample-input-1&quot; style=&quot;box-sizing: border-box; border-radius: 5px; overflow: scroll auto; font-family: Menlo, Monaco, &amp;quot;Source Code Pro&amp;quot;, consolas, monospace; font-size: 18px; padding: 8px; margin-top: 0px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: normal; overflow-wrap: normal; background-color: rgb(247, 247, 249); border: 1px solid rgb(225, 225, 232);&quot;&gt;3
K.P
...
K.K
3 3 4
9 5 9
8 3 7&lt;/pre&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 225px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99F4C7475F647D8B0D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99F4C7475F647D8B0D&quot; width=&quot;225&quot; height=&quot;200&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;이니깐,&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;초기 height와 left, right는&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 225px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99AE10475F647D8B08&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99AE10475F647D8B08&quot; width=&quot;225&quot; height=&quot;206&quot; filename=&quot;캡처2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;다음과 같다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;상원이가 &lt;b&gt;고도 3~3일때만 이동 가능하면, 우체국에서 출발 자체가 불가능 =&amp;gt; 결국&amp;nbsp;모든 집에 우편 배달불가능하니깐 right 이동&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 225px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99C737475F647D8B3E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99C737475F647D8B3E&quot; width=&quot;225&quot; height=&quot;208&quot; filename=&quot;캡처3.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;상원이가 고도 3~4 일때만 이동 가능하면 &lt;b&gt;우편 배달&amp;nbsp;불가능 또 right 이동&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 225px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9977A5475F647D8C0A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9977A5475F647D8C0A&quot; width=&quot;225&quot; height=&quot;209&quot; filename=&quot;캡처4.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;b&gt;불가능 -&amp;gt; 또 이동 -&amp;gt; 또 이동&lt;/b&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 225px; text-align: center;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99E437475F647D8C01&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99E437475F647D8C01&quot; width=&quot;225&quot; height=&quot;209&quot; filename=&quot;캡처5.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;text-align: center;&quot;/&gt;&lt;/span&gt;&lt;b&gt;고도 3 ~ 8 일때는 가능&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;상원이가 3~8 고도 범위를 이동 가능하다고 하면 이 때는&amp;nbsp;모든 집에 우편 배달 가능하니깐 =&amp;gt; 피로도 계산 8 - 3 = 5&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그리고 left 이동시켜서 다시 반복..&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;조금 설명이 부족한듯 싶지만,, 이런식으로 고도 범위를 바꿔가며&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;피로도의 최소값을 찾으면 된다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(153, 56, 0);&quot;&gt;주의할 점&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;상원이가 현재 출발해야 하는 우체국의 고도가 범위안에 있을 때만 이동을 시작할 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important;overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0;padding:0;border:none;background-color:#272727;border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px;border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0;padding:0;word-break:normal;text-align:right;color:#aaa;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;37&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;38&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;39&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;40&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;41&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;42&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;43&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;44&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;45&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;46&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;47&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;48&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;49&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;50&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;51&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;52&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;53&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;54&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;55&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;56&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;57&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;58&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;59&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;60&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;61&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;62&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;63&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;64&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;65&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;66&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;67&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;68&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;69&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;70&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;71&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;72&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;73&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;74&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;75&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;76&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;77&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;78&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;79&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;80&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;81&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;82&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;83&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;84&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;85&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;86&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;87&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;88&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;89&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;90&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;91&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;92&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;93&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;94&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;95&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;96&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;97&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0;text-align:left&quot;&gt;&lt;div style=&quot;margin:0;padding:0;color:#f0f0f0;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important;line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;stdio.h&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;.h&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;char&lt;/span&gt;&amp;nbsp;map[&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;pair&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;sang;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;house;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;height[&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;visited[&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;50&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dy[&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;};&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dx[&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;};&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;bfs(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;s,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;e)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;queue&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;pair&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;qu;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push({&amp;nbsp;sang.first,sang.second&amp;nbsp;});&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[sang.first][sang.second]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;temp&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;qu.empty())&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;front&lt;/span&gt;().first;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;front&lt;/span&gt;().second;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.&lt;span style=&quot;color:#4be6fa&quot;&gt;pop&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(map[y][x]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'K'&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(temp&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;house)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;dy[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;nx&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;dx[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(nx&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;nx&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;ny&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;visited[ny][nx])&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(height[ny][nx]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;height[ny][nx]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;e)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;visited[ny][nx]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;qu.push({&amp;nbsp;ny,nx&amp;nbsp;});&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;getchar();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;map[i][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;getchar();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(map[i][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'P'&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sang.first&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;i;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sang.second&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;j;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(map[i][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'K'&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;house&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;getchar();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;diff_height;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;height[i][j]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;push_back&lt;/span&gt;(height[i][j]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sort(diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),&amp;nbsp;diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;());&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//고도&amp;nbsp;값들&amp;nbsp;오름차숨&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;diff_height.erase(unique(diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),&amp;nbsp;diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;()),&amp;nbsp;diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;());&lt;span style=&quot;color:#999999&quot;&gt;//중복값&amp;nbsp;제외&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;987654321&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;left&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;right&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(right&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;diff_height.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;())&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;true&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;bool&lt;/span&gt;&amp;nbsp;suc&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(diff_height[left]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;height[sang.first][sang.second]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;height[sang.first][sang.second]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;diff_height[right])&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;suc&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;bfs(diff_height[left],&amp;nbsp;diff_height[right]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;memset(visited,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;sizeof&lt;/span&gt;(visited));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;suc)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;diff&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;diff_height[right]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;diff_height[left];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;diff)&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;diff;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;left&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;right&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;answer);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color:#4f4f4ftext-decoration:none&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom;padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;text-decoration:none;color:white&quot;&gt;&lt;span style=&quot;font-size:9px;word-break:normal;background-color:#4f4f4f;color:white;border-radius:10px;padding:1px&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>문제 풀이</category>
      <category>BFS</category>
      <category>binary search</category>
      <category>pointer</category>
      <author>컴영</author>
      <guid isPermaLink="true">https://comyoung.tistory.com/279</guid>
      <comments>https://comyoung.tistory.com/279#entry279comment</comments>
      <pubDate>Fri, 18 Sep 2020 18:39:50 +0900</pubDate>
    </item>
  </channel>
</rss>