<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>취미가 알고리즘</title>
    <link>https://emoney96.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Wed, 13 May 2026 03:02:58 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>와이에쓰</managingEditor>
    <image>
      <title>취미가 알고리즘</title>
      <url>https://tistory1.daumcdn.net/tistory/4466267/attach/72a3a0887b69442a9032dc71e409468e</url>
      <link>https://emoney96.tistory.com</link>
    </image>
    <item>
      <title>2019.05.14 ~ 2026.04.28</title>
      <link>https://emoney96.tistory.com/568</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;오늘 백준이 서비스 종료를 합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;아니 이미 했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1178&quot; data-origin-height=&quot;55&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bmnEaf/dJMcab440Nt/vhyydTAysf7qfNdkGBPN6K/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bmnEaf/dJMcab440Nt/vhyydTAysf7qfNdkGBPN6K/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bmnEaf/dJMcab440Nt/vhyydTAysf7qfNdkGBPN6K/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbmnEaf%2FdJMcab440Nt%2FvhyydTAysf7qfNdkGBPN6K%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1178&quot; height=&quot;55&quot; data-origin-width=&quot;1178&quot; data-origin-height=&quot;55&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1154&quot; data-origin-height=&quot;408&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/crxEvf/dJMcahK0VOs/sBeRJMqj8396CATbnNpFO1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/crxEvf/dJMcahK0VOs/sBeRJMqj8396CATbnNpFO1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/crxEvf/dJMcahK0VOs/sBeRJMqj8396CATbnNpFO1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcrxEvf%2FdJMcahK0VOs%2FsBeRJMqj8396CATbnNpFO1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1154&quot; height=&quot;408&quot; data-origin-width=&quot;1154&quot; data-origin-height=&quot;408&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;최종 티어는 다이아5 입니다. 루비도 한 문제 푼게 보이네요.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제는 총 2996문제를 풀었습니다. 2문제는 서버 오류로 인해 solved.ac에 반영이 되지 않아서 2994문제로 표시되어 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;목표했던 3000문제는 채우지 못했습니다. 마지막 날에 남은 4문제를 달려서 채울 생각이었지만 생각보다 이른 시간에 서버가 종료되는 바람에.. 너무 아쉽네요.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1183&quot; data-origin-height=&quot;546&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/SMhrZ/dJMcaffocJu/gaTCS0Xs2aZynpE6m23Bsk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/SMhrZ/dJMcaffocJu/gaTCS0Xs2aZynpE6m23Bsk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/SMhrZ/dJMcaffocJu/gaTCS0Xs2aZynpE6m23Bsk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FSMhrZ%2FdJMcaffocJu%2FgaTCS0Xs2aZynpE6m23Bsk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1183&quot; height=&quot;546&quot; data-origin-width=&quot;1183&quot; data-origin-height=&quot;546&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;최장 스트릭은 최종 11위로 마무리되었습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;앞에 10명을 벼르고 있었는데 끝까지 자리를 내어주지 않으시네요. 대단들 하십니다 진짜&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1153&quot; data-origin-height=&quot;360&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/lkHtE/dJMb990xbty/4GkVKFXu1uAQaLEEALRVQk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/lkHtE/dJMb990xbty/4GkVKFXu1uAQaLEEALRVQk/img.png&quot; data-alt=&quot;2021.07.26 ~ 2026.04.28&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/lkHtE/dJMb990xbty/4GkVKFXu1uAQaLEEALRVQk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FlkHtE%2FdJMb990xbty%2F4GkVKFXu1uAQaLEEALRVQk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1153&quot; height=&quot;360&quot; data-origin-width=&quot;1153&quot; data-origin-height=&quot;360&quot;/&gt;&lt;/span&gt;&lt;figcaption&gt;2021.07.26 ~ 2026.04.28&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1주일만 더 빨리 찾았더라면 1등으로 끝났을텐데. 아쉬움이 남습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;118&quot; data-origin-height=&quot;38&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/XYinp/dJMcagk0vp6/B3tPpFLokqb0qkZ0bEEfh1/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/XYinp/dJMcagk0vp6/B3tPpFLokqb0qkZ0bEEfh1/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/XYinp/dJMcagk0vp6/B3tPpFLokqb0qkZ0bEEfh1/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FXYinp%2FdJMcagk0vp6%2FB3tPpFLokqb0qkZ0bEEfh1%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;118&quot; height=&quot;38&quot; data-origin-width=&quot;118&quot; data-origin-height=&quot;38&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제푼거 날라가면 아까우니까 깃허브에 올려보자고 시작했었는데 커밋이 꽤 쌓였습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&lt;span style=&quot;background-color: #ffffff;&quot;&gt;이미 섭종했는데도 백준 들어가서 새로고침을 지금까지도 하고있는 저를 보니 꽤 진심이긴 했나봅니다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&lt;span style=&quot;background-color: #ffffff;&quot;&gt;사실 오늘 문제를 풀기도 전에 섭종을 해버렸어요.. 그래도 오늘 새벽에는 풀었다&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1226&quot; data-origin-height=&quot;133&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/AZmgQ/dJMb990xcaw/UAJyydVOW9YHpYAAI4gzKk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/AZmgQ/dJMb990xcaw/UAJyydVOW9YHpYAAI4gzKk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/AZmgQ/dJMb990xcaw/UAJyydVOW9YHpYAAI4gzKk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FAZmgQ%2FdJMb990xcaw%2FUAJyydVOW9YHpYAAI4gzKk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1226&quot; height=&quot;133&quot; data-origin-width=&quot;1226&quot; data-origin-height=&quot;133&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #000000; text-align: start;&quot;&gt;Hello World를 외치며 들어왔던 저는 Good Bye, BOJ!를 외치며 마지막 가는 길을 지켜보게 되었습니다.&lt;/span&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #000000; text-align: start;&quot;&gt;백준님 백준이 돌아올까요? 정말 감사했습니다.&lt;/span&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;span style=&quot;background-color: #ffffff; color: #000000; text-align: start;&quot;&gt;Good Bye, BOJ!&lt;/span&gt;&lt;/p&gt;</description>
      <category>잡담</category>
      <category>BOJ</category>
      <category>Good Bye BOJ!</category>
      <category>백준</category>
      <category>백준 서비스 종료</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/568</guid>
      <comments>https://emoney96.tistory.com/568#entry568comment</comments>
      <pubDate>Tue, 28 Apr 2026 23:01:14 +0900</pubDate>
    </item>
    <item>
      <title>백준 서비스 종료.</title>
      <link>https://emoney96.tistory.com/567</link>
      <description>&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1147&quot; data-origin-height=&quot;81&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/catjmu/dJMcadn6PqG/KKaXVcJ2ihZOnvSduuMjFk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/catjmu/dJMcadn6PqG/KKaXVcJ2ihZOnvSduuMjFk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/catjmu/dJMcadn6PqG/KKaXVcJ2ihZOnvSduuMjFk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fcatjmu%2FdJMcadn6PqG%2FKKaXVcJ2ihZOnvSduuMjFk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1147&quot; height=&quot;81&quot; data-origin-width=&quot;1147&quot; data-origin-height=&quot;81&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2019년 5월 14일. 과제에 시달리며 살던 저는 처음으로 코딩 공부를 하기위해 &quot;Hello World&quot; 를 외치며 백준으로 뛰어들었습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;단 몇개월만에 icpc 예선에서 학교 1등을 차지하여 본선에 진출하기도 했고, 그외 몇몇 알고리즘 대회에서 수상하기도 했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;대회에서 수상을 하면서 알고리즘 푸는것을 점점 좋아하게 되었습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;중간에 solved.ac 티어가 생겼고, 확인해보니 이미 플래티넘이던 기억과, 이후 회사다니면서 다이아를 찍었던 기억이 남아있습니다.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;무엇보다도 제 인생에서 처음으로 무언가를 내세울 수 있고, 자랑할 수 있는게 생겨서 좋았습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;사람들은 저를 보면서&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;알고리즘에 미친사람,&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;잠이 오면 알고리즘 푸는사람,&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;개발하다가 화나면 알고리즘 푸는사람,&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이렇게 부르고는 했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;특히 ssafy 교육시간에 막히는 부분이 있을때 저는 백준을 키고 문제를 풀었습니다. 마음이 편안해지는 순간이었습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;팀원들은 이해를 못하는 눈치였습니다. 진짜 재밌는데..&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;저는 현재 1725일째 1일 1알고리즘을 실천 중입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;ssafy 프로젝트를 하던 중 막히는 부분이 발생하여 백준으로 시선을 돌렸고, solved.ac에 깃허브처럼 잔디를 심는 기능이 추가된 것을 발견했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;저는 이건 해야지 하며 그날부터 바로 시작했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이후 취준생일때도, 취업을 하고나서도, 잠시 다른일을 하며 보내는 지금까지도 백준만큼은 놓지않고 1일 1알고리즘을 실천하고 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/board/view/165799&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/board/view/165799&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1151&quot; data-origin-height=&quot;608&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/qNMn4/dJMcaiiFQXq/6PLGxEm8vkCtes2KqwoJFk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/qNMn4/dJMcaiiFQXq/6PLGxEm8vkCtes2KqwoJFk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/qNMn4/dJMcaiiFQXq/6PLGxEm8vkCtes2KqwoJFk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FqNMn4%2FdJMcaiiFQXq%2F6PLGxEm8vkCtes2KqwoJFk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;1151&quot; height=&quot;608&quot; data-origin-width=&quot;1151&quot; data-origin-height=&quot;608&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 오늘 오후, 백준님의 서비스 종료 공지가 포스팅되었습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2026년 4월 28일을 끝으로 서비스가 종료된다고 합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;처음 이 글을 봤을때 처음 들었던 생각은 &quot;나 오늘 아직 안풀었는데&quot; 였습니다. 그냥 그렇다고요.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그냥 멍한 느낌이었습니다. 제 얼마 안되는 개발 인생을 함께 보낸 친구같은 존재였기 때문이죠.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그런 친구를 갑자기 놓게되는건 정말 쉽지 않을거라고 생각합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;당분간은 오늘 백준 풀었는지 한번 확인해보고 아 섭종했지 하고 다시 닫는 일이 생길 것 같네요.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;저도 벌써 입문한지 7년이 다되어가네요. 20대 중반부터 지금까지도 함께 하고있는 백준을 저도 덮어둘 때가 온 것 같습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;지금 저는 2950문제를 푼 상태입니다. 서비스 종료까지 남은 시간은 2주. 2주 내에 3000문제를 채우는 것을 목표로 막판 스퍼트를 해볼 생각입니다. 깔끔하잖아요.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;너무 갑작스러운 공지라 아직까지도 전혀 실감이 나지않고 글을 쓰는 지금까지도 무슨 생각이 드는지 잘 모르겠습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그저 돌아오실 날을 기다리면서 살아가려고 합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;백준 덕분에 행복했습니다. 감사합니다.&lt;/p&gt;</description>
      <category>잡담</category>
      <category>baekjoon</category>
      <category>BOJ</category>
      <category>ICPC</category>
      <category>백준</category>
      <category>백준 서비스종료</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/567</guid>
      <comments>https://emoney96.tistory.com/567#entry567comment</comments>
      <pubDate>Wed, 15 Apr 2026 22:22:16 +0900</pubDate>
    </item>
    <item>
      <title>boj 14848 정수 게임</title>
      <link>https://emoney96.tistory.com/566</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/14848&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/14848&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;요즘 빠져있는 포함 배제 원리 문제입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제에 나와있는 게임의 규칙은&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1. 정수 N과 크기가 K인 배열 A를 정한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. 1 ~ N의 정수를 모두 종이에 적는다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3. 배열 A의 정수를 하나씩 골라서 제거하고, 그 수의 배수를 종이에서 지운다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;4. 배열 A의 정수가 모두 제거될 때까지 3을 반복한다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위 내용을 정리하면&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1 ~ N의 정수 중에 배열 A의 정수들의 배수가 아닌 수의 갯수를 구해라.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;라는 문제가 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그러면 처음 생각해볼 수 있는건 배열 A의 정수를 하나씩 빼서 N / A[i]를 구하면 그게 A[i]의 배수의 갯수라고 볼 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;즉 N = 15, A = {3, 5}이면&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3의 배수는 15/3 =5개, 5의 배수는 15/5 = 3개 이렇게 쉽게 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;하지만 여기서 문제는 3의 배수와 5의 배수 모두 15가 포함된다는 것입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그래서 이런 중복되는 것들을 추가로 더해줘야하는 작업이 필요합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-filename=&quot;a.png&quot; data-origin-width=&quot;1800&quot; data-origin-height=&quot;1200&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bOAfCi/btsNpDI7PZw/7Ph92i8x7HhakfMXAapB20/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bOAfCi/btsNpDI7PZw/7Ph92i8x7HhakfMXAapB20/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bOAfCi/btsNpDI7PZw/7Ph92i8x7HhakfMXAapB20/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbOAfCi%2FbtsNpDI7PZw%2F7Ph92i8x7HhakfMXAapB20%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;537&quot; height=&quot;358&quot; data-filename=&quot;a.png&quot; data-origin-width=&quot;1800&quot; data-origin-height=&quot;1200&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위 벤 다이어그램을 참고했을 때 A가 3의 배수, B가 5의 배수, A &amp;cap; B가 15의 배수에 해당됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;A &amp;cup; B = A + B - A &amp;cap; B가 되고, 이걸 이용하여 포함 배제 원리 문제에 접근할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;여기서 수식만 봐도 겹치는 부분이 1개 (홀수)인 부분은 덧셈, 2개 (짝수)인 부분은 뺄셈 연산을 한다는 것을 알 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그러면 정수들을 적절하게 조합해서 나온 수들의 최소공배수가 교집합 부분이라는 것을 알 수 있고, 최소공배수로 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그냥 곱하면 안되는 이유로 4, 6을 들 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;4 * 6 = 24인데 12도 4의 배수와 6의 배수 둘다 포함됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;배열의 갯수는 K &amp;lt;= 15 입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;따라서 비트마스킹 사용이 가능합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1부터 비트 하나씩 조합을 확인할 수 있고, 포함된 수의 갯수와 최소공배수를 바로 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;다음은 곱해진 수를 전체 범위에서 나누기만 하면 답을 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 16.5px; padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;35&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;36&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;37&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;38&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;39&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;40&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;41&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;42&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;43&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;44&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;45&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;46&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;47&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;48&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;49&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;50&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;51&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;52&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;53&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;54&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;55&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;56&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#define&lt;/span&gt;&amp;nbsp;MAX&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;15&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;typedef&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;ll;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;list[MAX];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;gcd(ll&amp;nbsp;x,&amp;nbsp;ll&amp;nbsp;y)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;y&amp;nbsp;?&amp;nbsp;gcd(y,&amp;nbsp;x&amp;nbsp;%&amp;nbsp;y)&amp;nbsp;:&amp;nbsp;x;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;lcm(ll&amp;nbsp;x,&amp;nbsp;ll&amp;nbsp;y)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;gcd(x,&amp;nbsp;y);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ll&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;K);&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;cnt&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ll&amp;nbsp;tmp&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;1LL;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;K;&amp;nbsp;j&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;(i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;j)))&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cnt&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tmp&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;lcm(tmp,&amp;nbsp;list[j]);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(tmp&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(flag)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(cnt&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;)&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;tmp);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;else&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;tmp);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;K;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list[i];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/Inclusion-Exclusion Principal</category>
      <category>boj 14848</category>
      <category>inclusion-exclusion</category>
      <category>LCM</category>
      <category>백준 14848</category>
      <category>정수 게임</category>
      <category>포함 배제 원리</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/566</guid>
      <comments>https://emoney96.tistory.com/566#entry566comment</comments>
      <pubDate>Thu, 17 Apr 2025 15:47:24 +0900</pubDate>
    </item>
    <item>
      <title>boj 7121 Pencil Factory</title>
      <link>https://emoney96.tistory.com/565</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7121&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/7121&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;K일간 작업하여 N + 1의 배수일에는 페인팅 작업을, M + 1의 배수일에는 바니싱 작업을 하지 않고 쉽니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1. 페인팅과 바니싱을 모두 완료한 날&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. 페인팅과 바니싱 둘다 쉰 날&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3. 페인팅만 완료한 날&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;4. 바니싱만 완료한 날&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위 값들을 순서대로 구하는 문제입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;우선 작업을 언제 쉬었는지에 대해서는 전체 일수에서 처음 쉬는날인 N + 1과 M + 1을 각각 나눠주면 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;두 작업을 모두 완료한 날은 `전체 일 수 - 페인팅을 쉰 날 - 바니싱을 쉰 날 + 둘다 쉰 날`로 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;둘다 쉰 날은 두 작업의 최소공배수를 활용하여 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;둘중 하나만 완료한 날은 서로 반대 작업을 쉰날에서 둘다 쉰날을 빼면 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;typedef&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;ll;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;N,&amp;nbsp;M,&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;gcd(ll&amp;nbsp;x,&amp;nbsp;ll&amp;nbsp;y)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;y&amp;nbsp;?&amp;nbsp;gcd(y,&amp;nbsp;x&amp;nbsp;%&amp;nbsp;y)&amp;nbsp;:&amp;nbsp;x;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;lcm(ll&amp;nbsp;x,&amp;nbsp;ll&amp;nbsp;y)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;gcd(x,&amp;nbsp;y);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ll&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;K&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ll&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;K&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;(M&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ll&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;K&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;/&lt;/span&gt;&amp;nbsp;lcm(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;M&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;K&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'&amp;nbsp;'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'&amp;nbsp;'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'&amp;nbsp;'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;M&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/Inclusion-Exclusion Principal</category>
      <category>boj 7121</category>
      <category>inclusion-exclusion</category>
      <category>pencil factory</category>
      <category>백준 7121</category>
      <category>포함배제 원리</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/565</guid>
      <comments>https://emoney96.tistory.com/565#entry565comment</comments>
      <pubDate>Sat, 12 Apr 2025 22:07:14 +0900</pubDate>
    </item>
    <item>
      <title>boj 29721 변형 체스 놀이 : 다바바(Dabbaba)</title>
      <link>https://emoney96.tistory.com/564</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/29721&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/29721&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제 난이도는 쉬운 편이지만 cpp의 unordered_set에 대해 새롭게 알게된 부분이 있어서 정리해봅니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;문제는 체스판 위에 놓여져 있는 다바바를 이동시킬 수 있는 칸이 몇 개인지 세기만 하면 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;다바바는 상하좌우로 2칸만 이동할 수 있으며 나이트처럼 경로에 위치한 다른 기물을 뛰어 넘을 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;체스판의 크기가 10만이므로 배열로는 해결할 수 없습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;set과 unordered_set 둘다 사용이 가능했지만 정렬이 필요없기에 unordered_set을 사용했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;문제 로직은 간단합니다.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;다바바는 맵 밖이나 다른 다바바가 위치한 좌표에는 갈 수 없으니 최초 다바바의 위치는 set에 미리 넣어둡니다.&lt;/p&gt;
