<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Informatics</title>
    <link>https://makesource.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Sat, 9 May 2026 14:13:51 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>makesource</managingEditor>
    <item>
      <title>Practice Round 2019</title>
      <link>https://makesource.tistory.com/entry/Practice-Round-2019</link>
      <description>&lt;p&gt;&lt;b&gt;1. Number thinking&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;문제요약:&lt;/p&gt;
&lt;p&gt;Up and Down 을 Interactive 로 옮겨 놓은 문제이다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;풀이:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;숫자 범위를 L 이라고 할때, 항상 현재 범위의 중간을 확인하는 방식으로 [log2 (L)] + 1 번 만에 정답을 맞출 수 있다.&lt;/p&gt;
&lt;p&gt;Interactive probolem 이기 때문에, 출력 시 buffer flush 를 해주지 않으면 TLE 로 판정된다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;2. Mural&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;문제요약:&lt;/p&gt;
&lt;p&gt;길이 N 개의 벽이 있고, 각 벽에 해당되는 점수가 있다.&lt;/p&gt;
&lt;p&gt;하루 마다 길이 1 에 해당되는 벽을 색칠 할 수 있고, 하루마다 좌우측 벽 중 색칠되지 않은 놈들중 하나가 무너진다.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;첫번째 날에는 아무 벽에서 색칠을 시작 할 수 있고, 시작한 이후에는 이미 색칠된 벽의 좌우만 칠 할 수 있다.&lt;/p&gt;
&lt;p&gt;이러한 상황에서 얻을 수 있는 점수중 최대를 구하는 문제&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;풀이:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;문제를 잘 요약해보면, 연속된 구간으로만 색을 칠 할 수 있고,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;매일 하나의 벽을 칠하고 하나의 벽이 무너지기 때문에 최대 칠할 수 있는 벽은 [(N+1)/2] 개 이다.&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;어느 곳에서든 시작할 수 있기 때문에 &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span&gt;길이 &lt;/span&gt;[(N+1)/2] 구간중 합이 가장 큰 구간을 구하면 정답이 된다.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;sliding window 방식을 통해 합을 구하면 길이 N 만에 합이 최대인 구간을 구할 수 있다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;3. Kickstart alarm&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;문제요약:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;주어진 수식을 계산하면 된다&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;풀이:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;정답이 되는 최종합을 &lt;/span&gt;Ai 를 기준으로 수식을 정리하다보면 각 계수의 특징이 관찰된다.&lt;/p&gt;
&lt;p&gt;(power1 + power2 + .. powerk) 를 Ai 를 기준으로 정리하면&lt;/p&gt;
&lt;p&gt;ans = a1 * A1 * N + a2 * A2 * (N-1) ... + an * An * 1 과 같은 꼴로 나타낼 수 있는데,&lt;/p&gt;
&lt;p&gt;이때 ai 들을 관찰해보면 ai = ai-1 + &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;i^1 + i^2 ... i^k 과 같은 꼴로 나타낼 수 있다. (a1 = K)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i^1 + i^2 .. i^k 는 등비수열 합 공식에 의해 i * (i^k - 1) / (i-1) 으로 나타나고,&lt;/p&gt;
&lt;p&gt;MOD 1000000007 에 대한 모든 i 에 대한 역원을 미리 구해두면 ai 값을 빠르게 계산 할 수 있다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;주의할 점:&lt;/p&gt;
&lt;p&gt;1. 모듈러 연산에서 뺄샘이 들어가는 경우 무조건 MOD 만큼 더해준 다음 빼준다.&lt;/p&gt;
&lt;p&gt;2. 각각의 모든 연산에서 MOD 연산을 해주어야 정확한 값이 계산된다. #define 으로 정의해두면 편하다&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;문제출저&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codingcompetitions.withgoogle.com/kickstart/round/0000000000051060&quot;&gt;https://codingcompetitions.withgoogle.com/kickstart/round/0000000000051060&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1577149909405&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot;&gt;&lt;a href=&quot;https://codingcompetitions.withgoogle.com/kickstart/round/0000000000051060&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;position: relative; border-right: 1px solid #d9d9d9; width: 200px; height: 200px; background-size: cover; background-position: center center; background-image: url('https://scrap.kakaocdn.net/dn/bKN0fM/hyEfDEtr00/IvjzIdmeNyYFkpov7qB7GK/img.jpg?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot; style=&quot;position: relative; flex-grow: 1; height: 130px; padding-left: 40px;&quot;&gt;
&lt;p class=&quot;og-title&quot; style=&quot;line-height: 1.6; color: #000000; font-size: 22px; padding-bottom: 10px; max-width: 467px; text-overflow: ellipsis; white-space: nowrap; margin: 0px; overflow: hidden; font-family: 'Noto Sans', 'Noto Sans KR';&quot;&gt;Kick Start - Google&amp;rsquo;s Coding Competitions&lt;/p&gt;
&lt;p class=&quot;og-desc&quot; style=&quot;line-height: normal; margin: 0px; max-width: 467px; text-overflow: ellipsis; overflow: hidden; font-family: 'Noto Sans DemiLight', sans-serif; font-size: 14px; font-weight: 300; font-style: normal; font-stretch: normal; letter-spacing: normal; color: #909090; max-height: 42px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; display: -webkit-box;&quot;&gt;Hone your coding skills with algorithmic puzzles meant for students and those new to coding competitions. Participate in one round or join them all.&lt;/p&gt;
&lt;p class=&quot;og-host&quot; style=&quot;line-height: 1.6; margin: 0px; position: absolute; bottom: -8px; font-family: AvenirNext; font-size: 14px; color: #909090;&quot;&gt;codingcompetitions.withgoogle.com&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>Codejam/2019</category>
      <category>codejam</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/16</guid>
      <comments>https://makesource.tistory.com/entry/Practice-Round-2019#entry16comment</comments>
      <pubDate>Tue, 24 Dec 2019 10:10:55 +0900</pubDate>
    </item>
    <item>
      <title>KOI 2011 지역본선 책장</title>
      <link>https://makesource.tistory.com/entry/KOI-2011-%EC%A7%80%EC%97%AD%EB%B3%B8%EC%84%A0-%EC%B1%85%EC%9E%A5</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;b&gt;Problem&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;https://www.acmicpc.net/problem/2466&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;N 개의 책이 주어진다.&lt;/p&gt;&lt;p&gt;각 책 마다&amp;nbsp;너비 W 와 높이 H 가 주어지고, 주어진 순서대로 책장에 꽂으려 한다.&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;span style=&quot;font-size: 24pt;&quot;&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/span&gt;&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;/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;span style=&quot;font-size: 14pt;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F1A8465A956FF830&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28%7B%20N%20%7D%5E%7B%202%20%7D%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;Solution&lt;/span&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;br /&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;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7C6465A9572B81E&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%7B%20D%20%7D_%7B%20i%20%7D%5Cquad%20%3D%5Cquad%201%5Cquad%20%5Csim%20%5Cquad%20i%5Cquad%20%uBC88%uC9F8%5Cquad%20%uCC45%uC744%5Cquad%20%uD3ED%uC774%5Cquad%20L%uC778%5Cquad%20%uCC45%uC7A5%uC5D0%5Cquad%20%uAF42%uC744%5Cquad%20%uB54C%5Cquad%20%uCD5C%uC18C%5Cquad%20%uB192%uC774%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;552&quot; height=&quot;31&quot;&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;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99CF054C5A95727F26&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%7B%20D%20%7D_%7B%20i%20%7D%3D%5Cmin%20_%7B%201%5Cquad%20%5Cle%20%5Cquad%20j%5Cquad%20%26lt%3B%5Cquad%20i%20%7D%7B%20%5C%7B%20%7B%20D%20%7D_%7B%20j-1%20%7D%5Cquad%20+%5Cquad%20%5Cmax%20%7B%20%28h%5Bj...i%5D%29%20%7D%20%5C%7D%20%5Cquad%20%20%7D%20%28%uB2E8%2C%5Cquad%20w%5Bj%5D+...+w%5Bi%5D%5Cquad%20%5Cle%20%5Cquad%20L%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;543&quot; height=&quot;43&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;와 같이 표현 할 수 있고, 각 i 에 대해 모든 후보 j 에 대해 검사를 하여 정답을 구할 수 있다.&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;span style=&quot;font-size: 14pt;&quot;&gt;2.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F014465A9572FE16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28%7B%20N%20%7D%5Cquad%20log%5Cquad%20N%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;120&quot; height=&quot;26&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;Solution&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위의 점화식을 다시 한번 살펴 보자.&lt;/p&gt;&lt;p&gt;고정된 i 에 대해 편의상 max(h[j...i]) = H[j] 라고 표현하면&lt;/p&gt;&lt;p&gt;D[i] =max { D[j-1] + H[j] } 로 나타난다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;여기서 max 함수 안에 있는 각 항을 따로 살펴보면&lt;/p&gt;&lt;p&gt;D[j-1]: j 가 증가 함에 따라 단조 증가하는 그래프를 그린다.&lt;/p&gt;&lt;p&gt;H[j]: j가 증가 함에 따라 단조 감소하는 그래프를 그린다. (j 가 감소함에 따라 증가한다.)&lt;/p&gt;&lt;p&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: 408px; width: 408px; height: 279px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99F793445A95756E13&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99F793445A95756E13&quot; width=&quot;408&quot; height=&quot;279&quot; filename=&quot;d.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 408px; height: 279px;&quot;/&gt;&lt;/span&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: 408px; width: 408px; height: 280px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9981A4445A9576080D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9981A4445A9576080D&quot; width=&quot;408&quot; height=&quot;280&quot; filename=&quot;h.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 408px; height: 280px;&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;D와 H의 개형을 대략적으로 나타내면 위의 그림과 같다.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;이러한 상황에서 D와 H를 더한 값을 최소로 하는 j를 찾는것이 이 문제의 핵심이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그래프의 개형을 통해 아래의 Lemma를 얻을 수 있다.&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: 14pt;&quot;&gt;lemma 1&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;고정된 i 에 대해, H[j]이 같은 한 가장 작은 j를 선택하는 것이 유리하다. &lt;b&gt;즉 H[j]가 감소하는 j에 대해서만 고려해도 충분하다.&lt;/b&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;따라서 i 가 고정되어 있을때에는 H[j]가 감소하는 j 리스트를 가지고 있어, 이 j 에 대해서만 식을 계산해도 충분하다.&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;그렇다면 i 가 증가할 때 그래프의 개형을 살펴보자&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 681px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/997F4B3D5A957CB205&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F997F4B3D5A957CB205&quot; width=&quot;681&quot; height=&quot;467&quot; filename=&quot;h_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;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;위와같이 i+1 번째 책이 이전 책보다 높이가 큰 경우와 작은경우 두가지 경우가 나올 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;또 세로축이 오른쪽으로 이동한 이유는 문제 조건 상 (w[j] + ... + w[i] &amp;lt;= L) 을 만족해야 되기 때문에 i 가 증가함에 따라 가능한 j의 범위는 점점 감소하기 때문이다.&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;i 일때 고려해야되는 j 의 후보를 list[i] , i + 1 일때 고려해야되는 j 의 후보를 list[i+1] 이라 하면&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;list[i+1] 은 list[i]의&amp;nbsp;앞에서 몇개의 원소가 삭제되고, list[i]의 뒤에서 몇개의 원소가 삭제되거나 추가된 형태가 된다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그리고 여기서&amp;nbsp;삭제된 j들은 이후 i 의 값과 상관없이&amp;nbsp;고려해야할&amp;nbsp;대상에서 아에 제거된다. (한번 높아진 H[j] 값이 다시 감소 하지 않기 때문)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;이를 정리하면 아래와 같은 lemma 를 얻는다.&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: 14pt;&quot;&gt;lemma 2: i 가 증가함에 따라&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;고려해야되는 j 의 후보는 앞 / 뒤에서 추가 혹은 삭제되며 &lt;b&gt;한번 후보에서 빠진 j 는 i 에 상관없이 다시 고려될 필요 없다.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;따라서 i 가 증가하는 순서로 D[i]&amp;nbsp;값을 계산할 때 고려해야 하는 j 의 후보군들을 deque로 관리하면 원소가 앞, 뒤에서 추가 혹은 제거되는 상황을 효과적으로 처리 할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;하지만 최악의 경우 각 i 에대해 고려해야 할 j 의 후보군이 n 에 비례 할 수도 있기 때문에 매번 list 의 모든 후보에 대해 계산하면&amp;nbsp;O(N^2) 이 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;따라서 매번 후보에 대한 계산을 하지 않고 리스트에 삽입되는 순간&amp;nbsp;D[j-1] + H[j] 값을 계산하고 이 값을 우선순위큐에 넣어둔다. 그런 다음 D[i] 를 계산 할 때 우선순위 큐에서 가장 작은 원소를 뽑아 D[i] 값을 계산한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;여기서 주의할 접은 리스트에서 제거되는 원소에 대해서는 그 값을 고려하면 안되기 때문에 큐에서 뽑은 뒤 이 값이 현재 deque 안에 있는 j 에 의해 계산된 값인지 확인하는 과정이 필요하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;lemma2 에 따라 각 원소는 최대 한번 리스트에 삽입 / 삭제 되기 때문에 우선순위 큐에 삽입되는 원소 또한 N 에 비례하며 따라서 D[1] ... D[N] 까지의 모든 값 계산을&amp;nbsp;N log N 시간만에 해결 할 수 있다.&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;span style=&quot;font-size: 14pt;&quot;&gt;3.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99BC1F405A95836826&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28%7B%20N%20%7D%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;52&quot; height=&quot;24&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;Solution&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;이 문제를 O(N) 으로 해결하기 위해서는 후보 j 에 대한 값을 저장하기 위해 사용한 우선순위 큐 대신, &lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;값이 증가하는 데큐 하나와 값이 감소 하는 데큐 2개를 사용하면 된다. 하지만 기본적으로 j후보가 앞/뒤에서 dynamic 하게 추가 삭제되기 때문에 데큐안의 원소를 우리가 원하는 범위 안의 값으로 잘 관리해주기 상당히&amp;nbsp;까다로울 것으로 예상된다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;p.s) 위의 O(N log N) 솔루션으로도 충분히 제한시간 안으로 답을 구해낼 수 있다.&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;span style=&quot;font-size: 32px;&quot;&gt;&lt;b&gt;Implementation&lt;/b&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;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;아래 코드는 두번째 방법인 O(N log N) 으로 구현되어 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 32px;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;우선순위 큐 안의 원소가 현재 deque 안의 원소에서 계산된 값인지 확인하기 위해 valid 라는 배열을 두어 큐에서 뽑을 때 매번 확인하는 과정이 포함되어 있습니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 32px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more15_0&quot; data-id=&quot;15_0&quot;&gt;더보기&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content15_0&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less15_0&quot; data-id=&quot;15_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c preprocessor&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c preprocessor&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;#include &amp;lt;deque&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c preprocessor&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;#include &amp;lt;queue&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c preprocessor&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;#define maxf(a,b) ((a)&amp;gt;(b)?(a):(b))&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c preprocessor&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;#define minf(a,b) ((a)&amp;lt;(b)?(a):(b))&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;using&lt;/code&gt; &lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;namespace&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;std;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number8 index7 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;seq {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number9 index8 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;bool&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;operator &amp;lt; (&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;const&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;seq i)&amp;nbsp; &lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;const&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;{ &lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;dp &amp;gt; i.dp; }&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number10 index9 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;seq() { i = H = dp = 0; }&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number11 index10 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;seq(&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;_i,&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;_H,&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;_dp) { i = _i; H = _H; dp = _dp; }&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number12 index11 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;i,H,dp;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number13 index12 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;} last;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number14 index13 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number15 index14 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;priority_queue&amp;lt;seq&amp;gt; table;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number16 index15 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;deque&amp;lt;seq&amp;gt; list;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number17 index16 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;N, D[100010], valid[100010], S[100010];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number18 index17 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;T[100010][2];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number19 index18 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number20 index19 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;f(&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;M) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number21 index20 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;fJ, nowH, i;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number22 index21 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number23 index22 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c comments&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;&quot;&gt;//초기화&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number24 index23 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;fJ = 1; &lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number25 index24 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(i=1;i&amp;lt;=N;i++){ D[i] = 0; S[i]=0; valid[i] = -1; }&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number26 index25 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(i=1;i&amp;lt;=N;i++){ S[i] = T[i][0]; S[i] += S[i-1]; }&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number27 index26 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(!list.empty()) list.pop_back(); &lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(!table.empty()) table.pop();&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number28 index27 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number29 index28 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;list.push_back(seq(1,T[1][1],D[1-1]+T[1][1]));&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number30 index29 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;table.push(seq(1,T[1][1],D[1-1]+T[1][1]));&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number31 index30 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;valid[1] = D[1-1] + T[1][1];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number32 index31 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;D[1] = T[1][1];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number33 index32 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number34 index33 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(i=2;i&amp;lt;=N;i++) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number35 index34 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c comments&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;&quot;&gt;// list들중 앞에서 pop되는 것들&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number36 index35 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;( S[i] - S[fJ-1] &amp;gt; M ) fJ ++;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number37 index36 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;( !list.empty() &amp;amp;&amp;amp; list.front().i &amp;lt; fJ ) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number38 index37 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;last=list.front(); list.pop_front();&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number39 index38 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;valid[last.i] = -1;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number40 index39 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number41 index40 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;( list.empty() || list.front().i != fJ ) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number42 index41 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;last.i = fJ; last.dp = D[last.i-1] + last.H;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number43 index42 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;list.push_front(last);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number44 index43 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;table.push(last);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number45 index44 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;valid[last.i] = last.dp;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number46 index45 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number47 index46 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c comments&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;&quot;&gt;// 현재 높이 update&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number48 index47 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;nowH = T[i][1];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number49 index48 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;last = seq(i,nowH,D[i-1]+nowH);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number50 index49 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;( !list.empty() &amp;amp;&amp;amp; list.back().H &amp;lt; nowH ) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number51 index50 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;last = list.back(); list.pop_back();&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number52 index51 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&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;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;valid[last.i] = -1;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number53 index52 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number54 index53 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;last.H = nowH; last.dp = D[last.i-1] + last.H;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number55 index54 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;list.push_back(last);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number56 index55 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;table.push(last);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number57 index56 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;valid[last.i] = last.dp;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number58 index57 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number59 index58 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c comments&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;&quot;&gt;// dp값 구하기&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number60 index59 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;( valid[table.top().i] != table.top().dp ) table.pop();&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number61 index60 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;D[i] = table.top().dp;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number62 index61 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number63 index62 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;D[N];&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number64 index63 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number65 index64 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;line number66 index65 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;main() {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number67 index66 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c color1 bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: gray !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;l,r,m,ans=1e9,v,i; l = 0;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number68 index67 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c functions bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(255, 20, 147) !important;&quot;&gt;scanf&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;c string&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: blue !important;&quot;&gt;&quot;%d&quot;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;,&amp;amp;N);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number69 index68 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(i=1;i&amp;lt;=N;i++) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number70 index69 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c functions bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(255, 20, 147) !important;&quot;&gt;scanf&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;c string&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: blue !important;&quot;&gt;&quot;%d%d&quot;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;,&amp;amp;T[i][0],&amp;amp;T[i][1]);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number71 index70 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;l = maxf(l,T[i][0]);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number72 index71 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number73 index72 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;r = 10000 * N;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number74 index73 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;while&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(l&amp;lt;=r) {&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number75 index74 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;m = (l+r)&amp;gt;&amp;gt;1;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number76 index75 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;v = f(m);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number77 index76 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;ans = minf( ans , maxf(v,m) );&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number78 index77 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(v&amp;gt;m) l = m + 1;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number79 index78 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;else&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;r = m - 1;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number80 index79 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number81 index80 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c functions bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(255, 20, 147) !important;&quot;&gt;printf&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;c string&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: blue !important;&quot;&gt;&quot;%d&quot;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;,ans);&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number82 index81 alt1&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c spaces&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;0;&lt;/code&gt;&lt;/div&gt;&lt;div class=&quot;line number83 index82 alt2&quot; style=&quot;font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 14.6667px; color: rgb(0, 0, 0); border-radius: 0px !important; background: none white !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: pre !important;&quot;&gt;&lt;code class=&quot;c plain&quot; style=&quot;border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace !important; font-size: 1em !important; min-height: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less15_0&quot; data-id=&quot;15_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/15</guid>
      <comments>https://makesource.tistory.com/entry/KOI-2011-%EC%A7%80%EC%97%AD%EB%B3%B8%EC%84%A0-%EC%B1%85%EC%9E%A5#entry15comment</comments>
      <pubDate>Wed, 28 Feb 2018 00:55:14 +0900</pubDate>
    </item>
    <item>
      <title>오일러 파이 함수</title>
      <link>https://makesource.tistory.com/entry/%EC%98%A4%EC%9D%BC%EB%9F%AC-%ED%8C%8C%EC%9D%B4-%ED%95%A8%EC%88%98</link>
      <description>&lt;p&gt;오일러 파이 함수란&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://wikimedia.org/api/rest_v1/media/math/render/svg/fbb3dbe542ca7d51c4f32e32cefb8572edb26ab3&quot; class=&quot;mwe-math-fallback-image-inline&quot; aria-hidden=&quot;true&quot; alt=&quot;\phi (n)&quot; style=&quot;border: none; vertical-align: -0.838ex; display: inline-block; color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px; width: 4.631ex; height: 2.843ex;&quot;&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;1부터 n까지의 양의&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://ko.wikipedia.org/wiki/%EC%A0%95%EC%88%98&quot; title=&quot;정수&quot; style=&quot;color: rgb(11, 0, 128); background-image: none; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; font-family: sans-serif; font-size: 14px;&quot;&gt;정수&lt;/a&gt;&lt;span style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;중에 n과&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://ko.wikipedia.org/wiki/%EC%84%9C%EB%A1%9C%EC%86%8C_(%EC%88%98%EB%A1%A0)&quot; title=&quot;서로소 (수론)&quot; style=&quot;color: rgb(11, 0, 128); background-image: none; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; font-family: sans-serif; font-size: 14px;&quot;&gt;서로소&lt;/a&gt;&lt;span style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;인 것의 개수를 나타내는 함수이다&lt;/span&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;/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;우선 특정 N에 대해 구한다고 생각하면&lt;/p&gt;&lt;p&gt;N의 소인수들을 다 구한 다음&amp;nbsp;&lt;img src=&quot;https://wikimedia.org/api/rest_v1/media/math/render/svg/c2880821fa8fcf1d08e8afedf82d99de14f1daa1&quot; class=&quot;mwe-math-fallback-image-inline&quot; aria-hidden=&quot;true&quot; alt=&quot;{\displaystyle \varphi (n)=n\prod _{p|n}(1-1/p)}&quot; style=&quot;border: none; vertical-align: -3.671ex; display: inline-block; color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px; width: 22.027ex; height: 6.176ex;&quot;&gt;&amp;nbsp;이 공식을 사용하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1~ 까지 파이 함수의 값을 구하기 위해서는,&lt;/p&gt;&lt;p&gt;소수판별을 할때 에라토스테네스의 채 기법을 사용한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;pi[i] = i;&lt;/p&gt;&lt;p&gt;for (int i=2;i&amp;lt;=N;i++) {&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;if (pi[i] == i) &amp;nbsp;{ // 소수인 경우&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;pi[i] = i - 1;&lt;/p&gt;&lt;p style=&quot;margin-left: 4em;&quot;&gt;for (int j=i+i;j&amp;lt;=N;j+=i) pi[j] = pi[j] * (i-1) / i;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;와 같이 구할 수 있다.&lt;/p&gt;&lt;p&gt;시간복잡도는 n lg lg n이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이러한 파이 함수와 관련된 법칙이 있는데, 바로 오일러의 정리이다.&lt;/p&gt;&lt;p&gt;만약&amp;nbsp;&lt;i style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;a&lt;/i&gt;&lt;span style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;와&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;n&lt;/i&gt;&lt;span style=&quot;color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;&quot;&gt;이 서로소이고 n이 자연수이면 다음이 성립한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://wikimedia.org/api/rest_v1/media/math/render/svg/02ae8b35573906d08a7f93229eb6b8898cf3c7f2&quot; class=&quot;mwe-math-fallback-image-inline&quot; aria-hidden=&quot;true&quot; alt=&quot;{\displaystyle a^{\phi (n)}\equiv 1{\pmod {n}}}&quot; style=&quot;border: none; vertical-align: -0.838ex; display: inline-block; color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px; width: 20.171ex; height: 3.343ex;&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;특히 n이 소수일때는 pi(n) = n-1 이기때문에 페르마 소정리 a^(p-1) = 1 (mod p)가 성립한다.&lt;/p&gt;&lt;p&gt;이를 통해서 서로소인 a와 n에 대해 모듈러 inverse을 계산 할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;서로소인 a와 n에 대해 모듈러 인버스를 다른 방식으로 계산 할 수 있는 방법도 있는데, 이는 확장유클리드 알고리즘을 이용한 방식이다.&lt;/p&gt;&lt;p&gt;확장 유클리드란&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color: rgb(31, 31, 31); font-family: &amp;quot;맑은 고딕&amp;quot;, &amp;quot;malgun gothic&amp;quot;, 돋움, dotum, AppleGothic, sans-serif;&quot;&gt;ax&amp;nbsp;+ by = gcd(a,b)를 만족하는 정수해 x,y 를 찾기 위한 알고리즘으로&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#1f1f1f&quot; face=&quot;맑은 고딕, malgun gothic, 돋움, dotum, AppleGothic, sans-serif&quot;&gt;이를 위의 식에 적용시키면&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#1f1f1f&quot; face=&quot;맑은 고딕, malgun gothic, 돋움, dotum, AppleGothic, sans-serif&quot;&gt;a*x + n*y&amp;nbsp;= gcd(a, n) = 1&amp;nbsp;을 만족시키는 정수해를 찾을 수 있고&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#1f1f1f&quot; face=&quot;맑은 고딕, malgun gothic, 돋움, dotum, AppleGothic, sans-serif&quot;&gt;양변을 모듈러 n연산을 씌우면&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#1f1f1f&quot; face=&quot;맑은 고딕, malgun gothic, 돋움, dotum, AppleGothic, sans-serif&quot;&gt;a*x = 1 (mod n)이라는 식이 만들어 진다.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color=&quot;#1f1f1f&quot; face=&quot;맑은 고딕, malgun gothic, 돋움, dotum, AppleGothic, sans-serif&quot;&gt;여기서 x는 법 n에 대해 a의 곱셈에대한 역원이 된다.&lt;/font&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;임의의 수 N에 대해 pi를 구하는 방법&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;imsi = N;&lt;/p&gt;&lt;p&gt;for (j=2;j*j&amp;lt;=imsi;j++) if (imsi % j == 0) {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while(!(imsi %j)) imsi /= j;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pi = pi / j * (j-1)&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;if (imsi &amp;gt; 1) { // 소수&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pi = pi / imsi * (imsi - 1)&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/14</guid>
      <comments>https://makesource.tistory.com/entry/%EC%98%A4%EC%9D%BC%EB%9F%AC-%ED%8C%8C%EC%9D%B4-%ED%95%A8%EC%88%98#entry14comment</comments>
      <pubDate>Fri, 23 Sep 2016 15:28:52 +0900</pubDate>
    </item>
    <item>
      <title>Centroid Decomposition</title>
      <link>https://makesource.tistory.com/entry/Centroid-Decomposition</link>
      <description>&lt;p&gt;트리에서 사용하는 분할정복 기법을 Centroid Decomposition이라고 한다.&lt;/p&gt;&lt;p&gt;트리에 존재하는 모든 경로에 대해서 어떤 연산을 수행하려 할때&lt;/p&gt;&lt;p&gt;트리를 분할에 서브 트리에 대해 연산을 수행하고, 그러한 서브트리를 merge해 전체 트리에서의 결과값을 얻어 낼 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;여기서 중요한 것은 주어진 트리르 어떻게 쪼개는지 이다.&lt;/p&gt;&lt;p&gt;쪼개는 방법에 따라 시간복잡도가 달라지는데, 분할정복 처럼 트리의 크기를 계속해서 반 씩 쪼깨고 각 서브트리를 처음 트리사이즈 시간만에 merge 할 수 있다면 시간복잡도는 마스터 정리에 의해 O(N lg N)이 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 문제를 푸는 데 있어 중요한 것은&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;1. Subtree 로 분할할 cutting edge를 어떻게 잡을것인가?&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;2. 서로다른 Subtree들의 결과값을 어떻게 리니어 하게 Merge 할 것인가?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;우선 트리에서 서브트리의 노드갯수가 원래 트리 노드 갯수 / 2가 되도록 커팅 할 수 있는 정점은 항상 존재한다.&lt;/p&gt;&lt;p&gt;그러한 노드는 한번은 bfs순회를 통해 찾을 수 잇다.&lt;/p&gt;&lt;p&gt;여기서 주의할 점이 있는데, Cutting edge를 찾는 과정에서 dfs를 돌릴때 visit배열을 따로 사용하면 안된다.&lt;/p&gt;&lt;p&gt;이유인 즉슨 Cutting과정은 남은 노드가 1개가 될때 까지 재귀적을 반복되는데 매 Cutting과정에서 visit배열을 초기화하고 사용하면 제곱 시간이 들기 때문이다.&lt;/p&gt;&lt;p&gt;따라서 구현을 할때는 현재 노드가 cutting 되었는지 아닌지를 판단하는 배열, cutted하나와 자기로 온 부모 노드로 따라올라가지 못하도록 부모노드의 인덱스만 가지고 dfs를 돌린다. 트리이기 때문에 dfs를 돌릴때 부모로 가지 않도록 해주면, visit 배열을 따로 사용하지 않고 구현 할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그렇게 cutting할 노드를 찾기 위해 dfs 탐색을 한 후, 노드 리스트를 가지고 현재 노드를 잘랏을때 생기는 서브트리의 정점갯수중 max값을 구한다. 그런다음 그 max값이 원래노드갯수/2보다 작거나 같다면 그 정점을 루트로 다시 분할 하면 된다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre class=&quot;source prettyprint&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 2px; font-size: 13.2px; border: 1px solid rgb(136, 136, 136); background-color: rgb(255, 255, 255);&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mom &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mom &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getCut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; y &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; maxf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; maxf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&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;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그런 다음 merge하는 과정에서는 같은 그룹의 서브트리들이 계산 과정에서 선택되지 않도록 그룹별로 분리를 잘 해줘야 한다.&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;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;분할을 해서 subtree에 대해 solve를 부르는 것은, 그 subtree 내에 존재하는 모든 경로들을 탐색하는 것이고,&lt;/p&gt;&lt;p&gt;머지하는 과정에서는 cut한 노드를 무조건 거쳐가는 경로에 대한 계산이라 보면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;밑에는 코드포스 C번에 대한 코드이다.&lt;/p&gt;&lt;p&gt;http://codeforces.com/contest/715/problem/C&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;pre class=&quot;source prettyprint&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 2px; font-size: 13.2px; border: 1px solid rgb(136, 136, 136); background-color: rgb(255, 255, 255);&quot;&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;queue&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;memory.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;map&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#define&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mp make_pair
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#define&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; __ &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;100010&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#define&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; maxf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&amp;gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)?(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;):(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;typedef&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;long&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; std&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; g&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    ll l&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; r&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;};&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