&lt;p style=&quot;color: #333333; text-align: start;&quot; data-ke-size=&quot;size16&quot;&gt;이후에 상하좌우로 2칸씩 이동시켜서 set에 insert하고, 그 횟수를 구하면 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;32&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/deHkGP/btsMg5n3vxS/vj60bCC0zpybJEexBi3w61/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/deHkGP/btsMg5n3vxS/vj60bCC0zpybJEexBi3w61/img.png&quot; data-alt=&quot;set&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/deHkGP/btsMg5n3vxS/vj60bCC0zpybJEexBi3w61/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdeHkGP%2FbtsMg5n3vxS%2Fvj60bCC0zpybJEexBi3w61%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;914&quot; height=&quot;32&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;32&quot;/&gt;&lt;/span&gt;&lt;figcaption&gt;set&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;31&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/d6wpi2/btsMhmC6wWm/YBBzsCau2Ya4tc9mJW1670/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/d6wpi2/btsMhmC6wWm/YBBzsCau2Ya4tc9mJW1670/img.png&quot; data-alt=&quot;unordered_set&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/d6wpi2/btsMhmC6wWm/YBBzsCau2Ya4tc9mJW1670/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fd6wpi2%2FbtsMhmC6wWm%2FYBBzsCau2Ya4tc9mJW1670%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;914&quot; height=&quot;31&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;31&quot;/&gt;&lt;/span&gt;&lt;figcaption&gt;unordered_set&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;확실히 메모리와 시간이 줄어드는 것을 확인할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;저는 처음에는 set을 활용하여 문제를 풀었고, 시간을 줄이기 위해 unordered_set으로 바꾸는 도중에 컴파일 에러가 떴는데&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;849&quot; data-origin-height=&quot;62&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bvvspw/btsMhwevylG/0IenK3DDgrrmmwhFwesXCk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bvvspw/btsMhwevylG/0IenK3DDgrrmmwhFwesXCk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bvvspw/btsMhwevylG/0IenK3DDgrrmmwhFwesXCk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbvvspw%2FbtsMhwevylG%2F0IenK3DDgrrmmwhFwesXCk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;849&quot; height=&quot;62&quot; data-origin-width=&quot;849&quot; data-origin-height=&quot;62&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;unordered_set은 key를 해시화해서 사용하는데 pair에 대한 기본 해시 함수가 없기 때문에 발생한 에러였고, 해시 함수를 직접 정의를 해야했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;struct&lt;/span&gt;&amp;nbsp;pair_hash&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_t&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;operator&lt;/span&gt;()(&lt;span style=&quot;color: #ff3399;&quot;&gt;const&lt;/span&gt;&amp;nbsp;pii&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;p)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;const&lt;/span&gt;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;hash&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;()(p.first)&amp;nbsp;^&amp;nbsp;hash&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;()(p.second);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;};&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이런식으로 해시 함수를 직접 정의할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;다만 이렇게 둔다면 p.first와 p.second가 비슷한 값이면 해시 충돌이 많이 발생한다고 합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;특히 이 문제에서는 상하좌우로 2칸씩만 이동하기 때문에 치명적인 문제가 될 수 있겠다는 생각이 들었습니다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;32&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/bfx8ee/btsMi0ZNjPC/lEjdqeu7OqzD5kDgKgimTk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/bfx8ee/btsMi0ZNjPC/lEjdqeu7OqzD5kDgKgimTk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/bfx8ee/btsMi0ZNjPC/lEjdqeu7OqzD5kDgKgimTk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbfx8ee%2FbtsMi0ZNjPC%2FlEjdqeu7OqzD5kDgKgimTk%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;914&quot; height=&quot;32&quot; data-origin-width=&quot;914&quot; data-origin-height=&quot;32&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;역시나 TLE가 떴습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;p.first나 p.second 둘 중 하나에 소수를 곱해준다면 충돌 확률을 낮추는 효과를 가져올 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;다만 너무 큰 숫자를 곱하게 되면 곱셈 연산에 소요되는 시간이 더 많이 발생할 수 있으니 적당한 수를 곱하는게 좋아보입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 양쪽 모두 소수를 곱하는 방법도 있는데 충돌은 줄어들겠지만 그만큼 곱셈 연산이 더 늘어나서 시간이 더 소요될 수 있습니다.&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 16.5px; padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;35&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;36&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;37&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;38&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;39&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;40&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;41&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;42&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;43&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;44&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;45&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;46&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;47&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;48&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;49&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;50&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;51&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;52&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;53&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;54&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;55&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;56&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;57&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;unordered_set&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#define&lt;/span&gt;&amp;nbsp;MAX&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;100001&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;typedef&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;pair&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;pii;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;struct&lt;/span&gt;&amp;nbsp;pair_hash&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_t&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;operator&lt;/span&gt;()(&lt;span style=&quot;color: #ff3399;&quot;&gt;const&lt;/span&gt;&amp;nbsp;pii&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;p)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;const&lt;/span&gt;&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;hash&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;()(p.first)&amp;nbsp;^&amp;nbsp;(hash&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;()(p.second)&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;31&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;};&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;unordered_set&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;pii,&amp;nbsp;pair_hash&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;s;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;pii&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;v;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;direct[&lt;span style=&quot;color: #c10aff;&quot;&gt;4&lt;/span&gt;][&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&amp;nbsp;{&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;},{&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;},{&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;},{&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;}&amp;nbsp;};&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;N,&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ff3399;&quot;&gt;auto&lt;/span&gt;&amp;nbsp;xy&amp;nbsp;:&amp;nbsp;v)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;xy.first;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;xy.second;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;d&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;d&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;4&lt;/span&gt;;&amp;nbsp;d&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;nx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;direct[d][&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;y&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;direct[d][&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(nx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&amp;nbsp;nx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&amp;nbsp;ny&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N)&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(s.find({&amp;nbsp;nx,ny&amp;nbsp;})&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;s.&lt;span style=&quot;color: #4be6fa;&quot;&gt;end&lt;/span&gt;())&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;continue&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s.insert({&amp;nbsp;nx,ny&amp;nbsp;});&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;x,&amp;nbsp;y;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;K;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;K;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;y;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v.&lt;span style=&quot;color: #4be6fa;&quot;&gt;push_back&lt;/span&gt;({&amp;nbsp;x,y&amp;nbsp;});&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s.insert({&amp;nbsp;x,y&amp;nbsp;});&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>algorithm/data-structure</category>
      <category>boj 29721</category>
      <category>Set</category>
      <category>unordered_set</category>
      <category>백준 29721</category>
      <category>변형 체스 놀이 : 다바바(dabbaba)</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/564</guid>
      <comments>https://emoney96.tistory.com/564#entry564comment</comments>
      <pubDate>Fri, 14 Feb 2025 11:11:34 +0900</pubDate>
    </item>
    <item>
      <title>boj 27966 △</title>
      <link>https://emoney96.tistory.com/562</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/27966&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/27966&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;N개의 정점으로 이루어진 트리에서 i &amp;lt; j인 정점들 사이 거리가 최소가 되도록 하려면 어떤 트리를 만들어야하는지 구하는 문제입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;트리를 직접 그려보면 Star Graph 형식이 최소가 된다는 것을 알 수 있습니다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignLeft&quot; data-ke-mobileStyle=&quot;widthOrigin&quot; data-origin-width=&quot;1200&quot; data-origin-height=&quot;1200&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/dVeQqb/btsJbZwXFi7/Neen75zq6lPBs3jAuBErw0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/dVeQqb/btsJbZwXFi7/Neen75zq6lPBs3jAuBErw0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/dVeQqb/btsJbZwXFi7/Neen75zq6lPBs3jAuBErw0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdVeQqb%2FbtsJbZwXFi7%2FNeen75zq6lPBs3jAuBErw0%2Fimg.png&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot; loading=&quot;lazy&quot; width=&quot;254&quot; height=&quot;254&quot; data-origin-width=&quot;1200&quot; data-origin-height=&quot;1200&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;Star Graph는 하나의 정점에 다른 모든 정점이 연결된 형태입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이렇게되면 1번 정점과 연결된 다른 정점은 거리가 각각 1입니다. (N - 1)&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;나머지 정점들끼리의 거리는 각각 2입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;나머지 N - 1개의 정점에서 2개를 고르는 경우의 수는 N-1C2이며, 두개 곱하면 (N - 2) * (N - 1)이 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위에서 구한 두 수를 더하면 N - 1 + (N - 2) * (N - 1) 이라는 답을 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;스페셜 저지 문제이기 때문에 기준이 되는 정점을 아무거나 고르시면 됩니다. 저는 1번 정점을 기준으로 정했습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 기준이 되는 정점과 i를 반복해서 출력해주시면 되겠습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 16.5px; padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;typedef&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;ll;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;1LL&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;2LL)&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;*&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;1LL)&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;2&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;&quot;1&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/ad-hoc</category>
      <category>ad-hoc</category>
      <category>boj 27966</category>
      <category>Math</category>
      <category>△</category>
      <category>백준 27966</category>
      <category>애드혹</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/562</guid>
      <comments>https://emoney96.tistory.com/562#entry562comment</comments>
      <pubDate>Thu, 22 Aug 2024 17:53:09 +0900</pubDate>
    </item>
    <item>
      <title>boj 7982 순열 그래프의 연결성 판별</title>
      <link>https://emoney96.tistory.com/561</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/7982&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/7982&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;순열 그래프는 N개의 정점이 1 ~ N의 번호가 하나씩 구성되어 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 두 정점 쌍 i, j (1 &amp;le; i &amp;lt; j &amp;le; n) 는 ai &amp;gt; aj 일때 간선으로 연결되어 있습니다.&lt;/p&gt;
&lt;pre id=&quot;code_1723804367107&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;4
2 3 1 4&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;순열이 이렇게 주어졌을 때&amp;nbsp; 2, 3 &amp;gt; 1이므로 (1, 2), (1, 3)이 각각 연결되어 있고&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;(1, 2, 3) (4) 로 집합을 나눌 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;여기서 알 수 있는건 i번째 까지 순회했을때 max가 i이면 해당 위치까지 하나의 집합으로 묶을 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위의 예시로 보면&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;3번 인덱스까지의 max가 3이므로 1, 2, 3을 집합으로 묶을 수 있고, 4번 인덱스까지의 max가 4이므로 4를 집합으로 묶을 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이전 집합의 max값을 유지해주면서 배열을 순회하면 정답을 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;35&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;36&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;37&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;38&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;39&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;40&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;41&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;42&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;43&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#define&lt;/span&gt;&amp;nbsp;MAX&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1000001&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;v;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;list[MAX];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;maxValue&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;maxValue&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;max(maxValue,&amp;nbsp;list[i]);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;maxValue)&amp;nbsp;v.&lt;span style=&quot;color: #4be6fa;&quot;&gt;push_back&lt;/span&gt;(i);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;pre&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;v.&lt;span style=&quot;color: #4be6fa;&quot;&gt;size&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ff3399;&quot;&gt;auto&lt;/span&gt;&amp;nbsp;x&amp;nbsp;:&amp;nbsp;v)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;pre&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'&amp;nbsp;'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;pre&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;x;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'&amp;nbsp;'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;x;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list[i];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/ad-hoc</category>
      <category>ad-hoc</category>
      <category>boj 7982</category>
      <category>백준 7982</category>
      <category>순열 그래프의 연결성 판별</category>
      <category>애드혹</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/561</guid>
      <comments>https://emoney96.tistory.com/561#entry561comment</comments>
      <pubDate>Fri, 16 Aug 2024 20:34:35 +0900</pubDate>
    </item>
    <item>
      <title>boj 16161 가장 긴 증가하는 팰린드롬 부분수열</title>
      <link>https://emoney96.tistory.com/560</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/16161&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/16161&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;팰린드롬은 앞/뒤에서 읽었을 때 같은 수열입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이 문제에서는 증가하는 팰린드롬을 구해야 합니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1723711324504&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;1, 2, 3, 4, 3, 2, 1