vector&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
vector&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&amp;lt;int&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
vector&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
ll ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rev&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ans&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;__&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
ll N&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mom &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mom &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getCut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dfs&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; y &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; maxf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; maxf&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cnt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cmax &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; count&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; calc&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    queue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    memset&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; n &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;front&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;vis&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            ll L &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;l &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            ll R &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            Q&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; n&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; L&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; R&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    map&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;--;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;l &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ans &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;r &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ans &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            ll t &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(-&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;l &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            t &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;t &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rev&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
            ans &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: rgb(102, 0, 102);&quot;&gt;Queue&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; qlist&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; rv&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; solve&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; cut &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getCut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    calc&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        solve&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    cutted&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;cut&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; extended_gcd&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    pair&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ll&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; t &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; extended_gcd&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; mp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; t&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;first &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; t&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;));&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; main&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    scanf &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&quot;%lld%lld&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&amp;amp;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;N&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&amp;amp;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;N&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        rev&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;extended_gcd&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; ten&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;]).&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;second &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; M&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;N&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        scanf &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&quot;%d%d%d&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&amp;amp;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&amp;amp;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&amp;amp;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;mp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;));&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
        graph&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push_back&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;mp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;));&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    solve&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    printf &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;&quot;%lld&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ans&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: rgb(0, 0, 136);&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;color: rgb(0, 102, 102);&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: rgb(102, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/13</guid>
      <comments>https://makesource.tistory.com/entry/Centroid-Decomposition#entry13comment</comments>
      <pubDate>Fri, 23 Sep 2016 15:17:21 +0900</pubDate>
    </item>
    <item>
      <title>divide &amp;amp; conquar optimization</title>
      <link>https://makesource.tistory.com/entry/divide-conquar-optimization</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = min (D[t-1][j] + C[j][i])&amp;nbsp;(j &amp;lt; i) 꼴인 경우&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;위의 조건을 만족하는 최소의 j를 P[t][i]라고 할때&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;P[t][i] &amp;lt;= P[t][i+1] &amp;lt; --- &amp;gt; C[a][c] + C[b][d] &amp;lt;= C[a][d] + C[b][c] 증명은 귀류법!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;반대로&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = max&amp;nbsp;(D[t-1][j] + C[j][i])&amp;nbsp;(j &amp;lt; i) 꼴인 경우&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;위의 조건을 만족하는 최소의 j를 P[t][i]라고 할때&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;P[t][i] &amp;lt;= P[t][i+1] &amp;lt; --- &amp;gt; C[a][c] + C[b][d] &amp;gt;=&amp;nbsp;C[a][d] + C[b][c] 증명은 귀류법!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;위의 조건을 이용해 divide &amp;amp; conquar 방식으로 로그시간만에 dp table 값을 계산 할 수 있다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;증명&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;(1)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[a][c] + C[b][d] &amp;lt;= C[a][d] + C[b][c]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = min( D[t-1][k] + C[k][i] )&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;A[t][i] &amp;lt;= A[t][i+1]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;귀류법&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;어떤 i에 대해서&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;A[t][i] = j &amp;gt; A[t][i+1] = k&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = D[t-1][j] + C[j][i] &amp;lt; D[t-1][k] + C[k][i]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i+1] = D[t-1][k] + C[k][i+1] &amp;lt; D[t-1][j] + C[j][i+1]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t-1][j] - D[t-1][k]에 대해 정리해보면&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[k][i+1] - C[j][i+1] &amp;lt; D[t-1][j] - D[t-1][k] &amp;lt; C[k][i] - C[j][i]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;즉 C[k][i+1] - C[j][i+1] &amp;lt; C[k][i] - C[j][i]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;다시써서 C[k][i+1] + C[j][i] &amp;lt; C[k][i] + C[j][i+1] 에서 (k &amp;lt; j &amp;lt; i &amp;lt; i+1)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;사각 부등식을 만족한다는 가정에 모순되므로 위 명제는 참이다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;(2)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[a][c] + C[b][d] &amp;gt;= C[a][d] + C[b][c]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = max( D[t-1][k] + C[k][i] )&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;A[t][i] &amp;lt;= A[t][i+1]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;귀류법&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;어떤 i에 대해서&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;A[t][i] = j &amp;gt; A[t][i+1] = k&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i] = D[t-1][j] + C[j][i] &amp;gt; D[t-1][k] + C[k][i]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t][i+1] = D[t-1][k] + C[k][i+1] &amp;gt; D[t-1][j] + C[j][i+1]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[t-1][j] - D[t-1][k]에 대해 정리해보면&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[k][i] - C[j][i] &amp;lt; D[t-1][j] - D[t-1][k] &amp;lt; C[k][i+1] - C[j][i+1]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;즉 C[k][i] - C[j][i] &amp;lt; C[k][i+1] - C[j][i+1]&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;다시 써서 C[k][i] + C[j][i+1] &amp;lt; C[k][i+1] + C[j][i] 에서 (k &amp;lt; j &amp;lt; i &amp;lt; i+1)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;사각 부등식을 만족한다는 가정에 모순되므로 위 명제는 참이다&lt;/span&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;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;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;boj 김치 문제&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[i] = i날에 꺼낼때 max value&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;D[i] = (i-j+1) * T[i] + V[j] ( j &amp;lt; i)로 정의되므로&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[j][i] = (i-j+1) * T[i] + V[j]가 된다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;사각 부등식의 조건을 살펴 보면&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;C[a][c] + C[b][d] - C[a][d] - C[b][c]&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;= (c-a+1) * T[c] + V[a] + (d-b+1) * T[d] + V[b] - (d-a+1) * T[d] - V[a] - (c-b+1) * T[c] - V[b]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;= (c-a+1-c+b-1) * T[c] + (d-b+1-d+a-1) * T[d]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;= (b-a) * T[c] + (a-b) * T[d]&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;= (b-a) (T[c] - T[d]) 로 정리되며&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;a&amp;lt;b&amp;lt;c&amp;lt;d , T[a] &amp;gt; T[b] &amp;gt; T[c] &amp;gt; T[d]라는 조건에서&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;준 식의 값은 양수가 된다&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: Gulim, 굴림; font-size: 12pt;&quot;&gt;즉 다시써서 C[a][c] + C[b][d] &amp;gt; C[a][d] + C[b][c] 를 만족하므로 divide &amp;amp; conquar optimization 을 사용 할 수 있다&lt;/span&gt;&lt;/p&gt;</description>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/12</guid>
      <comments>https://makesource.tistory.com/entry/divide-conquar-optimization#entry12comment</comments>
      <pubDate>Sat, 27 Aug 2016 21:43:14 +0900</pubDate>
    </item>
    <item>
      <title>apio 2010 patrol 간략한 풀이</title>
      <link>https://makesource.tistory.com/entry/apio-2010-patrol-%EC%9E%90%EC%84%B8%ED%95%9C-%ED%92%80%EC%9D%B4</link>
      <description>&lt;p&gt;&lt;/p&gt;&lt;p&gt;우선 K=1일때에는 트리의 지름에 설치하는것이 가장최적이라는 결론을 내릴수 있는데&amp;nbsp;&lt;/p&gt;&lt;p&gt;그에 대한 증명을 위해서 지름길을 설치했을때의 경로길이를 수식으로 표현해보자&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;일단 지름길을 설치하지 않았을때에는 모든간선을 2번씩 지나야함으로&amp;nbsp;&lt;/p&gt;&lt;p&gt;경로이길이는 2(N-1)이 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;지름길을 하나 설치하면 트리에 간선을 하나 추가하는 행위임으로 반드시 하나의 사이클이 생기게된다.&lt;/p&gt;&lt;p&gt;이때 사이클 위에 존재하는 간선은 한번씩만 사이클위에 속하지 않는 간선은 2번씩지나야함으로&lt;/p&gt;&lt;p&gt;경로의 길이는 2(N-1) - L + 1이 되는데 L은 (사이클 위에 포함된 정점의 갯수-1)개 이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;따라서 K=1일때는 간선을 추가하여 만드는 사이클의 길이(즉, 정점갯수-1) 가 최대가 되게 하면 됨으로&amp;nbsp;&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;p&gt;이제 K=2일때 생각을 해보자&lt;/p&gt;&lt;p&gt;우리가 설치할 두개의 지름길에 따라서 생기는 사이클의 갯수도 2개가 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이때 두개의 사이클이 하나이상의 엣지를 공유하는경우(같은 정점을 공유하는것은 상관없다)와&amp;nbsp;&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;/p&gt;&lt;p&gt;즉 (v1,v2)를 연결하는 지름길 e1 과 (v3,v4)를 연결하는 지름길 e2를&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. (v1,v3)와 (v2,v4)로 연결하거나&lt;/p&gt;&lt;p&gt;2. (v1,v4)와 (v2,v3)로 연결하면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;두개중 하나의 경우에서는 반드시 겹치는 경로가 사라지게 된다.&lt;/p&gt;&lt;p&gt;즉 K=2일때에는 트리에서 두개의 경로의합이 최대가되는 경로 2개만 찾으면된다.&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;br /&gt;&lt;/p&gt;&lt;p&gt;이사실을 알았을때&lt;/p&gt;&lt;p&gt;K=1일때와 K=2일때 해결하는방법을 알아보자&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;i) K=1일때&lt;/p&gt;&lt;p&gt;간단한 트리DP로 해결가능하다&lt;/p&gt;&lt;p&gt;H[u] = u와 u의 자식간의 가장 긴 경로의 길이&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;(끝점중 하나가 u라는뜻)&lt;/span&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;; 로 정의하면 O(N)만에 해결할수 있을것이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;ii) K=2일때&lt;/p&gt;&lt;p&gt;K=1일때보다는 조금 복잡하지만 여전히 트리 DP로 해결하다.&lt;/p&gt;&lt;p&gt;우선 구현에 사용되는 DP table정의를 모두 적어보면 다음과 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;H[u] = u와 u의 자식간의 가장 긴 경로의 길이(끝점중 하나가 u라는뜻)&lt;/p&gt;&lt;p&gt;L[u] = u의 서브트리들중에서 u를 포함한 가장긴 경로의 길이&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A[u] = u의 서브트리들중에서 가장긴 경로의 길이&lt;/p&gt;&lt;p&gt;B[u] = u의 서브트리들중에서 엣지가 서로 곂치지 않는 서로다른 두개의 경로의 길이의 최대합&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;이때 두개의 경로를 P,Q라고 하자, P 경로의 끝점은 반드시 u 가 되어야함.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;D[u] = u의 서브트리들중에서 서로 곂치지않는 경로2개의 길이의 최대합&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;br /&gt;&lt;/p&gt;&lt;p&gt;H[u]는 트리 순회하면서 O(N)만에 가능&lt;/p&gt;&lt;p&gt;L[u]는 H[u]를 이용해서 O(N)만에 가능&lt;/p&gt;&lt;p&gt;A[u]는 L[u]를 이용해서 O(N)만에 가능&amp;nbsp;&lt;/p&gt;&lt;p&gt;B[u]는 그냥 하면 O(N^2) 이되는데 잘하면 O(N)으로 가능하다&lt;/p&gt;&lt;p&gt;D[u]도 그냥 하면 O(N^2) 이되는데 잘하면 O(N)으로 가능하다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;*B[u]와 D[u] 잘 계산하는방법*&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;B[u]는 세가지 경우로 나눌수있는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 두개의 경로 P,Q가 모두 정점 u를 포함하는경우 (단 P의 끝점은 u)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;이때 B[u]는 &amp;nbsp;u의 자식정점을 CH(u)라고 정의할때 H[CH(u)]의 최댓값3개의 합이다.&lt;/p&gt;&lt;p&gt;2. 두개의 경로 P,Q가 있는데 u의 자식들중 임의로 하나를 v 라고하자 이때 경로 P는 edge(u,v)를 포함하는경로이고&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;Q는 v의 서브트리에 완전히 포함되는 가장긴 경로이다. 이때는 B[u] = B[v] + 1&lt;/p&gt;&lt;p&gt;3. 두개의 경로 P,Q가 있는데 u의 자식들중 임의로 두개를 v,w라고 하자 이때 경로 P는 edge(u,v)를 포함하는 경로이고&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;Q는 w의 서브트리에 완전히 포함되는 가장긴 경로이다. B[u] = H[v] + A[w] + 1;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;D[u]도 세가지 경우로 나눌수 있는데&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 두개의 경로 P,Q가 모두 u를 포함하는경우 , u의 자식을 CH(u)라고 할때 D[u] = H[CH(u)]의 최댓값 두개의 합 + 2&lt;/p&gt;&lt;p&gt;2. 두개의 경로 P,Q모두 u를 포함하지 않는경우 , u의 자식을 CH(u)라고 할때 D[u] = A[CH(u)]의 최댓값 두개의 합&lt;/p&gt;&lt;p&gt;3. 두개의 경로 P,Q중 하나만 u를 포함하는경우 , D[u] = B[u];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;따라서 총 시간복잡도는 O(N)이 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
      <category>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/10</guid>
      <comments>https://makesource.tistory.com/entry/apio-2010-patrol-%EC%9E%90%EC%84%B8%ED%95%9C-%ED%92%80%EC%9D%B4#entry10comment</comments>
      <pubDate>Sun, 3 Feb 2013 17:31:38 +0900</pubDate>
    </item>
    <item>
      <title>그래프 관련</title>
      <link>https://makesource.tistory.com/entry/%EA%B7%B8%EB%9E%98%ED%94%84-%EA%B4%80%EB%A0%A8</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그래프&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/207C4E485094FC3D1E&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28G%3D%28V%2CE%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;80&quot; height=&quot;24&quot;&gt; 에서&lt;/p&gt;&lt;p&gt;매칭 =&amp;nbsp;변집합&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/19724C495094FD8C08&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28M%5Csubseteq%20E%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;63&quot; height=&quot;31&quot;&gt;로, 상호 끝점을 공유하지 않는다.&lt;/p&gt;&lt;p&gt;변 덮개 = 변집합&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1608384D5094FDC528&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28F%5Csubseteq%20E%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;57&quot; height=&quot;31&quot;&gt;로,&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/185A31495094FDE132&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28G%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;23&quot; height=&quot;24&quot;&gt;의 어떤 정점도 적어도 1개의&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/02372F4F5094FDF91A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28F%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;22&quot; height=&quot;24&quot;&gt;에 포함된 변에 접속 하고 있다.&lt;/p&gt;&lt;p&gt;안정집합 = 점집합&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1438654F5094FE261A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%5Csubseteq%20V%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;56&quot; height=&quot;31&quot;&gt;로,&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/014A134C5094FE3719&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;21&quot; height=&quot;24&quot;&gt;의 어떤 두점도&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/185A31495094FDE132&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28G%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;23&quot; height=&quot;24&quot;&gt;에 대해 인접하고 있지 않다.&lt;/p&gt;&lt;p&gt;점 덮개 =&amp;nbsp;점집합&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1438654F5094FE261A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%5Csubseteq%20V%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;56&quot; height=&quot;31&quot;&gt;로,&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/185A31495094FDE132&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28G%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;23&quot; height=&quot;24&quot;&gt;의 어떤 변도 적어도 1개의&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/014A134C5094FE3719&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;21&quot; height=&quot;24&quot;&gt;에 포함된 정점에 접속하고 있다.&lt;/p&gt;&lt;p&gt;일때 몇가지 법칙이 성립한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 고립점이 없는 그래프에서 대해서, |최대매칭| + |최소 변 덮개| = |V|&lt;/p&gt;&lt;p&gt;2. |최대 안정 집합| + |최소 점 덮개| = |V|&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;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;http://prague.algospot.com/judge/problem/read/TRAPCARD&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;위 문제가 위의 성질을 이용하여 풀수있는 대표적인 문제이다&lt;/span&gt;&lt;/p&gt;&lt;p&gt;이문제는 갯수만 출력하는것이 아니라 그 구체적인 예시까지 출력해야되는 문제인데.&lt;/p&gt;&lt;p&gt;이분그래프에서 minimum vertex cover를 찾는 방법은 다음과 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이분그래프&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/0124FE4B510E140D18&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28G%3D%28U%5Ccup%20V%2CE%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;111&quot; height=&quot;24&quot;&gt;에서 최소 점덮개(minimum vertex cover)를&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/24046547510E142E07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;21&quot; height=&quot;24&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;라고 하자&lt;/p&gt;&lt;p&gt;이분매칭을 돌리고 나온 그래프에서 residual edge를 따라 갈수있는 정점을&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/264D4439510E14772B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28T%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;23&quot; height=&quot;24&quot; style=&quot;font-size: 9pt; line-height: 1.5;&quot;&gt;라고 하면&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1551E435510E14CD36&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S%3D%28U-T%29%5Ccup%20%28V%5Ccap%20T%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;160&quot; height=&quot;24&quot;&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;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>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/9</guid>
      <comments>https://makesource.tistory.com/entry/%EA%B7%B8%EB%9E%98%ED%94%84-%EA%B4%80%EB%A0%A8#entry9comment</comments>
      <pubDate>Sat, 3 Nov 2012 20:50:35 +0900</pubDate>
    </item>
    <item>
      <title>다이나믹 -- 시작복잡도 줄이기</title>
      <link>https://makesource.tistory.com/entry/%EB%8B%A4%EC%9D%B4%EB%82%98%EB%AF%B9-%EC%8B%9C%EC%9E%91%EB%B3%B5%EC%9E%A1%EB%8F%84-%EC%A4%84%EC%9D%B4%EA%B8%B0</link>
      <description>&lt;p style=&quot;line-height: 1; &quot;&gt;dynamic programming 문제들중&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/2006FA47502B7FEC0E&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28D%28i%29%3DD%28j%29+cost%28i%2Cj%29%5Cquad%20%281%5Cquad%20%5Cle%20%5Cquad%20j%5Cquad%20%26lt%3B%5Cquad%20i%5Cquad%20%5Cle%20%5Cquad%20N%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;354&quot; height=&quot;31&quot;&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;와 같은 점화식을 가진 문제들에 대해 생각해보자.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;실제로 최근 KOI에서도 위와 같은 점화식을 가진 문제가 몇몇 나왔는데&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;2011 전국 중등부3 번이라던가&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;2011 지역 고등부5 번을 예로 들 수 있다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;위와 같은 점화식을 가진 문제는 특수한 경우에 따라 시간복잡도를&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/143A0D4B502B80BF28&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28%7B%20N%20%7D%5E%7B%202%20%7D%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;에서&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1731F841502B80EB0A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28NlgN%29%5Cquad%20or%5Cquad%20O%28N%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;173&quot; height=&quot;26&quot; style=&quot;line-height: 1; &quot;&gt;으로 바꿔 풀 수 있다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;font-size: 24pt; &quot;&gt;1. commando (APIO 2010)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;위 문제의 점화식을 나타내보면&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/11680935502B836D0C&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28D%28i%29%5Cquad%20%3D%5Cquad%20D%28j-1%29%5Cquad%20+%5Cquad%20aX%5E%7B%202%20%7D%5Cquad%20+%5Cquad%20bX%5Cquad%20+%5Cquad%20c%5Cquad%20%281%5Cquad%20%5Cle%20%5Cquad%20j%5Cquad%20%26lt%3B%5Cquad%20i%5Cquad%20%5Cle%20%5Cquad%20N%5Cquad%20%2C%5Cquad%20X%5Cquad%20%3D%5Cquad%20%5Csum%20_%7B%20k%3Dj%20%7D%5E%7B%20i%20%7D%7B%20x%28k%29%20%7D%20%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;640&quot; height=&quot;65&quot;&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;여기서 bX항은 그룹을 어떻게 나누는지에는 상관없이 항상 그 값은&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1543454F502F7F0D33&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28b%28%7B%20x%20%7D_%7B%201%20%7D%5Cquad%20+%5Cquad%20%7B%20x%20%7D_%7B%202%20%7D%5Cquad%20...%5Cquad%20+%5Cquad%20%7B%20x%20%7D_%7B%20n%20%7D%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;193&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;&amp;nbsp;과 같게 된다.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;따라서 위 점화식을&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/192E5541502B856C27&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28D%28i%29%5Cquad%20%3D%5Cquad%20D%28j-1%29%5Cquad%20+%5Cquad%20aX%5E%7B%202%20%7D%5Cquad%20+%5Cquad%20c%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;253&quot; height=&quot;28&quot;&gt;&amp;nbsp;로 두고 마지막에 b*(x1+x2..+xn) 을 더해주면 위와같은 점화식이 된다는것을 확인할 수 있다. 그리고&amp;nbsp;&lt;span style=&quot;line-height: 1; &quot;&gt;c는 j값에 상관없이 항상 일정한 값을 가지기 때문에&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;우리는 고정된 i 에 대하여&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1470394C502F86B921&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28max%28%5Cquad%20D%28j-1%29%5Cquad%20+%5Cquad%20aX%5E%7B%202%20%7D%5Cquad%20%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;213&quot; height=&quot;28&quot;&gt;&amp;nbsp;의 값을&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/15337E41502B85D522&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%281%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;50&quot; height=&quot;24&quot; style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;만에 구할수 있다면 시간복잡도는&amp;nbsp;&lt;/span&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/172C0146502B85EA0D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28N%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot; style=&quot;line-height: 1; &quot;&gt;이 될것이다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;편의상&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/15508050502F7F632C&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%7B%20S%20%7D_%7B%20i%20%7D%5Cquad%20%3D%5Cquad%20%5Csum%20_%7B%20k%3D1%20%7D%5E%7B%20i%20%7D%7B%20%7B%20x%20%7D_%7B%20i%20%7D%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;117&quot; height=&quot;65&quot;&gt;&amp;nbsp;로 정의하면,&amp;nbsp;&amp;nbsp;&lt;span style=&quot;line-height: 1; &quot;&gt;점화식을 다음과 같이 나타낼수 있다.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1570604B502F86C52F&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Cquad%20%5Cquad%20%5Cquad%20%5Cquad%20%5Cquad%20D%28i%29%5Cquad%20%3D%5Cquad%20max%5C%7B%20%5Cquad%20a%28S_%7B%20i%20%7D-S_%7B%20j%20%7D%29%5E%7B%202%20%7D+D%28j-1%29%5Cquad%20%5C%7D%20%5Cquad%20+%5Cquad%20c%5C%5C%20%26lt%3B%3D%3D%26gt%3B%5Cquad%20D%28i%29%5Cquad%20%3D%5Cquad%20max%5C%7B%20%5Cquad%20aS_%7B%20i%20%7D%5E%7B%202%20%7D-2aS_%7B%20i%20%7DS_%7B%20j%20%7D+aS_%7B%20j%20%7D%5E%7B%202%20%7D+D%28j-1%29%5Cquad%20%5C%7D%20%5Cquad%20+%5Cquad%20c%5C%5C%20%26lt%3B%3D%3D%26gt%3B%5Cquad%20D%28i%29%5Cquad%20%3D%5Cquad%20max%5C%7B%20%5Cquad%20-2aS_%7B%20i%20%7DS_%7B%20j%20%7D+aS_%7B%20j%20%7D%5E%7B%202%20%7D+D%28j-1%29%5Cquad%20%5C%7D%20%5Cquad%20+%5Cquad%20aS_%7B%20i%20%7D%5E%7B%202%20%7D%5Cquad%20+%5Cquad%20c%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;521&quot; height=&quot;94&quot;&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;두번째 식에서 세번째 식으로 넘어가는 과정에서 &lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/130DC73D502F819E0A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28aS_%7B%20i%20%7D%5E%7B%202%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;40&quot; height=&quot;29&quot; style=&quot;line-height: 1; &quot;&gt;항이 밖으로 빠저나간 이유는 D(i)값을 구할때 고정된 i에 대해서 생각하기 때문이다. &amp;nbsp;위와 같이 정의한후 &amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1259924D502F82330C&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28y%5Cquad%20%3D%5Cquad%20%28-2aS_%7B%20j%20%7D%29x+aS_%7B%20j%20%7D%5E%7B%202%20%7D+D%28j-1%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;247&quot; height=&quot;29&quot; style=&quot;line-height: 1; &quot;&gt;라는 함수를 생각해 보자.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;그러면 위 함수는 일정한&amp;nbsp;특징을 가진 일차함수가 된다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt; &quot;&gt;&amp;lt;특징1&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 11pt; &quot;&gt;&amp;nbsp;j가 증가함에 따라서 기울기가 증가하는 함수이다.&amp;nbsp;(-5 &amp;lt;= a &amp;lt;=-1 임으로)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt; &quot;&gt;&amp;lt;특징2&amp;gt; &amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt; &quot;&gt;기울기가 동일한 j와 j'는 존재하지 않는다.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;이러한 사실을 알았을때, i = 5 일때 임의의 그래프를 그려보면&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 619px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/15525148502F8B3A15&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F15525148502F8B3A15&quot; width=&quot;619&quot; height=&quot;461&quot; filename=&quot;코만도 1.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;다음과 같습니다. 이러한 후보들 중에서&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/153ACF48502F866A16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S_%7B%20i%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;28&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;값이 주어졌을때 함수값이 최대가 되는 j후보를 찾는것이 문제의 핵심인데,&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 619px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/11750D49502F875C18&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F11750D49502F875C18&quot; width=&quot;619&quot; height=&quot;461&quot; filename=&quot;코만도 2.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;그러면 모든 j의 후보에 대해서 교점을 찾아서 함숫값을 구하면 각 i에 대해서 N번 즉 O(N^2) 이 되어버린다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;그러나 아까 찾은 특징을 생각해&amp;nbsp;보면 어떤 j에 대하여 그 함수값이 최대가 되는 어떠한 구간들을 각각 가지고 있다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 649px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/207C1D34502F88AB16&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F207C1D34502F88AB16&quot; width=&quot;649&quot; height=&quot;461&quot; filename=&quot;코만도 3.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;그렇다면 j후보에 대해서 직선들의 교점에 대한 list들을 관리해 주면서,&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/153ACF48502F866A16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S_%7B%20i%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;28&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;값이 주어졌을때 최댓값으로 인정받는 j를 binary search 로 찾아주고, i -&amp;gt; i+1이 될때 i에 대한 직선을 list에 update 시켜 준다면&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1607E750502F896D23&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28NlgN%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;86&quot; height=&quot;24&quot; style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;풀이는 완성이 되었다.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;직선을 update시켜줄때 주의해야할 점이 하나 있는데,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 649px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/1370B54F502F8A2831&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F1370B54F502F8A2831&quot; width=&quot;649&quot; height=&quot;461&quot; filename=&quot;코만도 4.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;다음과 같은 상황일때이다.&amp;nbsp;이런 상황에선 list들을 뒤에서 부터 pop해주면서 필요없는 직선은 버리면 된다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 649px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/1950F24E502F8AE11C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F1950F24E502F8AE11C&quot; width=&quot;649&quot; height=&quot;461&quot; filename=&quot;코만도 5.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1178984C502F8B5E33&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28NlgN%29%5Cquad%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;98&quot; height=&quot;26&quot;&gt;에서&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/1443B447502F8B6E12&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28O%28N%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot; style=&quot;line-height: 1; &quot;&gt;으로 줄이는 아이디어는 간단하다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;바로&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/153ACF48502F866A16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S_%7B%20i%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;28&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;값은 항상 증가한다는 사실이다. 즉 binary search로 j후보를 찾을 필요없이 list의 앞에서 부터&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/153ACF48502F866A16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S_%7B%20i%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;28&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;값이 최댓값으로 인정받는 구간이 아니라면 pop해버리면 된다. 아까 말했듣이&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/153ACF48502F866A16&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28S_%7B%20i%20%7D%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;28&quot; height=&quot;27&quot; style=&quot;line-height: 1; &quot;&gt;값은 항상 증가하기때문에 pop한 j의 후보에 대해선 다시 참조할 일이 없기 때문이다.&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; text-align: center; clear: none; float: none; &quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 649px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/15397D47502F8D2C26&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F15397D47502F8D2C26&quot; width=&quot;649&quot; height=&quot;461&quot; filename=&quot;코만도 6.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;span style=&quot;font-size: 32px; line-height: 32px; &quot;&gt;2. 책장 (KOI 2011)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;// 작성중&lt;/p&gt;&lt;p style=&quot;line-height: 1; &quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/8</guid>
      <comments>https://makesource.tistory.com/entry/%EB%8B%A4%EC%9D%B4%EB%82%98%EB%AF%B9-%EC%8B%9C%EC%9E%91%EB%B3%B5%EC%9E%A1%EB%8F%84-%EC%A4%84%EC%9D%B4%EA%B8%B0#entry8comment</comments>
      <pubDate>Wed, 15 Aug 2012 20:36:32 +0900</pubDate>
    </item>
    <item>
      <title>컨베이어 벨트</title>
      <link>https://makesource.tistory.com/entry/%EC%BB%A8%EB%B2%A0%EC%9D%B4%EC%96%B4-%EB%B2%A8%ED%8A%B8</link>
      <description>&lt;p&gt;링크 : &lt;a href=&quot;http://211.228.163.31/pool/coci_traka/coci_traka.php?pname=coci_traka&quot;&gt;http://211.228.163.31/pool/coci_traka/coci_traka.php?pname=coci_traka&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;Solution&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;1)&amp;nbsp;&amp;nbsp; O(NM)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;D(j) = j번째 사람이 첫번째 작업을 시작할 최소시간&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;이라 정의하자.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;그러면 모든 i에 대하여&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;D(j) + {T(1)+T(2)+T(3)...+T(i)}*F(j) &amp;lt;= D(j+1) + {T(1)+T(2)+T(3)...+T(i-1)}*F(j+1)&amp;nbsp;이 성립해야 한다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉 모든 작업i에 대해서 j+1번째 사람이 i번째&amp;nbsp;작업을 시작할 시간은 j번째 사람이 i번째 작업을 끝낸 시간보다 같거나 커야한다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;위식을 정리하면&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;모든 i에 대해서&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;D(j+1) &amp;gt;= D(j) + {T(1)+T(2)+T(3)...+T(i-1)}{F(j)-F(j+1)} + T(i)*F(j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;가 성립해야한다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉 &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;D(j+1)&amp;nbsp;= D(j) +&amp;nbsp;max(&amp;nbsp;{T(1)+T(2)+T(3)...+T(i-1)}{F(j)-F(j+1)} + T(i)*F(j) )&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;라는 식을 얻어낼수 있다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;따라서 모든j에 대해서 모든 i를 훑으면, O(NM)솔루션을 얻어낼수 있다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;2) O(NlgM)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;