1, 3, 6, 7, 7, 6, 3, 1&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이런것처럼 중앙으로 갈수록 값이 커지는 것이 증가하는 팰린드롬 수열입니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1723711376701&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;1, 2, 4, 3, 2, 1
4, 3, 2, 3, 4
1, 1, 1, 1&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;증가하는 팰린드롬이 아닌 경우는&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;1. 애초에 팰린드롬이 아닌 경우&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;2. 팰린드롬이지만 값이 증가하지 않는 경우 (값이 같아도 x)&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이렇게 두가지가 되겠습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;저는 중앙을 먼저 정해놓고 한칸씩 이동하여 팰린드롬의 길이를 직접 구해봤습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;팰린드롬의 길이에 따라 중앙은 1개 or 2개가 될 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;따라서 l번째 수와 l + 1번째 수가 같으면 묶어서 중앙으로 두고 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이후에는 그냥 왼쪽, 오른쪽으로 한칸씩 이동하면서 증가하는 팰린드롬인지 확인해주시고, 최대 길이를 갱신해주시면 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 이 문제가 &quot;증가하는 팰린드롬&quot;이기 때문에 하나 더 생각할 수 있는건&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;s ~ e 범위의 팰린드롬을 찾았다고 했을 때, list[s], list[e]은 해당 팰린드롬에서 항상 가장 작은 수를 담당하고 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그렇기 때문에 e번째 수에서 왼쪽으로 이동하더라도 큰 수가 있을 수밖에 없고, 더 큰 범위의 팰린드롬을 찾을 수 없습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;따라서 중앙값인 l, r을 +1씩 볼 필요 없이 s ~ e 범위의 다음 인덱스부터 다시 확인해주시면 불필요한 계산 없이 정답을 구할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;35&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;36&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;37&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;38&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;39&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;40&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;41&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;42&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;43&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;44&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;45&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#define&lt;/span&gt;&amp;nbsp;MAX&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;100001&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;list[MAX];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;l&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(l&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;r&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;l;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(r&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;list[l]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list[r&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;])&amp;nbsp;r&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;l&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;r&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(s&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(list[s]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list[e]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;|&lt;/span&gt;&amp;nbsp;list[s]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list[s&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;])&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;max(ret,&amp;nbsp;e&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;l&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;e;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;N;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list[i];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/ad-hoc</category>
      <category>ad-hoc</category>
      <category>BOJ 16161</category>
      <category>가장 긴 증가하는 팰린드롬 부분수열</category>
      <category>백준 16161</category>
      <category>애드혹</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/560</guid>
      <comments>https://emoney96.tistory.com/560#entry560comment</comments>
      <pubDate>Thu, 15 Aug 2024 17:59:48 +0900</pubDate>
    </item>
    <item>
      <title>boj 1756 피자 굽기</title>
      <link>https://emoney96.tistory.com/559</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/1756&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/1756&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;오븐의 깊이에 따라 피자가 들어갈 수 있는 크기가 다릅니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;오븐에 피자를 위에서부터 차례대로 쌓는 방식인데 중간에 크기가 좁은 오븐을 만나면 더이상 내려갈 수 없습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;따라서 오븐의 크기를 먼저 조정해줄 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1723117003687&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;5 6 4 3 6 2 3&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;오븐의 크기가 위에서부터 이렇게 주어진다면&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;위에서부터 최솟값을 갱신한다면&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1723117052971&quot; class=&quot;bash&quot; data-ke-language=&quot;bash&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;5 5 4 3 3 2 2&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이렇게 바뀌게되고, 크기가 같거나 작아지는 수열이 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그러면 위에서부터 크기가 맞는 높이를 계속 찾아줄 필요 없이 밑에서부터 맞는 크기를 찾아주면 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;N에서 시작하여 피자가 들어갈 수 있는 높이라면 바로 넣어주는 방식으로 해결할 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 16.5px; padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;29&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;30&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;31&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;32&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;33&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;34&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;35&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;36&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;37&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;38&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;39&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;40&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;41&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;42&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;43&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;44&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;45&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;46&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;47&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;48&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;49&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;50&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;51&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;52&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#define&lt;/span&gt;&amp;nbsp;MAX&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;300001&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;width[MAX];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;list[MAX];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;N,&amp;nbsp;M;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;idx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;M;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(idx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(width[idx]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;list[i])&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idx&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;flag&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;idx&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;!&lt;/span&gt;flag)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;&quot;0\n&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;idx&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;'\n'&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;M;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;N;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;width[i];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;width[i]&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;min(width[i],&amp;nbsp;width[i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;1&lt;/span&gt;]);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;M;&amp;nbsp;i&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list[i];&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic;&quot;&gt;&lt;a style=&quot;color: #4f4f4ftext-decoration:none;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/Implementation</category>
      <category>boj 1756</category>
      <category>IMPLEMENTATION</category>
      <category>구현</category>
      <category>백준 1756</category>
      <category>피자 굽기</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/559</guid>
      <comments>https://emoney96.tistory.com/559#entry559comment</comments>
      <pubDate>Thu, 8 Aug 2024 20:43:55 +0900</pubDate>
    </item>
    <item>
      <title>boj 24553 팰린드롬 게임</title>
      <link>https://emoney96.tistory.com/558</link>
      <description>&lt;p data-ke-size=&quot;size16&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/24553&quot; target=&quot;_blank&quot; rel=&quot;noopener&amp;nbsp;noreferrer&quot;&gt;https://www.acmicpc.net/problem/24553&lt;/a&gt;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;N개의 돌 중에 팰린드롬 수만큼의 돌을 가져갈 수 있으며, 마지막에 모든 돌을 가져가는 사람이 이깁니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;우선 1 ~ 9는 팰린드롬이므로 무조건 먼저하는 사람이 이깁니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;N = 10이라면 1 ~ 9개를 가져가더라도 9 ~ 1개는 무조건 남기 때문에 먼저하는 사람이 집니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;그리고 N = 11 ~ 19는 1 ~ 9를 적절하게 뺀다면 다음 사람에게 10을 넘겨줄 수 있으므로 무조건 이길 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;이런식으로 간다면 10의 배수가 아닐때는 무조건 선공이 이긴다는 것을 알 수 있습니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;0으로 시작하는 수는 없으므로 10의 배수는 팰린드롬이 올 수 없으므로 다른건 고려하지 않아도 됩니다.&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class=&quot;colorscripter-code&quot; style=&quot;color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position: relative !important; overflow: auto;&quot;&gt;
&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0; padding: 0; border: none; background-color: #272727; border-radius: 4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; data-ke-align=&quot;alignLeft&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;width: 16.5px; padding: 6px; border-right: 2px solid #4f4f4f;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; word-break: normal; text-align: right; color: #aaa; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;1&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;2&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;3&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;4&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;5&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;6&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;7&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;8&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;9&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;10&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;11&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;12&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;13&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;14&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;15&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;16&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;17&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;18&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;19&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;20&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;21&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;22&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;23&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;24&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;25&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;26&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;27&lt;/div&gt;
&lt;div style=&quot;line-height: 130%;&quot;&gt;28&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;padding: 6px 0; text-align: left;&quot;&gt;
&lt;div style=&quot;margin: 0; padding: 0; color: #f0f0f0; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height: 130%;&quot;&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #0086b3;&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;typedef&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;long&lt;/span&gt;&amp;nbsp;ll;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;ll&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;func()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(N&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;10&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;&quot;0\n&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ffd500;&quot;&gt;&quot;1\n&quot;&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;void&lt;/span&gt;&amp;nbsp;input()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;N;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cout&lt;/span&gt;.tie(&lt;span style=&quot;color: #0086b3;&quot;&gt;NULL&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ios::sync_with_stdio(&lt;span style=&quot;color: #ff3399;&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;int&lt;/span&gt;&amp;nbsp;tc;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4be6fa;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;tc;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(tc&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #aaffaa;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: #ff3399;&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;func();&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #ff3399;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c10aff;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;
&lt;div style=&quot;padding: 0 6px; white-space: pre; line-height: 130%;&quot;&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td style=&quot;vertical-align: bottom; padding: 0 2px 4px 0;&quot;&gt;&lt;a style=&quot;text-decoration: none; color: white;&quot; href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: #4f4f4f; color: white; border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
      <category>algorithm/ad-hoc</category>
      <category>ad-hoc</category>
      <category>boj 24553</category>
      <category>백준 24553</category>
      <category>애드혹</category>
      <category>팰린드롬 게임</category>
      <author>와이에쓰</author>
      <guid isPermaLink="true">https://emoney96.tistory.com/558</guid>
      <comments>https://emoney96.tistory.com/558#entry558comment</comments>
      <pubDate>Wed, 7 Aug 2024 09:41:27 +0900</pubDate>
    </item>
  </channel>
</rss>