&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;다음과 같은 함수를 정의하자 &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;C(i,j) = {T(1)+T(2)+T(3)...+T(i-1)}{F(j)-F(j+1)} + T(i)*F(j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉, D(j+1)&amp;nbsp;= D(j) +&amp;nbsp;max(&amp;nbsp;C(i,j) ) 이다&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;1 &amp;lt;= i1 &amp;lt; i2 &amp;lt;= M&amp;nbsp;에 대해서 C(i1,j) &amp;lt;= C(i2,j) 일 필요충분 조건을 구해보자&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;C(i1,j) &amp;lt;= C(i2,j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&amp;lt;==&amp;gt;&amp;nbsp;&amp;nbsp;{T(1)+T(2)+T(3)...+T(i1-1)}{F(j)-F(j+1)} + T(i1)*F(j) &amp;lt;= {T(1)+T(2)+T(3)...+T(i2-1)}{F(j)-F(j+1)} + T(i2)*F(j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&amp;lt;==&amp;gt; F(j){T(i1)-T(i2)} &amp;lt;= {F(j)-F(j+1)}{T(i1)+T(i1+1) ... + T(i2-2) + T(i2-1)}&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&amp;lt;==&amp;gt; &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;txc-formula&quot; height=&quot;62&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/114DC7414F86F82F03&quot; width=&quot;279&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Cfrac%20%7B%20%7B%20T%20%7D_%7B%20i1%20%7D-%7B%20T%20%7D_%7B%20i2%20%7D%20%7D%7B%20%7B%20T%20%7D_%7B%20i1%20%7D+%7B%20T%20%7D_%7B%20i1+1%20%7D+...+%7B%20T%20%7D_%7B%20i2-1%20%7D%20%7D%20%5Cle%20%5Cfrac%20%7B%20%7B%20F%20%7D_%7B%20j%20%7D-%7B%20F%20%7D_%7B%20j+1%20%7D%20%7D%7B%20%7B%20F%20%7D_%7B%20j%20%7D%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&amp;lt;==&amp;gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;txc-formula&quot; height=&quot;62&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/181355364F87B0E024&quot; width=&quot;277&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Cfrac%20%7B%20%7B%20T%20%7D_%7B%20i2%20%7D-%7B%20T%20%7D_%7B%20i1%20%7D%20%7D%7B%20%7B%20T%20%7D_%7B%20i1%20%7D+%7B%20T%20%7D_%7B%20i1+1%20%7D+...+%7B%20T%20%7D_%7B%20i2-1%20%7D%20%7D%20%5Cge%20%5Cfrac%20%7B%20%7B%20F%20%7D_%7B%20j+1%20%7D-%7B%20F%20%7D_%7B%20j%20%7D%20%7D%7B%20%7B%20F%20%7D_%7B%20j%20%7D%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;여기서 복잡한 식을 간단히 하기위해 다음과같은 함수를 정의한다&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; height=&quot;62&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/113A9D344F87B20F21&quot; width=&quot;282&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28t%28i1%2Ci2%29%5Cquad%20%3D%5Cquad%20%5Cfrac%20%7B%20%7B%20T%20%7D_%7B%20i2%20%7D-%7B%20T%20%7D_%7B%20i1%20%7D%20%7D%7B%20%7B%20T%20%7D_%7B%20i1%20%7D+%7B%20T%20%7D_%7B%20i1+1%20%7D+...+%7B%20T%20%7D_%7B%20i2-1%20%7D%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;txc-formula&quot; height=&quot;62&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/174D22454F86F8CA14&quot; width=&quot;159&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28f%28j%29%5Cquad%20%3D%5Cquad%20%5Cfrac%20%7B%20%7B%20F%20%7D_%7B%20j+1%20%7D-%7B%20F%20%7D_%7B%20j%20%7D%20%7D%7B%20%7B%20F%20%7D_%7B%20j%20%7D%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;그러면 다음과 같은 결론을 얻을수 있다.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;txc-formula&quot; height=&quot;31&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/132EEB414F86F9C51E&quot; width=&quot;398&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Ctherefore%20%5Cquad%20C%28i1%2Cj%29%5Cquad%20%5Cle%20%5Cquad%20C%28i2%2Cj%29%5Cquad%20%26lt%3B%3D%3D%26gt%3B%5Cquad%20f%28j%29%5Cquad%20%5Cle%20%5Cquad%20t%28i1%2Ci2%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;txc-formula&quot; height=&quot;31&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/2045C9424F86F9AB11&quot; width=&quot;386&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Ctherefore%20%5Cquad%20C%28i1%2Cj%29%5Cquad%20%5Cge%20%5Cquad%20C%28i2%2Cj%29%5Cquad%20%26lt%3B%3D%3D%26gt%3Bf%28j%29%5Cquad%20%5Cge%20%5Cquad%20t%28i1%2Ci2%29%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot;&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;위의 결론을 바탕으로 몇가지 정보를 얻어낼수 있다.&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;(i1&amp;lt;i2&amp;lt;i3)에서&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;i)&amp;nbsp;f(j) &amp;lt;= t(i1,i2) &amp;lt;= t(i2,i3) &amp;lt;==&amp;gt;&amp;nbsp; C(i1,j) &amp;lt;= C(i2,j) &amp;lt;= C(i3,j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉 고정된 j에 대해서 i1과 i2는 고려 할 필요 없는 선택지이다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;ii)&amp;nbsp;t(i1,i2) &amp;lt;= f(j) &amp;lt;=&amp;nbsp;t(i2,i3) &amp;lt;==&amp;gt;&amp;nbsp; C(i1,j)&amp;nbsp;&amp;gt;= C(i2,j) &amp;amp; C(i2,j)&amp;nbsp;&amp;lt;= C(i3,j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉 고정된 j에 대해서 i2는 고려 할 필요 없는 선택지이다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;iii) t(i1,i2) &amp;lt;= t(i2,i3) &amp;lt;= f(j)&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; C(i1,j)&amp;nbsp;&amp;gt;= &amp;nbsp;C(i2,j)&amp;nbsp;&amp;gt;= C(i3,j)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉 고정된 j에 대해서 i2와 i3는 고려 할 필요 없는 선택지이다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;위 3가지 정보를 결합하면 f(j)값이 증가하든지 감소하든지에 상관없이 t(i1,i2) &amp;lt;= t(i2,i3)가 성립한다면, i2는 필요없는 선택지이다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;f(j) 값에 관계가 없기 때문에 j1&amp;lt;j2 에서&amp;nbsp;j1에서 제거된 i의 리스트는 j2에서 또한 필요없는 리스트가 된다. 즉 리스트에 한번빠진 i의 후보는 다시 추가될 필요없다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;그렇다면 이렇게 남은 i의 후보를 L1,L2,L3...Lk라고 하면&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;t(L1,L2) &amp;gt; t(L2,L3) &amp;gt; t(L3,L4) ... &amp;gt; t(L(k-1),Lk) 가 성립한다.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;만약 (1&amp;lt;=p&amp;lt;k)인 p에 대해서&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;t(L1,L2) &amp;gt; t(L2,L3) &amp;gt; t(L3,L4) ...&amp;nbsp;&amp;gt; t(L(p-1),Lp) &amp;gt;=&amp;nbsp;f(j) &amp;gt;&amp;nbsp;t(Lp,L(p+1)&amp;nbsp;... &amp;gt; t(L(k-1),Lk)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;가 성립하면&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;C(L1,j) &amp;lt; C(L2,j) ... &amp;lt; C(L(p-1),j) &amp;lt; C(Lp,j) &amp;gt; C(L(p+1),j) &amp;gt; ... &amp;gt; C(L(k-1),j) &amp;gt; C(Lk,j) &lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;가 성립한다&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;즉,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;D(j+1) = D(j) + C(Lp,j)이며,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;p의 위치는 모든 j 에 대해서 binary search로 log복잡도 만에 찾을수 있음으로&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;최종적인 알고리즘의 시간복잡도는 O(NlgM)가 된다&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;span style=&quot;FONT-SIZE: 12pt&quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/strong&gt;</description>
      <category>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/7</guid>
      <comments>https://makesource.tistory.com/entry/%EC%BB%A8%EB%B2%A0%EC%9D%B4%EC%96%B4-%EB%B2%A8%ED%8A%B8#entry7comment</comments>
      <pubDate>Fri, 13 Apr 2012 00:50:57 +0900</pubDate>
    </item>
    <item>
      <title>Hanoi Tower</title>
      <link>https://makesource.tistory.com/entry/Hanoi-Tower</link>
      <description>&lt;br /&gt;
&lt;a href=&quot;http://211.228.163.31/30stair/hanoi1/hanoi1.php?pname=hanoi1&quot;&gt;http://211.228.163.31/30stair/hanoi1/hanoi1.php?pname=hanoi1&lt;/a&gt;&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
문제를 요약하자면 현재상태의 하노이 탑이 주어졌을때 1,2,3번 기둥중 어떤기둥으로 옮기는지는 상관없고, 최소의 이동으로 모든 조각을 한곳에 모을때 최소이동과 어디로 모으는 것이 최적인지 구하는것이다.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
일단 이문제는 linear 하게 풀릴수 있다.&lt;br /&gt;
가장 쉽게 떠올릴수 있는 방법이 모든 경우를 다해보는 backtracking 기법인데.&amp;nbsp;&lt;br /&gt;
이문제의 실제 N범위가 100,000인걸 감안한다면&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 58px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/133B99454F47B31827&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F133B99454F47B31827&quot; width=&quot;58&quot; height=&quot;27&quot; filename=&quot;daum_equation_1330098950328.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;으론 해결할수 없다.&lt;br /&gt;
&lt;br /&gt;
그렇다면 어떻게 &amp;nbsp;접근해야 풀수 있을까?&lt;br /&gt;
&lt;br /&gt;
1)&lt;br /&gt;
우선 &amp;nbsp;우리는 N개의 하노이를 한 기둥에서 다른기둥으로 옮기기 위해 이동해야하는 최소횟수는&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 81px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/123FA43D4F47B3862D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F123FA43D4F47B3862D&quot; width=&quot;81&quot; height=&quot;27&quot; filename=&quot;daum_equation_1330099066828.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;임이 자명하다.&lt;br /&gt;
&lt;br /&gt;
2)&lt;br /&gt;
그리고 우리가 최종적으로 옮겨야할 목적지는 가장 큰 조각이 위치한 기둥임을 직관적으로 알수 있을것이다.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
이유를 설명하자면 가장큰 조각이 존재하는 기둥을 P1이라고 한고 P2에 모든 조각을 모은다고 하자.&lt;br /&gt;
P2에는 어떠한 조각이 있더라도 가장 큰 조각이 P2의 가장 밑바닥에 깔려야 함으로 이는 P2의 모든조각을 P3으로 옮긴뒤 P1에 존재하는 가장 큰 조각을 P2 로 옮겨야된다. &amp;nbsp;그러나 생각해보면 맨처음 상태나 위와같이 가장큰 조각을 P2로 옮긴 뒤 상태나 기둥의 번호만 바뀔뿐 다른 것은 바뀐것이없다. 즉 필요없는 이동만 늘어난 샘이 된것이다.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
위 두 힌트를 잘 사용한다면&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 60px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/123E0F374F47B5D71C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F123E0F374F47B5D71C&quot; width=&quot;60&quot; height=&quot;27&quot; filename=&quot;daum_equation_1330099662203.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;솔루션을 만들어 낼수 있고,&lt;br /&gt;
&lt;p style=&quot;margin:0&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 60px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/1433EE3C4F47B61805&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F1433EE3C4F47B61805&quot; width=&quot;60&quot; height=&quot;27&quot; filename=&quot;daum_equation_1330099662203.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;에서 한줄만 바꾸면(주석처리만 하면)&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 52px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2060583B4F47B6352D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2060583B4F47B6352D&quot; width=&quot;52&quot; height=&quot;24&quot; filename=&quot;daum_equation_1330099758187.png&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;솔루션을 얻어 낼수 있을것이다.&lt;/p&gt;
&lt;br /&gt;
&lt;/div&gt;</description>
      <category>infomatics</category>
      <author>makesource</author>
      <guid isPermaLink="true">https://makesource.tistory.com/5</guid>
      <comments>https://makesource.tistory.com/entry/Hanoi-Tower#entry5comment</comments>
      <pubDate>Sat, 25 Feb 2012 01:09:41 +0900</pubDate>
    </item>
  </channel>
</rss>