<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>히더</title>
    <link>https://2heedu.tistory.com/</link>
    <description>알고리즘,  SW, IT, 트렌드, 디자인, 취미</description>
    <language>ko</language>
    <pubDate>Fri, 12 Jun 2026 19:54:35 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>히더</managingEditor>
    <image>
      <title>히더</title>
      <url>https://tistory1.daumcdn.net/tistory/2925810/attach/03202c3665e64e06af3f8b6be973a788</url>
      <link>https://2heedu.tistory.com</link>
    </image>
    <item>
      <title>[BOJ 17837] 새로운 게임 2</title>
      <link>https://2heedu.tistory.com/175</link>
      <description>&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;백준 :: BOJ :: 17837 :: 새로운 게임 2&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #333333;&quot;&gt;출처 : &lt;a href=&quot;https://www.acmicpc.net/problem/17837&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/17837&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1573002535614&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-og-type=&quot;website&quot; data-og-title=&quot;17837번: 새로운 게임 2&quot; data-og-description=&quot;재현이는 주변을 살펴보던 중 체스판과 말을 이용해서 새로운 게임을 만들기로 했다. 새로운 게임은 크기가 N&amp;times;N인 체스판에서 진행되고, 사용하는 말의 개수는 K개이다.&amp;nbsp;말은 원판모양이고, 하나의 말 위에 다른 말을 올릴 수 있다. 체스판의 각 칸은 흰색, 빨간색, 파란색 중 하나로 색칠되어있다. 게임은 체스판 위에 말 K개를&amp;nbsp;놓고 시작한다. 말은 1번부터 K번까지 번호가 매겨져 있고,&amp;nbsp;이동 방향도 미리 정해져 있다. 이동 방향은 위, 아래, 왼쪽, 오른쪽 &quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/17837&quot; data-og-url=&quot;https://www.acmicpc.net/problem/17837&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/CTKwf/hyDzvOHKAP/svUoh9zKKC5kTpLQZBkay0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/iggwY/hyDBvfdPBS/D0P2VRcbhqtHmtLpKL0VsK/img.png?width=834&amp;amp;height=838&amp;amp;face=0_0_834_838,https://scrap.kakaocdn.net/dn/bBVqBZ/hyDzC77IbM/bnpGZH57n8Xd134r5lXEk0/img.png?width=834&amp;amp;height=836&amp;amp;face=0_0_834_836&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/17837&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/17837&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/CTKwf/hyDzvOHKAP/svUoh9zKKC5kTpLQZBkay0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/iggwY/hyDBvfdPBS/D0P2VRcbhqtHmtLpKL0VsK/img.png?width=834&amp;amp;height=838&amp;amp;face=0_0_834_838,https://scrap.kakaocdn.net/dn/bBVqBZ/hyDzC77IbM/bnpGZH57n8Xd134r5lXEk0/img.png?width=834&amp;amp;height=836&amp;amp;face=0_0_834_836');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;17837번: 새로운 게임 2&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;재현이는 주변을 살펴보던 중 체스판과 말을 이용해서 새로운 게임을 만들기로 했다. 새로운 게임은 크기가 N&amp;times;N인 체스판에서 진행되고, 사용하는 말의 개수는 K개이다.&amp;nbsp;말은 원판모양이고, 하나의 말 위에 다른 말을 올릴 수 있다. 체스판의 각 칸은 흰색, 빨간색, 파란색 중 하나로 색칠되어있다. 게임은 체스판 위에 말 K개를&amp;nbsp;놓고 시작한다. 말은 1번부터 K번까지 번호가 매겨져 있고,&amp;nbsp;이동 방향도 미리 정해져 있다. 이동 방향은 위, 아래, 왼쪽, 오른쪽&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;www.acmicpc.net&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1573002550303&quot; class=&quot;c++ cpp&quot; data-ke-language=&quot;c++&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define F(p,q,r) for(int p=q; p&amp;lt;r; p++)
struct S { int y, x, d; };
int N, K,a,b,c,t,fl, A[14][14], dir[5][2] = { {},{0,1},{0,-1},{-1,0},{1,0} };
deque&amp;lt;int&amp;gt; B[14][14]; S C[11];

int main() {
	cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; K;
	F(i, 0, N + 2) {
		F(j, 0, N + 2) {
			if (!i || !j || i &amp;gt; N || j &amp;gt; N) A[i][j] = 2;
			else cin &amp;gt;&amp;gt; A[i][j];
		}
	}
	F(i, 0, K) {
		cin &amp;gt;&amp;gt; C[i].y &amp;gt;&amp;gt; C[i].x &amp;gt;&amp;gt; C[i].d; B[C[i].y][C[i].x].push_back(i);
	}
	while (t++ &amp;lt; 1000) {
		F(i, 0, K) {
			a = C[i].y, b = C[i].x, c = C[i].d;
			a += dir[c][0]; b += dir[c][1]; int si = C[i].y, sj = C[i].x;
			if (A[a][b] &amp;gt; 1) {
				c += 1; if (c == 3)c = 1; if (c == 5)c = 3; C[i].d = c;
				a += dir[c][0]; b += dir[c][1];
				if(A[a+dir[c][0]][b+dir[c][1]]&amp;lt;2) a += dir[c][0], b += dir[c][1];			
			}
			int f, D=0,l=B[si][sj].size(), s=0;
			if (A[a][b] == 1) {
				for (int j = l - 1; j &amp;gt;= 0; j--) {
					s = B[si][sj][j]; C[s].y = a; C[s].x = b;
					B[a][b].push_back(s); B[si][sj].pop_back();
					 if (s == i)break;
				}
			}
			else {
				F(j, 0, l) {
					f = B[si][sj][j]; if (f == i) s = 1;
					if (s == 1) {
						C[f].y = a; C[f].x = b; B[a][b].push_back(f); D++;
					}
				}
				while (D-- &amp;gt; 0) B[si][sj].pop_back();
			}
			if (B[a][b].size() &amp;gt;= 4) { fl = 1; break; }
		}
		if (fl)break;
	}
	cout &amp;lt;&amp;lt; ((t &amp;gt; 1000)?-1:t);
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17837</category>
      <category>boj</category>
      <category>백준</category>
      <category>삼성</category>
      <category>새로운 게임 2</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/175</guid>
      <comments>https://2heedu.tistory.com/175#entry175comment</comments>
      <pubDate>Wed, 6 Nov 2019 10:09:36 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 17779] 게리맨더링 2</title>
      <link>https://2heedu.tistory.com/174</link>
      <description>&lt;p&gt;백준 :: BOJ :: 17779 :: 게리맨더링 2&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;출처 : &lt;a href=&quot;https://www.acmicpc.net/problem/17779&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/17779&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1571923193862&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-og-type=&quot;website&quot; data-og-title=&quot;17779번: 게리맨더링 2&quot; data-og-description=&quot;재현시의 시장 구재현은 지난 몇 년간 게리맨더링을 통해서 자신의 당에게 유리하게 선거구를 획정했다. 견제할 권력이 없어진 구재현은&amp;nbsp;권력을 매우 부당하게 행사했고, 심지어는 시의 이름도 재현시로 변경했다. 이번 선거에서는 최대한 공평하게 선거구를 획정하려고 한다. 재현시는 크기가 N&amp;times;N인 격자로 나타낼 수 있다. 격자의 각 칸은 구역을 의미하고, r행 c열에 있는 구역은 (r, c)로 나타낼 수 있다. 구역을 다섯 개의 선거구로 나눠야 하고, 각 구역은 다&quot; data-og-host=&quot;www.acmicpc.net&quot; data-og-source-url=&quot;https://www.acmicpc.net/problem/17779&quot; data-og-url=&quot;https://www.acmicpc.net/problem/17779&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/cwVskP/hyDoHAs8nI/9dgW36D1OH3UBk6bgDr6i1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/blwBAO/hyDoC6Z19m/MGQcB6vhVEAyv3x2ZbjJ6k/img.png?width=1014&amp;amp;height=1022&amp;amp;face=0_0_1014_1022,https://scrap.kakaocdn.net/dn/bp6i07/hyDoK41psA/T0wEGNk6Jc4XIXhNPAGbf0/img.png?width=902&amp;amp;height=910&amp;amp;face=0_0_902_910&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/17779&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.acmicpc.net/problem/17779&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/cwVskP/hyDoHAs8nI/9dgW36D1OH3UBk6bgDr6i1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630,https://scrap.kakaocdn.net/dn/blwBAO/hyDoC6Z19m/MGQcB6vhVEAyv3x2ZbjJ6k/img.png?width=1014&amp;amp;height=1022&amp;amp;face=0_0_1014_1022,https://scrap.kakaocdn.net/dn/bp6i07/hyDoK41psA/T0wEGNk6Jc4XIXhNPAGbf0/img.png?width=902&amp;amp;height=910&amp;amp;face=0_0_902_910');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;17779번: 게리맨더링 2&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;재현시의 시장 구재현은 지난 몇 년간 게리맨더링을 통해서 자신의 당에게 유리하게 선거구를 획정했다. 견제할 권력이 없어진 구재현은&amp;nbsp;권력을 매우 부당하게 행사했고, 심지어는 시의 이름도 재현시로 변경했다. 이번 선거에서는 최대한 공평하게 선거구를 획정하려고 한다. 재현시는 크기가 N&amp;times;N인 격자로 나타낼 수 있다. 격자의 각 칸은 구역을 의미하고, r행 c열에 있는 구역은 (r, c)로 나타낼 수 있다. 구역을 다섯 개의 선거구로 나눠야 하고, 각 구역은 다&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;www.acmicpc.net&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1571923205294&quot; class=&quot;c++ cpp&quot; data-ke-language=&quot;c++&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define F(p,q,r) for(int p=q; p&amp;lt;r; p++)
int N, A[20][20], s, t, ans = 1e5, v, D[4][2] = { {0,-1},{1,0},{0,1},{-1,0} };

int main() {
	cin &amp;gt;&amp;gt; N;
	F(i, 0, N) {
		F(j, 0, N) {
			cin &amp;gt;&amp;gt; A[i][j]; s += A[i][j];
		}
	}
	F(i, 0, N - 2) {
		F(j, 1, N - 1) {
			F(n1, 1, j + 1) {
				F(n2, 1, N-j) {
					if (i + n1 + n2 &amp;gt;= N) break;
					t = s; int B[5] = { 0, }, ma = 0, mi = 1e5,
						C[4][6] = { {0,i+n1,i,0,j+1,N},{0,i+n2+1,i+1,j+1,N,N},
					{i+n1,N,0,0,j-n1-1,i+n1+n2+1},{i+n2+1,N,0,j+n2+1,N,i+n1+n2+2} };
					F(k, 0, 4) {
						v = 0; F(y, C[k][0], C[k][1]) {
							if (y &amp;gt;= C[k][2] &amp;amp;&amp;amp; y&amp;lt;C[k][5]) v++;
							int c1 = C[k][3] + D[k][0]*v, c2= C[k][4] + D[k][1]*v;
							F(x, c1, c2) B[k] += A[y][x];
						}
						ma = max(ma, B[k]); mi = min(mi, B[k]); t -= B[k];
					} ma = max(ma, t); mi = min(mi, t);
					ans = min(ans, ma-mi);
				}
			}
		}
	}
	cout &amp;lt;&amp;lt; ans;
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17779</category>
      <category>boj</category>
      <category>게리맨더링 2</category>
      <category>백준</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/174</guid>
      <comments>https://2heedu.tistory.com/174#entry174comment</comments>
      <pubDate>Thu, 24 Oct 2019 22:21:43 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 17142] 연구소 3</title>
      <link>https://2heedu.tistory.com/173</link>
      <description>&lt;p&gt;백준 :: BOJ :: 17142 :: 연구소 3&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/17142&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/17142&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1568797986976&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/17142&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-original-url=&quot;https://www.acmicpc.net/problem/17142&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/eiNi1g/hyCRXZTOEx/oby6ARZu5bOjZPrka824n1/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;17142번: 연구소 3&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;인체에 치명적인 바이러스를 연구하던 연구소에&amp;nbsp;승원이가 침입했고, 바이러스를 유출하려고 한다. 바이러스는 활성 상태와 비활성 상태가 있다. 가장 처음에 모든 바이러스는 비활성 상태이고, 활성 상태인 바이러스는 상하좌우로 인접한 모든 빈 칸으로 동시에&amp;nbsp;복제되며, 1초가 걸린다. 승원이는 연구소의&amp;nbsp;바이러스 M개를 활성 상태로 변경하려고 한다. 연구소는 크기가 N&amp;times;N인 정사각형으로 나타낼 수 있으며, 정사각형은 1&amp;times;1 크기의 정사각형으로 나누어져 있다. 연구소는&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;www.acmicpc.net&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1568797990562&quot; class=&quot;c++ cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define F(p,q) for(int p=0; p&amp;lt;q; p++)
struct S { int si, sj; };
int i, j, A[50][50], N, M, R = 1e4, c, z, r[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };

int main() {
	vector&amp;lt;S&amp;gt; v; vector&amp;lt;int&amp;gt; v3;
	cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M;
	F(i, N) F(j, N) {
		cin &amp;gt;&amp;gt; A[i][j]; if (A[i][j] &amp;gt; 1) { v.push_back({ i,j }); z++; } if (!A[i][j]) c++;
	}
	F(i, z - M) v3.push_back(0); F(i, M) v3.push_back(1);
	if (!c) R = 0;
	else {
		do {
			int B[50][50], dd = c, ti = 0; memcpy(B, A, sizeof(A)); queue&amp;lt;S&amp;gt; q;
			F(i, v3.size()) { if (v3[i]) { q.push(v[i]); B[v[i].si][v[i].sj] = 3; } }
			while (!q.empty()) {
				int qs = q.size(); ti++;
				while ((qs--)) {
					S ts = q.front(); q.pop();
					F(j, 4) {
						int ni = ts.si + r[j][0], nj = ts.sj + r[j][1];
						if ((ni &amp;gt;= 0 &amp;amp;&amp;amp; nj &amp;gt;= 0 &amp;amp;&amp;amp; ni &amp;lt; N &amp;amp;&amp;amp; nj &amp;lt; N &amp;amp;&amp;amp; !(B[ni][nj] % 2))) {
							q.push({ ni,nj }); if (!B[ni][nj])dd--; B[ni][nj] = 3;
						}
					}
					if (!dd) { R = min(R, ti); break; }
				}
				if (ti &amp;gt;= R) break;
			}
		} while (next_permutation(v3.begin(), v3.end()));
	}
	cout &amp;lt;&amp;lt; (R &amp;lt; 1e4 ? R : -1);
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17142</category>
      <category>백준</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <category>연구소 3</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/173</guid>
      <comments>https://2heedu.tistory.com/173#entry173comment</comments>
      <pubDate>Wed, 18 Sep 2019 18:13:33 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 17140] 이차원 배열과 연산</title>
      <link>https://2heedu.tistory.com/172</link>
      <description>&lt;p&gt;백준 :: BOJ :: 17140 :: 이차원 배열과 연산&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/17140&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/17140&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1568797791824&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot;&gt;&lt;a href=&quot;https://www.acmicpc.net/problem/17140&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-original-url=&quot;https://www.acmicpc.net/problem/17140&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/cYh2KA/hyCTuaJDYV/n8xKLckk5v3kfZcUkZ36M0/img.png?width=1200&amp;amp;height=630&amp;amp;face=0_0_1200_630');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;17140번: 이차원 배열과 연산&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;첫째 줄에 r, c, k가 주어진다. (1 &amp;le; r, c, k &amp;le; 100) 둘째 줄부터 3개의 줄에 배열 A에 들어있는 수가 주어진다. 배열 A에 들어있는 수는 100보다 작거나 같은 자연수이다.&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;www.acmicpc.net&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;pre id=&quot;code_1568797811939&quot; class=&quot;c++ cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include&amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define F(p,q,z) for(int p=q; p&amp;lt;z; p++)
#define pi pair&amp;lt;int,int&amp;gt;
int r, c, k, A[100][100], N = 3, M = 3, i, j, ans, ss;

void G(int ii, int jj) {
	ss = 0; F(i, 0, ii) {
		set&amp;lt;int&amp;gt;s1; multiset&amp;lt;int&amp;gt; s2; priority_queue&amp;lt;pi, vector&amp;lt;pi&amp;gt;, greater&amp;lt;pi&amp;gt;&amp;gt;pq; int B = 0;
		F(j, 0, jj) { 
			if (N &amp;gt;= M) { if (!A[i][j]) continue; s1.insert(A[i][j]); s2.insert(A[i][j]); A[i][j] = 0;}
			else {if (!A[j][i]) continue; s1.insert(A[j][i]); s2.insert(A[j][i]); A[j][i] = 0;}
		}
		for (auto it = s1.begin(); it != s1.end(); it++)pq.push(make_pair(s2.count(*it),*it));
		int gg = 0, mm=pq.size(); ss=max(ss,(mm*2));
		while (!pq.empty()) {
			pi tmp = pq.top(); pq.pop();
			if (N &amp;gt;= M) {A[i][gg++] = tmp.second; A[i][gg++] = tmp.first;}
			else {A[gg++][i] = tmp.second; A[gg++][i] = tmp.first;}
			if (gg &amp;gt; 99)break;
		}
	}
}

int main() {
	cin &amp;gt;&amp;gt; r &amp;gt;&amp;gt; c &amp;gt;&amp;gt; k;
	F(i, 0, 3) F(j, 0, 3) cin &amp;gt;&amp;gt; A[i][j];
	while (ans &amp;lt; 101 &amp;amp;&amp;amp; A[r - 1][c - 1] != k) { (N &amp;gt;= M ? G(N, M) : G(M, N)); (N &amp;gt;= M ? M = ss : N = ss); ans++; }
	cout &amp;lt;&amp;lt; (ans &amp;gt; 100 ? -1 : ans);
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17140</category>
      <category>백준</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <category>이차원 배열과 연산</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/172</guid>
      <comments>https://2heedu.tistory.com/172#entry172comment</comments>
      <pubDate>Wed, 18 Sep 2019 18:11:21 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 17143] 낚시왕</title>
      <link>https://2heedu.tistory.com/171</link>
      <description>&lt;p&gt;백준 :: BOJ :: 17143 :: 낚시왕&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/17143&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.acmicpc.net/problem/17143&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1557836857442&quot; class=&quot;c++ cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include&amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define FO(x,y) for(x=0; x&amp;lt;y; x++)
struct F { int r, c, d, s, z; }; vector&amp;lt;F&amp;gt; v;
int R, C, M, ans, dir[2][5] = { { 0,-1,1,0,0 },{ 0,0,0,1,-1 } }, cd[] = { 0,2,1,4,3 };

inline int go(int a, int b, int c, int e) {
	int pm = (b + (v[a].s*dir[e][v[a].d])), tm = abs(pm) % ((c - 1) * 2);
	if (v[a].s) {
		if (v[a].d == 1 || v[a].d == 4) { if (tm &amp;gt; 0 &amp;amp;&amp;amp; tm &amp;lt; c) if (pm &amp;lt; 0) v[a].d = cd[v[a].d]; }
		else { if (tm == 0 || tm &amp;gt; (c - 1)) v[a].d = cd[v[a].d]; }
	}
	return (tm &amp;gt; (c - 1) ? ((c - 1) * 2) - tm : tm);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin &amp;gt;&amp;gt; R &amp;gt;&amp;gt; C &amp;gt;&amp;gt; M; F f;
	while (M--) { cin &amp;gt;&amp;gt; f.r &amp;gt;&amp;gt; f.c &amp;gt;&amp;gt; f.s &amp;gt;&amp;gt; f.d &amp;gt;&amp;gt; f.z; f.r--; f.c--; v.push_back(f); }
	for (int k = 0; k &amp;lt; C &amp;amp;&amp;amp; v.size(); k++) {
		F p[100][100] = { 0, }; vector&amp;lt;int&amp;gt;pv[2]; int fc[2] = { 101, }, i, vi[100][100] = { 0, };
		FO(i, v.size()) { if (v[i].c == k &amp;amp;&amp;amp; fc[0] &amp;gt; v[i].r) { fc[0] = v[i].r; fc[1] = v[i].z; } }
		FO(i, v.size()) {
			if (v[i].z == fc[1]) { ans += v[i].z; v.erase(v.begin() + i); i--; continue; }
			int ni = v[i].r, nj = v[i].c;
			if (v[i].d &amp;lt; 3) ni = go(i, ni, R, 0);
			else nj = go(i, nj, C, 1);
			if (p[ni][nj].z &amp;lt; v[i].z) {
				v[i].r = ni; v[i].c = nj; p[ni][nj] = v[i]; if (!vi[ni][nj]) { vi[ni][nj] = 1; pv[0].push_back(ni); pv[1].push_back(nj); };
			}
		}v.clear();
		FO(i, pv[0].size()) v.push_back(p[pv[0][i]][pv[1][i]]);
	}
	cout &amp;lt;&amp;lt; ans;
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17143</category>
      <category>boj</category>
      <category>낚시왕</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/171</guid>
      <comments>https://2heedu.tistory.com/171#entry171comment</comments>
      <pubDate>Tue, 14 May 2019 21:28:09 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 17144] 미세먼지 안녕!</title>
      <link>https://2heedu.tistory.com/170</link>
      <description>&lt;p&gt;백준 :: BOJ :: 17144 :: 미세먼지 안녕!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/17144&quot;&gt;https://www.acmicpc.net/problem/17144&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1557836685277&quot; class=&quot;c++ cpp&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#include &amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

#define F(x,y,u,p) for(int x=0; x&amp;lt;u; x++)for(int y=0;y&amp;lt;p;y++)
int ans, w, q[2][2], R, C, T, a[50][50], dd[4][2] = { {0,1},{-1,0},{0,-1},{1,0} }, dx[8] = { 0,1,2,3,0,3,2,1 };

inline bool chk(int i, int j) { return (i &amp;lt; 0 || j &amp;lt; 0 || i &amp;gt;= R || j &amp;gt;= C || a[i][j] &amp;lt; 0) ? false : true; }

int main() {
	cin &amp;gt;&amp;gt; R &amp;gt;&amp;gt; C &amp;gt;&amp;gt; T;
	F(i, j, R, C) { cin &amp;gt;&amp;gt; a[i][j]; if (a[i][j] &amp;lt; 0)q[w][0] = i,q[w++][1] = j; }
	while (T--) {
		int ta[50][50] = { 0, }, cz = 0;
		F(i, j, R, C) {
			if (a[i][j] &amp;gt; 4) {
				int n = a[i][j] / 5, m = 0;
				for (int d = 0; d &amp;lt; 4; d++) { int ni = i + dd[d][0], nj = j + dd[d][1]; if (chk(ni, nj)) { ta[ni][nj] += n; m++; } }
				a[i][j] -= n * m;
			}
		}
		F(i, j, R, C) a[i][j] += ta[i][j];
		for (int i = 0; i &amp;lt; 2; i++) {
			int cn = 0, cm = 0, ii = q[i][0], jj = q[i][1];
			while (1) {
				int ni = ii + dd[dx[cz]][0], nj = jj + dd[dx[cz]][1];
				if (ni == q[i][0]&amp;amp;&amp;amp;nj==0) { cz++; break; }
				if (chk(ni, nj)) { cm = a[ni][nj]; a[ni][nj] = cn; cn = cm; ii = ni; jj = nj; }
				else cz++;
			}
		}
	}
	F(i, j, R, C) if (a[i][j] &amp;gt; 0) ans += a[i][j];
	cout &amp;lt;&amp;lt; ans;
	return 0;
}&lt;/code&gt;&lt;/pre&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>17144</category>
      <category>boj</category>
      <category>미세먼지 안녕!</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/170</guid>
      <comments>https://2heedu.tistory.com/170#entry170comment</comments>
      <pubDate>Tue, 14 May 2019 21:25:23 +0900</pubDate>
    </item>
    <item>
      <title>삼성 SW 역량 테스트 기출 풀이</title>
      <link>https://2heedu.tistory.com/169</link>
      <description>&lt;p&gt;&lt;b&gt;1. 게리맨더링 2&amp;nbsp;(백준17779)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_0&quot; data-id=&quot;169_0&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_0&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_0&quot; data-id=&quot;169_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제를 푸는 방법이 여러가지가 있을 수 있다고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;모든 방법이 일단 문제에서 중간 지역을 만드는 모든 경우를 모두 계산해주어야 합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;중간지역의 꼭지점 중 가장 위를 0번, 가장 위에서 왼쪽 밑을 1번, 가장 위에서 오른쪽 밑을 2번, 가장 밑을 3번 이라고 부르겠습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;여기서 핵심은 0번을 기준으로 1번과 2번만 찾으면 됩니다. ( 0번에서 1번 + 2번이 3번이기 때문입니다. 마름모 공식? )&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;그래서 0번을 기준으로 1번의 경우의 수와 2번의 경우의 수를 조합하면 모든 경우가 나오고 이때 전체 범위안에 들면 다음 계산(최대최소찾기)을 하면됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;1번과 2번 꼭지점을 지정했다고 가정하고 계산을 하는데 총 5개 구역의 값을 찾아야합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;이때 이중 for문으로 1,2,3,4를 찾으면 5는 전체에서 1234를 빼주면 되기 때문에 1234만 찾습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;이때 핵심은, 이중 for문을 하드코딩으로 4가지 경우 모두 적어도 되지만 이중 for문에 범위만 체크해주면 모두 같기 때문에&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;각 구역의 범위를 배열에 넣기만 하면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;각 구역의 범위는 1번 꼭지점을 기준으로 계산만 해주면 됩니다. 그리고 각 구역마다 계단 처럼 적어지거나 늘어나는 부분은 int 변수 한개를 ++해줘서&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;특정 범위를 기준으로 빼주거나 더해주면 됩니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/174&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/174&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_0&quot; data-id=&quot;169_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. 새로운 게임 2&amp;nbsp;(백준17837)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_1&quot; data-id=&quot;169_1&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_1&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_1&quot; data-id=&quot;169_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제에서 주어진 조건을 순서대로 구현하면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;제가 푼 방식은 덱을 이용하여 풀었습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;굳이 덱이 아니라도 스택이나 배열 등 여러가지 방법으로 풀 수 있습니다. 핵심은 자신과 그 위에 쌓인 것을 옮기는 것입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;말을 순서대로 움직입니다. 이때 다른 건 그냥 구현하면되는데 겹친 부분을 표현하는 것을 덱으로 했습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;덱 배열을 똑같이 하나 더 만들어서 그곳에 쌓인 말을 저장했습니다. 그러면 만약 옮기는 곳이 반대로 쌓아야하면 그 덱 배열에서 뒤에서 부터&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;옮겨주면 되고 아니면 자신부터 끝까지 옮겨주면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;덱 배열을 사용해서 쌓여있는 말의 사이즈와 위치 push pop을 편하게 했습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/175&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/175&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_1&quot; data-id=&quot;169_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;5. 연구소 3 (백준17142)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_2&quot; data-id=&quot;169_2&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_2&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_2&quot; data-id=&quot;169_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제에서 주어진 조건을 잘 읽고 풀면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;활성화 된 바이러스 옆에 비활성화 바이러스가 있다면 1초 후 그 비활성화 바이러스를 활성화 시킨다에 유의해야합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제는 먼저 모든 바이러스에 대해 활성화 시킬 바이러스를 골라야 합니다. 이를 재귀 또는 permutation으로 풀 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;저는 permutation으로 바이러스 조합을 만들어서 활성화 시켰습니다. 활성화 시키면 bfs를 통해 퍼트리면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;퍼트릴 때마다 빈곳의 개수를 빼주면 0이 되는 순간 종료시키면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;그리고 시간을 줄이는 한가지 방법이 min을 사용해서 현재까지 했던 시뮬레이션 중 가장 짧은 시간보다 시간이 넘어가면 바로 종료시키면&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;시간을 줄일 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/173&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/173&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_2&quot; data-id=&quot;169_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;6. 이차원 배열과 연산 (백준17140)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_3&quot; data-id=&quot;169_3&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_3&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_3&quot; data-id=&quot;169_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제를 푸는 다양한 방법이 있다고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;제가 푼 방법은 set과 multiset 그리고 priorty_queue를 사용했습니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;한 줄 씩 읽어가면서 set과 multiset에 값을 넣게 되면 set에는 중복이 되지 않기때문에 어떤 숫자가 있는지 알 수 있고&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;multiset에는 중복된 모든 숫자가 들어가서 count를 통해 숫자의 개수를 알 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;따라서 set의 원소들을 돌며 숫자와 개수를 priority_queue에 넣어주게 되면 문제가 요구하는 정렬법에 따라 정렬이 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;이를 순서대로 넣어주면 쉽게 풀 수 있습니다. 이 방법말고 다양한 방법으로 할 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/172&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/172&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_3&quot; data-id=&quot;169_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;7. 낚시왕 (백준17143)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_4&quot; data-id=&quot;169_4&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_4&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_4&quot; data-id=&quot;169_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제에서 주어진대로 순서대로 구현을 하면 쉽게 풀 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;정확한 채점기준을 잘 모르겠지만 문제의 조건을 보면 문제를 만든 사람의 의도를 볼 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;주의깊게 보아야할 부분이 상어의 속도 s 의 최대크기입니다. s는 1000까지 입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;혹시, 상어의 이동(벽에 부딪혀 turn하는 경우와 그냥 이동)을 반복문으로 일일이 했다면 코드가 도는데 꽤 오랜시간이 걸릴 것 입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;출제자는 이것을 어떻게 수식으로 간단히 할 수 있을지 묻는 것 같았습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;제가 짠 코드는 상어의 이동을 수식하나로 한번에 이동시킵니다. 수식은 코드에서 go함수에 있으며 속도, 방향에 따른&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;상어의 이동 후 좌표, 방향을 바로 계산해 줍니다. 이를 통해 코드의 실행속도를 현저히 줄였습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;이외의 부분은 천천히 문제의 순서에 따라 쉽게 구현할 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/171?category=672811&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/171?category=672811&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_4&quot; data-id=&quot;169_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;8. 미세먼지 안녕! (백준17144)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_5&quot; data-id=&quot;169_5&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_5&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_5&quot; data-id=&quot;169_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;문제에서 주어진대로 순서대로 구현을 하면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;여기서 주의할 점은 2차 배열의 최대크기가 50X50이기 때문에 전체 탐색과 벡터에 담는 것 어떤 것이 빠른지 고려해야합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;만약 벡터에 미세먼지를 담게 된다면 공기청정기에 의한 이동때문에 상당히 번거로울 수 있습니다.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;이 문제의 핵심도 이것이라고 생각합니다. 공기청정기에 의해 미세먼지가 이동합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;벡터에 담게되면 결국 다시 담아야하므로 이동된 미세먼지에 대해 다시 계산을 해야하는 문제가 생깁니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;더 시간이 오래걸리고 이 문제의 핵심이라고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;물론, 코드의 실행속도를 더 줄이는 다양한 방법이 있지만 간결하게 문제에서 요구하는 것을 풀었을 때 아래와 같은 코드가 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/170?category=672811&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/170?category=672811&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_5&quot; data-id=&quot;169_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;9. 아기상어 (백준16236)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_6&quot; data-id=&quot;169_6&quot;&gt;  #1 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_6&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_6&quot; data-id=&quot;169_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;아기 상어가 움직일 수 있는 경로에 대해 가장 가까운 먹이를 찾기 위해 bfs를 이용합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;그러나 먹이를 먹는 순서에 주의해야 합니다. 같은 거리에 대해 가장 위, 가장 왼쪽 부터 먹기 때문에&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;일반적으로 bfs를 돌리면 반례가 나오게 됩니다. 따라서 이 문제의 핵심은 이 반례를 해결하는 거라고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;이를 위해 우선순위 큐와 가중치를 사용했습니다. 같은 거리에 있는 먹을 수 있는 먹이에 대해&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;i에 100을 곱하고 j를 더해서 우선순위 큐(오름차순 정렬)에 저장했습니다. 결국 우선순위 큐의 top에 있는 먹이가&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;아기 상어가 먹어야 하는 먹이가 되므로 쉽게 해결할 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2heedu.tistory.com/165&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;https://2heedu.tistory.com/165&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_6&quot; data-id=&quot;169_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;10. 나무재테크 (백준16235)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_7&quot; data-id=&quot;169_7&quot;&gt;  #2 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_7&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_7&quot; data-id=&quot;169_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;봄,여름,가을,겨울에 일어나는 일을 순서대로 코드화 하면 간단하게 해결할 수 있습니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;1. 먼저 나무의 정보를 vector에 저장합니다. 그 후 K년의 시간을 돌립니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;2. 봄에는 먼저 나이가 어린 나무를 찾기 위해 vector를 sort합니다. 그 후, 죽게되는 나무는 queue에 따로 넣어두고&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;죽지않는 나무는 나이 1증가 후 다시 넣습니다. 임의의 vector를 하나 더 만들어서 따로 담은 후 swap 했습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;3. 여름에는 queue에 담아 둔 죽은 나무 정보를 가져와서 처리합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;4. 가을에는 vector의 나무 정보를 가져와 번식시킵니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;5. 겨울에는 전체 배열에 양분을 추가합니다. N의 크기가 작아 배열 전체를 한번 돌렸습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2heedu.tistory.com/167&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;https://2heedu.tistory.com/167&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_7&quot; data-id=&quot;169_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;11. 인구이동 (백준16234)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_8&quot; data-id=&quot;169_8&quot;&gt;  #3 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_8&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_8&quot; data-id=&quot;169_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;한번 체크했던 나라는 다시 안해도 되기 때문에 순서대로 체크하면서 bfs를 통해 국경을 열어 인구 이동을 시킵니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;N의 크기가 작기 때문에 처음부터 시작해서 2차 배열의 끝까지 bool visit 체크하며 방문안했던 곳을 찾습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;안했던 곳은 queue와 vector에 넣습니다. 그 후 queue를 통해 bfs를 돌려 열려서 이동이 가능한 곳들을 찾아서 vector에 추가합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;결국 이동가능한, 연결된 나라들이 vector에 담기게 되고 인구를 이동하고 다음 방문하지 않았던 나라를 찾으면서 반복합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/166&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/166&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_8&quot; data-id=&quot;169_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;12. 큐빙&amp;nbsp;(백준5373)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_9&quot; data-id=&quot;169_9&quot;&gt;  #4 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_9&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_9&quot; data-id=&quot;169_9&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;큐브를 돌리는 것에 대한 규칙을 찾으면 쉽게 풀 수 있습니다.&amp;nbsp;이 문제의 핵심은&amp;nbsp;6면에 대한 각 값, 총 54개의 값들을 어떻게 저장하냐가 중요하다고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;큐브를 회전했다는 것은 1. 중심면 (정사각형)이 90도&amp;nbsp;또는 -90도 회전 2. 중심면에 붙어있는 사이드 4개의 면들의 붙어있는 3개의 값들(총 12개) 가 회전 입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;어떠한 회전이든 모든 큐브의 값이 잘 저장만 되어 있으면 회전하는 코드는 각 값을 바꿔주기만 하면 끝나기 때문에 회전 코드는 매우 짧습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;이러한 규칙을 빠르게 적용하기 위해 익숙한 전개도를 활용하였습니다. 먼저, 전개도에 대해 54개의 값에 번호를 붙였습니다. 그 후 배열에 저장을 할 때 쉽게 회전&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;시키기 위해 총 9+12=21개의 값(회전하는 중심면+같이 회전되는 4개의 사이드 면의 3개 값들)을 저장하여 쉽게 회전시켰습니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;코드를 짤 때 전개도를 그리면서 생각하다보니.... 엄청 길지는 않을 것 같아서...&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;처음 각 면&amp;nbsp;대한 배열 값 sur[6][21] 그리고 회전 할 때 바꾸는 위치의 값 ch[2][21]은 직접 값을 다 넣었습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;회전 할 때 다른 면보다 Bottom 부분을 회전할 때 햇갈릴 수 있습니다. 전개도를 해당 값을 매칭해보면 실수없이 정확히 이해할 수 있습니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/163&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/163&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_9&quot; data-id=&quot;169_9&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;13. 감시 (백준15683)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_10&quot; data-id=&quot;169_10&quot;&gt;  #4 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_10&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_10&quot; data-id=&quot;169_10&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;cctv의 방향을 구현하는 것이 중요합니다. 5개의 cctv의 처음 방향을 정하고 회전했을 때의 방향을 수식으로 표현합니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;90도 회전은 (처음방향+i)%4 로 구현할 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;방향을 구현했으면 브루트포스 조합으로&amp;nbsp;모든 경우에 대해 연산을 합니다. 이때 memcpy를 통해 임시의 2차배열을 통해 되돌리는 것이 중요합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;모든 경우를 연산 후 가장 최소값을 출력하면 쉽게 풀 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/78&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/78&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_10&quot; data-id=&quot;169_10&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;14. 사다리조작 (백준15684)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_11&quot; data-id=&quot;169_11&quot;&gt;  #4 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_11&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_11&quot; data-id=&quot;169_11&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;2차원 배열에서 브루트포스 조합으로 모든 경우를 연산합니다. 사다리가 놓일 수 있는 경우를 생각하고 0개부터 3개까지 모든 경우에 대해 연산을 해줍니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;최소값을 찾아야 하기 때문에 i에서 i로 간다해도 모든 경우를 체크해주어야 합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;사다리를 놓을 때는 각 지점마다 오른쪽으로 놓였는지 왼쪽으로 놓였는지를 구분해줍니다. 저는 1과 -1로 하여 사디리 시뮬레이션 시에 가로 값이 움직이는 걸&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;한번에 표현했습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;그리고 N, M, H 값이 햇갈릴 수 있으니 주의해서 짜면 쉽게 풀 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2heedu.tistory.com/3&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;https://2heedu.tistory.com/3&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_11&quot; data-id=&quot;169_11&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;15. 드래곤커브 (백준15685)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_12&quot; data-id=&quot;169_12&quot;&gt;  #4 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_12&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_12&quot; data-id=&quot;169_12&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;규칙을 찾으면 쉽게 풀 수 있습니다. 반복되는 규칙이 잇습니다. 또한 방향에 관한 것이기에 +1 %4를 기억합니다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;그후 규칙을 찾으면&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;0방향을 기준으로 다른 방향은 시작 방향 값 만큼만 더해서 %4를 해주면 같으므로 하나만 계산하면 됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 8pt;&quot;&gt;규칙을 다른 여러가지 방식으로 코드화 할 수 있는데 수식의 핵심은 %4입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/157&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/157&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_12&quot; data-id=&quot;169_12&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;16. 치킨배달 (백준15686)&lt;/b&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more169_13&quot; data-id=&quot;169_13&quot;&gt;  #4 설명 및 코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content169_13&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_13&quot; data-id=&quot;169_13&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;가능한 조합을 모두 연산합니다. 거리를 미리 저장하여 시간을 줄이고 재귀를 통해 연산합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;조합을 만들어 모든 조합에 대해 연산하는 브루트포스 문제입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 10.6667px;&quot;&gt;거리 계산을 할때 inline 함수를 쓰면 조금 시간이 줄지만 역량테스트 특성상 시간초과를 많이 고려하지 않아도 되기에 상관없다고 생각합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:8pt;&quot;&gt;[코드] :&amp;nbsp;&lt;a href=&quot;https://2heedu.tistory.com/158&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://2heedu.tistory.com/158&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less169_13&quot; data-id=&quot;169_13&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;접기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;모든 문제 관련 출처&lt;/b&gt;&lt;/p&gt;&lt;p&gt;- 백준 &amp;nbsp;:&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/workbook/view/1152&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/workbook/view/1152&lt;/a&gt;&lt;/p&gt;&lt;p&gt;- SWEA &amp;nbsp;:&amp;nbsp;&lt;a href=&quot;https://www.swexpertacademy.com/main/searchAll/searchMore.do?category=CODE&amp;amp;keyword=%EB%AA%A8%EC%9D%98+sw&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.swexpertacademy.com/main/searchAll/searchMore.do?category=CODE&amp;amp;keyword=%EB%AA%A8%EC%9D%98+sw&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>SW</category>
      <category>기출</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <category>역량 테스트</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/169</guid>
      <comments>https://2heedu.tistory.com/169#entry169comment</comments>
      <pubDate>Wed, 13 Feb 2019 15:09:20 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 3190] 뱀</title>
      <link>https://2heedu.tistory.com/168</link>
      <description>&lt;p&gt;백준 :: BOJ :: 3190 :: 뱀&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/3190&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/3190&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int N, K, L, ti, tj, dd, ans, m[101][101];&lt;/p&gt;&lt;p&gt;int di[] = {0,1,0,-1}, dj[] = {1,0,-1,0};&lt;/p&gt;&lt;p&gt;deque &amp;lt;pair&amp;lt;int,int&amp;gt;&amp;gt; dq, r;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool chk(int i, int j) { return (i&amp;gt;0&amp;amp;&amp;amp;j&amp;gt;0&amp;amp;&amp;amp;i&amp;lt;=N&amp;amp;&amp;amp;j&amp;lt;=N) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; K; dq.push_back(make_pair(1, 1)); m[1][1] = -1; dd = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (K--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; ti &amp;gt;&amp;gt; tj; m[ti][tj] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; L;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (L--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;char c; cin &amp;gt;&amp;gt; ti &amp;gt;&amp;gt; c;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (c == 'L') tj = -1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else tj = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;r.push_back(make_pair(ti, tj));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (1) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;ans++;ti = dq.front().first+di[dd]; tj = dq.front().second+dj[dd];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (chk(ti, tj)) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (m[ti][tj]&amp;gt;=0) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (m[ti][tj] &amp;lt; 1) {&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;m[dq.back().first][dq.back().second] = 0; dq.pop_back();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;dq.push_front(make_pair(ti, tj)); m[ti][tj] = -1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else break;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else break;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (!r.empty() &amp;amp;&amp;amp; r.front().first == ans) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;dd += r.front().second; r.pop_front();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (dd == -1) dd = 3;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (dd == 4) dd = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; ans;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>3190</category>
      <category>boj</category>
      <category>백준</category>
      <category>뱀</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/168</guid>
      <comments>https://2heedu.tistory.com/168#entry168comment</comments>
      <pubDate>Mon, 21 Jan 2019 12:49:09 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 16235] 나무 재테크</title>
      <link>https://2heedu.tistory.com/167</link>
      <description>&lt;p&gt;백준 :: BOJ :: 16235 :: 나무 재테크&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/16235&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/16235&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct Tr {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j, a;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;bool operator&amp;lt;(const Tr&amp;amp; vv) const { return a &amp;lt; vv.a; }&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;int N, M, K, A[11][11], arr[11][11];&lt;/p&gt;&lt;p&gt;int di[] = { -1,-1,-1,0,1,1,1,0 }, dj[] = { -1,0,1,1,1,0,-1,-1 };&lt;/p&gt;&lt;p&gt;vector &amp;lt;Tr&amp;gt; v, tv; queue&amp;lt;Tr&amp;gt; q;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool chk(int i, int j) { return (i &amp;gt; 0 &amp;amp;&amp;amp; j &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt;= N &amp;amp;&amp;amp; j &amp;lt;= N) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void year() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;sort(v.begin(), v.end()); Tr t;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; v.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;t = v[i];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (arr[t.i][t.j] &amp;gt;= t.a) { arr[t.i][t.j] -= t.a; t.a++;&amp;nbsp; tv.push_back(t); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else q.push(t);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;v.swap(tv); tv.clear();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!q.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;t = q.front(); q.pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;arr[t.i][t.j] += (t.a / 2);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; v.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (v[i].a % 5 == 0) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int d = 0; d &amp;lt; 8; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;t = v[i]; t.i += di[d]; t.j += dj[d]; t.a = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (chk(t.i, t.j)) v.push_back(t);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (K) for (int i = 1; i &amp;lt;= N; i++) for (int j = 1; j &amp;lt;= N; j++) arr[i][j] += A[i][j];&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M &amp;gt;&amp;gt; K;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 1; i &amp;lt;= N; i++) for (int j = 1; j &amp;lt;= N; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; A[i][j]; arr[i][j] = 5;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (M--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;Tr tmp; cin &amp;gt;&amp;gt; tmp.i &amp;gt;&amp;gt; tmp.j &amp;gt;&amp;gt; tmp.a;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;v.push_back(tmp);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (K--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;year();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; v.size();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>16235</category>
      <category>boj</category>
      <category>나무 재테크</category>
      <category>백준</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/167</guid>
      <comments>https://2heedu.tistory.com/167#entry167comment</comments>
      <pubDate>Thu, 10 Jan 2019 13:51:13 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 16234] 인구 이동</title>
      <link>https://2heedu.tistory.com/166</link>
      <description>&lt;p&gt;백준 :: BOJ :: 16234 :: 인구 이동&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/16234&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/16234&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct A { int a, b; };&lt;/p&gt;&lt;p&gt;int N, L, R, f, sum, ans,&lt;/p&gt;&lt;p&gt;arr[50][50], dir[4][2] = { {0,1},{0,-1},{1,0},{-1,0} };&lt;/p&gt;&lt;p&gt;bool vi[50][50];&lt;/p&gt;&lt;p&gt;queue&amp;lt;A&amp;gt; q; vector&amp;lt;A&amp;gt; v;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool check(int i, int j) { return (i &amp;gt;= 0 &amp;amp;&amp;amp; j &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; N&amp;amp;&amp;amp;j &amp;lt; N) ? true : false; }&lt;/p&gt;&lt;p&gt;inline bool cal(int a, int b) { return (abs(a - b) &amp;gt;= L &amp;amp;&amp;amp; abs(a - b) &amp;lt;= R) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void bfs() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!q.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;auto tmp = q.front(); q.pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int d = 0; d &amp;lt; 4; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;int ni = tmp.a + dir[d][0], nj = tmp.b + dir[d][1];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (check(ni, nj) &amp;amp;&amp;amp; !vi[ni][nj] &amp;amp;&amp;amp; cal(arr[tmp.a][tmp.b], arr[ni][nj])) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;vi[ni][nj] = 1; q.push({ ni,nj });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;v.push_back({ ni,nj }); sum += arr[ni][nj];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void ch() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!f) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;f = 1; memset(vi, 0, sizeof(vi));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; N; i++) for (int j = 0; j &amp;lt; N; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (!vi[i][j]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;q.push({ i,j }); vi[i][j] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;v.push_back({ i,j }); sum += arr[i][j]; bfs();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (v.size() &amp;gt; 1) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;int tra = sum / v.size(); f = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;for (int i = 0; i &amp;lt; v.size(); i++) arr[v[i].a][v[i].b] = tra;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;v.clear(); sum = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (!f) ans++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; L &amp;gt;&amp;gt; R; ans = 0; sum = 0; f = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; N; i++) for (int j = 0; j &amp;lt; N; j++) cin &amp;gt;&amp;gt; arr[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ch();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; ans;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>16234</category>
      <category>boj</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>인구 이동</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/166</guid>
      <comments>https://2heedu.tistory.com/166#entry166comment</comments>
      <pubDate>Wed, 9 Jan 2019 17:48:23 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 16236] 아기 상어</title>
      <link>https://2heedu.tistory.com/165</link>
      <description>&lt;p&gt;백준 :: BOJ :: 16236 :: 아기 상어&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/16236&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/16236&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int N, t, tt, fs, ss, si, sj, ni, nj,&lt;/p&gt;&lt;p&gt;arr[21][21], v[21][21], di[] = {-1,0,0,1}, dj[] = {0,-1,1,0};&lt;/p&gt;&lt;p&gt;queue&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; q; priority_queue&amp;lt;int,vector&amp;lt;int&amp;gt;,greater&amp;lt;int&amp;gt;&amp;gt; pq;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void clear() {&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;queue&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; e; priority_queue&amp;lt;int, vector&amp;lt;int&amp;gt;, greater&amp;lt;int&amp;gt;&amp;gt;ee; swap(pq, ee); swap(q, e);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;memset(v, 0, sizeof(v)); q.push(make_pair(ni, nj));&amp;nbsp;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void bfs() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!q.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int s = q.size(); tt++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;while (s--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;auto tmp = q.front(); q.pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int d = 0; d &amp;lt; 4; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;ni = tmp.first + di[d]; nj = tmp.second + dj[d];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (ni &amp;gt; 0 &amp;amp;&amp;amp; ni &amp;lt;= N &amp;amp;&amp;amp; nj &amp;gt; 0 &amp;amp;&amp;amp; nj &amp;lt;= N &amp;amp;&amp;amp; arr[ni][nj] &amp;lt;= ss &amp;amp;&amp;amp;!v[ni][nj]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (arr[ni][nj] &amp;lt; ss &amp;amp;&amp;amp; arr[ni][nj] &amp;gt;0) pq.push(ni*100+nj);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else v[ni][nj] = 1, q.push(make_pair(ni, nj));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (!pq.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;ni = pq.top() / 100; nj = pq.top() % 100;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;fs++; arr[ni][nj] = 0; clear(); t += tt; tt = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (ss == fs) ss++, fs = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N; t = 0; ss = 2; fs = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 1; i &amp;lt;= N; i++) for (int j = 1; j &amp;lt;= N; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; arr[i][j]; if (arr[i][j] == 9) arr[i][j]=0, si = i, sj = j, q.push(make_pair(i,j));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;bfs();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; t;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>16236</category>
      <category>boj</category>
      <category>백준</category>
      <category>아기 상어</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/165</guid>
      <comments>https://2heedu.tistory.com/165#entry165comment</comments>
      <pubDate>Wed, 9 Jan 2019 17:45:40 +0900</pubDate>
    </item>
    <item>
      <title>2019 10대 전략 기술 트렌드</title>
      <link>https://2heedu.tistory.com/164</link>
      <description>&lt;p&gt;시장조사 기관 '가트너(Gartner)'가 선정한 2019년 IT 10대 전략 기술 트렌드와 이에 대한 생각을 정리하였다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;table style=&quot;box-sizing: border-box; margin: 0px; padding: 0px; empty-cells: show; color: rgb(17, 17, 17); font-family: 함초롬바탕; font-size: 16px; height: 1693.72px; border-right: medium none black; border-bottom: medium none black; border-left: medium none black; border-collapse: collapse;&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 27px; height: 38px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;구분&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 38px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; text-align: center; word-break: keep-all;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;명칭&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 38px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; text-align: center; word-break: keep-all;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;내용&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td rowspan=&quot;3&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 27px; height: 328px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; text-align: center; word-break: keep-all;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;지능&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;1. 자율 사물&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Autonomous Things)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;font face=&quot;함초롬바탕&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-로봇, 드론, 자율주행차 등 AI가 결합되 자동, 자율화 된 사물이 된다. 사물이 환경 및 사람과 상호작용하는 수준의 행동을 선보인다.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;2. 증강 분석&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Augmented Analytics)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-증강 분석은 분석 콘텐츠가 개발, 소비 및 공유되는 방식을 혁신하기 위해 머신러닝을 이용해 증강 지능의 특정 영역에 초점을 맞춘다. 증강 분석 기능은 데이터 준비, 데이터 관리, 분석, 프로세스 관리, 마이닝 및 데이터 사이언스 플랫폼의 주요 기능으로 빠르게 발전한다. 증강 분석으로부터 얻은 자동화된 통찰력은 HR, 재무, 영업, 마케팅, 서비스, 구매조달 및 자산관리 등에 적용되 최적화 결과를 낼 것이다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;3.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;인공지능 주도 개발&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(AI-Driven Development)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-기존의 데이터, 애플리케이션 등 협업을 통해 만들어진 AI 솔루션 방식에서 벗어나, 전문 개발자들이 서비스형 사전 정의 모델을 사용해 단독으로 운영할 수 있는 모델로 시장이 변하고 있다. 이는 개발자에게 AI 알고리즘, 모델 생태계는 물론 모델 및 AI 역량을 솔루션에 통합하도록 설계된 개발 툴을 제공한다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td rowspan=&quot;3&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 52px; height: 608px; vertical-align: middle;&quot; colspan=&quot;1&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; text-align: center; word-break: keep-all;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;디지털&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 119px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;4.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;디지털 트윈&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Digital Twin)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 119px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;디지털 트윈은&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;‘&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;현실 세계에 존재하는 대상이나 시스템의 디지털 버전&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;’&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;을 말함&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;디지털 트윈은 향후&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;3~5&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;년간 특히&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;IoT&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;프로젝트에서 유망할 것으로 예상한다. 비즈니스 목표에 맞게 효과적으로 데이터를 수집, 시각화, 분석, 규칙 적용을 하며 역량을 향상시키면서 진화할 것이다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;5.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;자율권을 가진 에지&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Empowred Edge)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;에지 컴퓨팅은 정보 처리와 콘텐츠 수집&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;전달이 해당 정보 소스와 인접한 곳에서 처리되는 컴퓨팅 토폴로지&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(topology)이다. 즉 에지는 사람들이 사용하거나 우리 주변에 내장된 엔드포인트 디바이스를 지칭한다. 에지는 IoT에 주도되어 클라우드, 에지 컴퓨팅이 중앙 서버 뿐 아니라 분산화 된 에지 디바이스 자체에서 중앙 서비스로서 관리되는 클아우드 서비스를 보완하는 모델로 진화할 것이다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;6.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;몰입 경험&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Immersive Experience)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 102px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;대화형 플랫폼은 디지털 세계와 인간 상호작용 방식 간 차세대 패러다임 전환을 야기할 것으로 예측한다. 디지털 세상을 인식하는 방식과 상호작용 모델의 통합된 변화는 미래 몰입형 사용자 경험을 이끌어 낸다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 52px; height: 370px; vertical-align: middle;&quot; colspan=&quot;1&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; text-align: center; word-break: keep-all;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;메시&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;8.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;블록체인&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Blockchain)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 123px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;블록체인은 디지털 통화 인프라에서 디지털 혁신 플랫폼으로 진화 중이다. 블록체인은 대안적 신뢰 모드를 제공하고 중재 거래에서 중앙당국의 필요성을 없앤다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 166px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;9.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;스마트 공간&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Smart Spaces)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 166px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-스마트 공간은 인간과 기술 시스템이 더욱 개방되고, 연결되며, 조율되고, 지능적인 생태계에서 상호작용하는 물리적 혹은 디지털 환경이다. 사람, 프로세스, 서비스 그리고 사물 등 여러 요소들은 스마트 공간에 모여 타깃 사용자 및 산업 시나리오를 겨냥한 보다 몰입적이고 상호적이며 자동화된 경험을 창출한다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td rowspan=&quot;2&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 52px; height: 412px; vertical-align: middle;&quot; colspan=&quot;1&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;공통&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 205.72px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;10. 디지털 윤리와 개인정보보호&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: 함초롬바탕;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Privacy and Ehtics)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 205.72px; vertical-align: middle;&quot;&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;-디지털 윤리와 개인정보보호는 개인, 조직 및 정부가 모두 우려하는 부분이다. 사람들은 자신의 개인정보가 공공 및 민간부문에서 조직에 의해 어떻게 사용되는지에 대해 점점 더 우려하고 있고, 이러한 우려에 대해 적극적인 조치를 취하지 않는 조직들에 대한 반발도 증가하고 있다.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 256.85px; height: 205.72px; vertical-align: middle;&quot; rowspan=&quot;1&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0pt; box-sizing: border-box; font-family: 함초롬바탕;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;10. 양자 컴퓨팅&lt;/span&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; letter-spacing: 0pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(Quantum Computing&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot; style=&quot;margin-right: 0px; margin-left: 0px; box-sizing: border-box; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;box-sizing: border-box; margin: 0px; padding: 1px 6px; border: 1px solid rgb(0, 0, 0); width: 377.14px; height: 205.72px; vertical-align: middle;&quot; rowspan=&quot;1&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;-양자 컴퓨팅은 정보를 양자 비트 요소로 나타내는 전자와 이온과 같은 아원자 입자의 양자 상태에서 작동하는 비고전적인 컴퓨팅의 한 유형이다. 양자 컴퓨터의 병렬 실행과 기하 급수적인 확장성은 기존의 문제점을 해결한다. 금융, 보험, 제약, 군사 및 연구 기관과 같은 기업들이 복잡하고 시간적 문제를 해결하며 큰 혜택을 이루고 있다.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;지능, 디지털, 메시는 작년과 동일하게 지속적으로 주목받았던 주제이다. 2019는 초기 상태에서 벗어나 보다 폭넓은 영향력과 활용 사례를 보이는 신기술과 급성장세를 보인다. 이는 기술 중심에서 보다 넓은 시야로 기술이 적용되는 환경을 고려한 기술이 중요시 되고 있다고 생각한다. 현재 우리나라의 기술력은 해외보다 늦다고 생각한다. 그러나 강점은 사회 전반에 디지털화가 가장 잘 되어 있다는 점이라고 생각한다. 2019년 부터 상용화 될 5G의 파급력으로 이러한 전략 기술들은 좀 더 사용자 및 개발자에게 가깝게 느껴지고 필요성이 절실할 것이다. 기업에서도 이러한 점을 고려하여 자체 목표, 전략에 맞게 발전해야 한다고 생각한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;http://www.itworld.co.kr/news/111118&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://www.itworld.co.kr/news/111118&lt;/a&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>트렌드</category>
      <category>2019 10대 전략 기술 트렌드</category>
      <category>가트너</category>
      <category>트렌드</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/164</guid>
      <comments>https://2heedu.tistory.com/164#entry164comment</comments>
      <pubDate>Thu, 1 Nov 2018 18:38:55 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 5373] 큐빙</title>
      <link>https://2heedu.tistory.com/163</link>
      <description>&lt;p&gt;백준 :: BOJ :: 5373 :: 큐빙&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/5373&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/5373&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;int T, N, i, h,&lt;/p&gt;&lt;p&gt;c[21] = {13,8,3,18,14,9,4,0,19,15,10,5,1,20,16,11,6,2,17,12,7 },&lt;/p&gt;&lt;p&gt;u[6][21] = {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 20,19,18,27,8,7,6,11,28,5,4,3,10,29,2,1,0,9,45,46,47 },&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 18,21,24,6,11,14,17,36,3,10,13,16,39,0,9,12,15,42,47,50,53 },&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 6,7,8,11,18,19,20,27,14,21,22,23,30,17,24,25,26,33,36,37,38 },&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 26,23,20,38,33,30,27,8,41,34,31,28,5,44,35,32,29,2,51,48,45 },&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 24,25,26,17,36,37,38,33,16,39,40,41,34,15,42,43,44,35,53,52,51 },&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;{ 42,43,44,15,53,52,51,35,12,50,49,48,32,9,47,46,45,29,0,1,2 } };&lt;/p&gt;&lt;p&gt;char s[86], t[21], g[54], d[2], in[6] = { 'o','g','w','b','r','y' };&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; T;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = 0; i &amp;lt; 6; i++) s[&quot;BLURFD&quot;[i]] = i;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (T--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; N; vector&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; v;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;while (N--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin &amp;gt;&amp;gt; d[0] &amp;gt;&amp;gt; d[1]; d[0] = s[d[0]];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;v.push_back(make_pair(d[0], d[1]));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i = -1; while ((++i) &amp;lt; 55) g[i] = in[i / 9];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 0; i &amp;lt; v.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;h = -1; while ((++h) &amp;lt;= 20) t[h] = g[u[v[i].first][h]];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;h = -1; while ((++h) &amp;lt;= 20) g[u[v[i].first][h]] = v[i].second&amp;gt;44 ? t[20-c[h]] : t[c[h]];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 18; i &amp;lt; 27; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cout &amp;lt;&amp;lt; g[i];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if ((i % 3) == 2) cout &amp;lt;&amp;lt; '\n';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>5373</category>
      <category>boj</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>큐빙</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/163</guid>
      <comments>https://2heedu.tistory.com/163#entry163comment</comments>
      <pubDate>Thu, 25 Oct 2018 18:30:04 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA 5789] 현주의 상자 바꾸기</title>
      <link>https://2heedu.tistory.com/162</link>
      <description>&lt;p&gt;SW Expert Academy :: SWEA :: 5789 :: 현주의 상자 바꾸기&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWYygN36Qn8DFAVm&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWYygN36Qn8DFAVm&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int i, j, T, N, Q, n1, n2;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; T;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int tc = 1; tc &amp;lt;= T; tc++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; Q;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt;q; vector&amp;lt;int&amp;gt;v(N + 1, 0), a(N + 1, 0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;while (Q--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin &amp;gt;&amp;gt; n1 &amp;gt;&amp;gt; n2; q.push_back(make_pair(n1, n2));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = q.size() - 1; i &amp;gt;= 0; i--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (j = q[i].first; j &amp;lt;= q[i].second; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (v[j]) j = v[j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;a[j] = i + 1; v[j] = q[i].second;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cout &amp;lt;&amp;lt; &quot;#&quot; &amp;lt;&amp;lt; tc &amp;lt;&amp;lt; &quot; &quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 1;i &amp;lt;= N;i++) cout &amp;lt;&amp;lt; a[i] &amp;lt;&amp;lt; &quot; &quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cout &amp;lt;&amp;lt; '\n';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/SWEA</category>
      <category>SW Expert Academy</category>
      <category>SWEA</category>
      <category>삼성</category>
      <category>현주의 상자 바꾸기</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/162</guid>
      <comments>https://2heedu.tistory.com/162#entry162comment</comments>
      <pubDate>Wed, 10 Oct 2018 16:56:51 +0900</pubDate>
    </item>
    <item>
      <title>오버헤드 (Overhead)</title>
      <link>https://2heedu.tistory.com/161</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;오버헤드&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;프로그램이 실행되는 중에 다른 위치의 코드를 실행시켜야 할 때, 간접적으로 시간, 메모리, 자원 등이 사용되는 현상이다.&lt;/p&gt;&lt;p&gt;즉, 반드시는 아니고 간접적인 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;외부 함수 사용 시 함수 사용을 위해 스택메모리를 할당하고 함수에 따라 여러가지 연산 등이 일어난다. 이는 예상치 못한 자원들이 사용되는 것이고 이것이 오버헤드이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오버헤드를 줄이기 위해 매크로, 인라인 함수 등을 사용하고 최적화가 필요하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>공부/SW</category>
      <category>overhead</category>
      <category>오버헤드</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/161</guid>
      <comments>https://2heedu.tistory.com/161#entry161comment</comments>
      <pubDate>Tue, 9 Oct 2018 16:41:09 +0900</pubDate>
    </item>
    <item>
      <title>정렬 알고리즘 (Sorting Algorithm)</title>
      <link>https://2heedu.tistory.com/160</link>
      <description>&lt;p&gt;정렬 알고리즘 정리에 앞서 두 가지를 정리하였다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 1px; border-style: solid; border-color: rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;안전 정렬 ( stable )&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;불안전 정렬 ( not stable )&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;width:392;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;같은 값(key)의 위치가 정렬 과정에서 바뀌지 않는 것&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width:392;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;같은 값(key)의 위치가 정렬 과정에서 바뀌는 것&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 1px; border-style: solid; border-color: rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;내부 정렬 ( Internal sorting )&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;외부&amp;nbsp;정렬 ( External sorting )&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;데이터의 크기가 주 기억장소 용량보다 적을 경우&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;기억장소를 활용하여 정렬&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;데이터의 크기가 주 기억장소 용량보다 클 경우&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;외부 기억장치를 사용하여 정렬&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;가장 효율적인 정렬 알고리즘이 무엇인가?&lt;/span&gt;&lt;/b&gt; 라는 질문에 대한 답은 &lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;상황에 따라 다르다&lt;/span&gt;&lt;/b&gt;이다.&lt;/p&gt;&lt;p&gt;데이터의 크기, 양, 정렬상태 등 다양한 상황에 따라 최적의 정렬 알고리즘을 선택하기 위해 각각의 정렬 알고리즘들을 정리하였다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;1. Bubble Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot; colspan=&quot;3&quot; rowspan=&quot;1&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt; 시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;


&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;width:196;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width:196;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot; colspan=&quot;1&quot; rowspan=&quot;2&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991DB5345BBBCF8F06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%201%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;width:196;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9972DB495BBBCE6D04&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width:196;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;;&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99CE6B3A5BBBD26F08&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9925514B5BBBCEF40A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif; font-size: 10pt;&quot;&gt;- 안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&amp;nbsp; &amp;nbsp; - 비교와 교환&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;letter-spacing: 0pt; font-size: 10pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;- 연산이 완료되었는지를 나타내는 flag&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif; font-size: 10pt;&quot;&gt;를 통한 코드 수정으로 복잡도 줄일 수 있다&lt;/span&gt;&lt;span style=&quot;letter-spacing: 0pt; font-size: 10pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;letter-spacing: 0pt; font-size: 10pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;- 이미 정렬이 되어 있는지 확인 가능하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif; font-size: 10pt;&quot;&gt;- 가장 쉬운 정렬 알고리즘&amp;nbsp; &amp;nbsp; - &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif; font-size: 10pt;&quot;&gt;시간복잡도가 높아 잘 사용하지 않는다&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 나란히 있는 2개의 데이터를 계속해서 바꾸어 나간다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터가 적고 단순한 구현이 필요한 경우 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_0&quot; data-id=&quot;160_0&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_0&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_0&quot; data-id=&quot;160_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;// flag를 통해 개선된 버블 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void bubble_sort(int list[], int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int flag = 1;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = n - 1; flag &amp;gt; 0; i--) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;flag = 0;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; i; j++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (list[j] &amp;gt; list[j + 1]) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;swap(list[j], list[j + 1]);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;flag = 1;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_0&quot; data-id=&quot;160_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;2. Selection Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991DB5345BBBCF8F06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%201%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9972DB495BBBCE6D04&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99036D3B5BBBCF1707&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9925514B5BBBCEF40A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 불안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&amp;nbsp; &amp;nbsp; - 비교와 교환&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터 중 최솟값을 선택하여 제일 앞과 자리를 바꾸며 정렬한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터가 적을 때 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터의 초기 정렬형태에 영향을 받지않고&amp;nbsp;일정한 시간 복잡도를 나타낸다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 거품 정렬에 비해 2~3배 빠르다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_1&quot; data-id=&quot;160_1&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_1&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_1&quot; data-id=&quot;160_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void selection_sort(int list[], int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int minValue;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i&amp;lt;n - 1; i++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;minValue = i;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = i + 1; j&amp;lt;n; j++) if (list[j]&amp;lt;list[minValue]) minValue = j;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;swap(list[i], list[minValue]);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_1&quot; data-id=&quot;160_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;3. Insertion Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991DB5345BBBCF8F06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%201%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9972DB495BBBCE6D04&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99CE6B3A5BBBD26F08&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9925514B5BBBCEF40A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&amp;nbsp; &amp;nbsp; - 비교와 교환&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터에 대해 더 작거나 큰 값이 나올때까지 진행하며 값을 찾아가며 바꾼다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 버블, 선택 정렬보다 빠르고 안전성이 높아 다른 분할정복으로 구현되는 알고리즘의 base가 된다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 이미 정렬된 상태면 최선의 시간 복잡도가 나온다. 반면 역순으로 정렬되어 있는 경우 최악의 시간 복잡도가 나온다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 선택 정렬보다 2배정도 빠르다.&amp;nbsp; &amp;nbsp; - 많은 이동때문에 적은 양의 데이터에&amp;nbsp;유리하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터의 초기 정렬형태에 영향을 받는다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_2&quot; data-id=&quot;160_2&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_2&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_2&quot; data-id=&quot;160_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void insertion_sort(int list[], int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j, key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = 1; i&amp;lt;n; i++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;key = list[i];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (j = i - 1; j &amp;gt;= 0 &amp;amp;&amp;amp; list[j]&amp;gt;key; j--) list[j + 1] = list[j];&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;list[j + 1] = key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_2&quot; data-id=&quot;160_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p class=&quot;0&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;4. Shell Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991DB5345BBBCF8F06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%201%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7BB3E5BBBD33C0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 불&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&amp;nbsp; &amp;nbsp; - 비교와 교환&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 속도가 빠르다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 정렬되지 않은 데이터의 경우에 비효율적인 삽입정렬을 개선한 방법&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 일정한 간격(gap)으로 그룹을 만들어 각각 삽입정렬을 한 후 전체를 간격 1로 보고 삽입정렬로 종합한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 간격에 따라 시간 복잡도가 결정되며 아직 정확한 시간 복잡도는 확인되지 않았다. 약 n의 1.25승 정도이다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 일정한 간격의 수열이 서로 소가 되게 정의해야 성능이 좋아진다. (ex 701, 301, 132, 57, 23, 10, 4, 1)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 간격에 따른 그룹 별 정렬 방식이 H/W로 정렬 알고리즘을 구현하는데 적합하여 임베디드 시스템에 주로 사용된다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_3&quot; data-id=&quot;160_3&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_3&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_3&quot; data-id=&quot;160_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void insertion_sort(int list[], int first, int last, int gap) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j, key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = first + gap; i &amp;lt;= last; i += gap) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;key = list[i];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (j = i - gap; j &amp;gt;= first &amp;amp;&amp;amp; key&amp;lt;list[j]; j = j - gap) list[j + gap] = list[j];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;list[j + gap] = key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void shell_sort(int list[], int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, gap;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (gap = n / 2; gap&amp;gt;0; gap /= 2) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if ((gap % 2) == 0) gap++;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 0; i&amp;lt;gap; i++)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;insertion_sort(list, i, n - 1, gap);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_3&quot; data-id=&quot;160_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;5. Merge Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991F283C5BBBD40807&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;52&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7BB3E5BBBD33C0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- &lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 외부 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 외부 정렬로 몇 번 패스(read/write)하냐 를 가지고 시간 복잡도를 측정한다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 가장 많이 쓰이는 알고리즘 중 하나이다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터를 2개의 균등 크기로 분할하고, 각각 재귀적으로 합병 정렬을 이용하여 정렬한 후&amp;nbsp;합병한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터 크기만큼 외부 메모리가 필요하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 퀵 정렬과 달리 안정적인 복잡도를 발휘한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터의 초기 상태에 별로 영향을 받지 않는다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_4&quot; data-id=&quot;160_4&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_4&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_4&quot; data-id=&quot;160_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void mergesort(int list[], int size, int tmp[]) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j, t;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (size &amp;lt;= 1) return;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;mergesort(list, size / 2, tmp);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;mergesort(list + size / 2, size - size / 2, tmp);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;i = 0;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;j = size / 2;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;t = 0;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (i &amp;lt; size / 2 &amp;amp;&amp;amp; j &amp;lt; size) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (list[i] &amp;lt;= list[j])&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;tmp[t++] = list[i++];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;tmp[t++] = list[j++];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (i &amp;lt; size / 2) tmp[t++] = list[i++];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (j &amp;lt; size) tmp[t++] = list[j++];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;memcpy(list, tmp, size * sizeof(int));&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_4&quot; data-id=&quot;160_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;6. Tim Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991F283C5BBBD40807&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;52&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99CE6B3A5BBBD26F08&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;-&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 외부 정렬&amp;nbsp; &amp;nbsp; - 2분할 삽입 정렬 + 병합 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 병합 정렬일 때 요소수가 적은 경우 오버헤드에 의해 느려진다. 이를 개선한 알고리즘&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 미리 어느 정도의 크기의 정렬이 끝난 열(run)로 분할하고 병합한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- run은 32보다 작게 하여 2분할 삽입 정렬을 한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 가장 많이 쓰이는 알고리즘 중 하나이다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 데이터를 2개의 균등 크기로 분할하고, 각각 재귀적으로 합병 정렬을 이용하여 정렬한 후&amp;nbsp;합병한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터 크기만큼 외부 메모리가 필요하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 퀵 정렬과 달리 안정적인 복잡도를 발휘한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터의 초기 상태에 별로 영향을 받지 않는다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;7. Quick Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9972DB495BBBCE6D04&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7BB3E5BBBD33C0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 불&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 실제 데이터에서 빠르다고 알려져서 가장 많이 쓰는 알고리즘&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 최악의 경우에 시간 복잡도가 큰 약점이 있다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 임의의 값(pivot)을 기준으로 한쪽은 pivot보다 작은 것, 다른 쪽은 큰것으로 나누어(partition) 양쪽을 다시 재귀로 반복한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- pivot을 선택이 매우 중요하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 원소 개수가 한자리로 떨어졌을 때는 재귀가 아니라 삽입 정렬로 효율을 높일 수 있다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 정렬된 데이터에 대해서는 시간이 더 걸린다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_5&quot; data-id=&quot;160_5&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_5&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_5&quot; data-id=&quot;160_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void quicksort(DATA list[], int left, int right)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int pivot, i, j;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (left &amp;lt; right) {&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i = left; j = right + 1;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;pivot = list[left].key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;do {&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;do i++;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;while (list[i].key &amp;lt; pivot &amp;amp;&amp;amp; i &amp;lt;= right);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;do j--;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;while (list[j].key &amp;gt; pivot);&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (i &amp;lt; j)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;swap(list[i], list[j]);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;} while (i &amp;lt; j);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;swap(list[left], list[j]);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;quicksort(list, left, j - 1);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;quicksort(list, j + 1, right);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_5&quot; data-id=&quot;160_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;mso-fareast-font-family:한컴바탕;mso-font-width:100%;letter-spacing:0pt;mso-text-raise:0pt;font-size:8.0pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;8. Intro Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7BB3E5BBBD33C0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 불&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 퀵&amp;nbsp;정렬의 개량 버전이다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 퀵 정렬에서 pivot의 선택에 의해 시간 복잡도가&amp;nbsp;최악으로 되는 경우를 대처하기 위해 재귀 탐색이 요소수의 대수를 넘으면&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&amp;nbsp; &amp;nbsp;힙 정렬로 바꾼다. 또한 퀵 정렬에서 32미만의 데이터 수의 경우 오버헤드를 적게하기 위해 삽입 정렬로 바꾼다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-family:한컴바탕;mso-fareast-font-family:한컴바탕;font-size:8.0pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;9. Heap Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991DB5345BBBCF8F06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%201%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;53&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 28px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99F521355BBBD31D07&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 28px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99A7BB3E5BBBD33C0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 28px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C08B405BBBD3590D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n%5Clog%20%7B%20n%20%7D%20%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;101&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 불&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;안전 정렬&amp;nbsp; &amp;nbsp; - 내부 정렬&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 퀵 정렬의 최악의 경우 때문에 힙 정렬을 많이 쓴다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 힙 조건(각 노드의 값이 자식 노드 값보다 커야 한다)을 만족하는 완전 이진 트리이다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 배열에 저장하여 힙을 만든 후 n개의 데이터를 삭제하고 힙을 재구성하는 과정을 반복한다. 삭제된 노드를 배열에 차례로 저장하면 정렬된 리스트가 된다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 재구성은 이진 트리를 힙으로 만들기 위한 재구성으로 트리의 깊이 만큼의 시간이 걸린다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_6&quot; data-id=&quot;160_6&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_6&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_6&quot; data-id=&quot;160_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void adjust(DATA list[], int root, int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int child, rootkey;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;temp = list[root];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;rootkey = list[root].key;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;child = 2 * root;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (child &amp;lt;= n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if ((child &amp;lt; n) &amp;amp;&amp;amp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;(list[child].key &amp;lt; list[child + 1].key))&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;child++;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (rootkey &amp;gt; list[child].key) break;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;list[child / 2] = list[child];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;child *= 2;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;list[child / 2] = temp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void heapsort(DATA list[], int n) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = n / 2; i &amp;gt; 0; i--)&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;adjust(list, i, n);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = n - 1; i &amp;gt; 0; i--) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;swap(list[1], list[i + 1]);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;adjust(list, 1, i);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_6&quot; data-id=&quot;160_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p class=&quot;0&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;10. Counting Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99C2994B5BBBD51F10&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;51&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99BA314C5BBBD4AD0D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99EA934A5BBBD4D612&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99D52C4B5BBBD4ED0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터에서 최대값 만큼의 메모리가 필요하다. 따라서 메모리 낭비가 있을 수 있다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 정렬하는 데이터들의 값이 특정한 범위 안에 있을 때 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터의 처음부터 끝까지 돌면서 각 숫자가 몇번 등장하는지 counting한다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_7&quot; data-id=&quot;160_7&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_7&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_7&quot; data-id=&quot;160_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void counting_sort(int list[], int n, int max_value) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i,j,cnt=0,chk[max_value + 1] = { 0, };&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = 0; i &amp;lt; n; i++) chk[list[i]]++;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;white-space: pre; font-size: 13.3333px;&quot;&gt;		&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = 0; i &amp;lt; max_value + 1; i++) for (j = 1; j &amp;lt;= chk[i]; j++)&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;list[cnt++] = i;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_7&quot; data-id=&quot;160_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;11. Radix Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99BA314C5BBBD4AD0D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/994EB54D5BBBD54505&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20nk%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;63&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/999D604B5BBBD5520D&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20nk%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;64&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/995C18465BBBD5630E&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20nk%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;63&quot; height=&quot;24&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터를 특정 진수로 자릿수 별로 정렬하는 알고리즘이다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 비교 정렬 알고리즘에서 가장 빠르다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- radix(기수), 즉 특정 진수로 일의 자리, 십의 자리, 백의 자리, 이렇게 차례로 정렬한다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 기수의 크기만큼의 메모리가 필요하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 부동 소숫점, 음수값 처럼 특수한 비교 연산에는 불가능하다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 숫자, 알파벳 관련 데이터 등 대용량 데이터 정렬에 적절하다.&lt;/span&gt;&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more160_8&quot; data-id=&quot;160_8&quot;&gt;코드&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content160_8&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_8&quot; data-id=&quot;160_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;void radixsort(int list[], int size) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, max = list[0], rad = 1, base = 10;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int tmp[size], bucket[base];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i = 1; i &amp;lt; size; i++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (list[i] &amp;gt; max) max = list[i];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (max / rad &amp;gt; 0) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;memset(bucket, 0, base * sizeof(int));&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 0; i &amp;lt; size; i++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;bucket[(list[i] / rad) % base]++;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = 1; i &amp;lt; base; i++) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;bucket[i] += bucket[i - 1];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (i = size - 1; i &amp;gt;= 0; i--) {&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;tmp[--bucket[(list[i] / rad) % base]] = list[i];&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;memcpy(list, tmp, size * sizeof(int));&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;rad *= base;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less160_8&quot; data-id=&quot;160_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;12. Bucket Sort&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; rowspan=&quot;1&quot; style=&quot;width: 586px; height: 24px; border-width: 1px 3px 1px 1px; border-style: solid; border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(204, 204, 204) rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;시간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-top: 1px solid rgb(204, 204, 204); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;b&gt;공간 복잡도&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&amp;nbsp;최악&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;최선&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;평균&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;1&quot; rowspan=&quot;2&quot; style=&quot;width: 197px; height: 48px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991F283C5BBBD40807&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20n%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;52&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9972DB495BBBCE6D04&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CO%20%5Cleft%28%20%7B%20n%20%7D%5E%7B%202%20%7D%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;60&quot; height=&quot;27&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99EA934A5BBBD4D612&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5COmega%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 196px; height: 24px; border-bottom: 1px solid rgb(204, 204, 204); border-right: 3px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/99D52C4B5BBBD4ED0B&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5CTheta%20%5Cleft%28%20n+k%20%5Cright%29%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;76&quot; height=&quot;24&quot;&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- n개의 데이터에 대해 범위를 n개로 나누고 n개의 버킷을 만든다. 그 후 각 데이터를 버킷에 넣고 버킷 별로 정렬하여 합친다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 데이터가 확률적으로 균등하게 분포한다고 가정할 때 성능이 나타난다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;- 연결 리스트로 버킷을 구성할 수 있고, 버킷들을 정렬할 때는 퀵 정렬 등을 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;정리&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;b&gt;-&amp;nbsp;&lt;/b&gt;데이터의 값을 정확히 모른다면 Heap을 사용하면 가장 무난한 성능을 기대할 수 있다.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- 만약 데이터가 정렬되어 있거나 거의 정렬되어 있으면 Insertion 이나 Tim을 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;- quick 보다는 intro가 더 성능이 좋으므로 무난하게 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size:18pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;정렬 알고리즘 별 비교 및 요약 :&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;작성자 : 히더&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;0&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <category>알고리즘/이론</category>
      <category>C++</category>
      <category>sort</category>
      <category>정렬 알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/160</guid>
      <comments>https://2heedu.tistory.com/160#entry160comment</comments>
      <pubDate>Tue, 9 Oct 2018 06:22:07 +0900</pubDate>
    </item>
    <item>
      <title>CX (Customer Experience)</title>
      <link>https://2heedu.tistory.com/159</link>
      <description>&lt;p&gt;CX는 Customer Experience 즉, 고객 경험을 말한다. 서비스 공급자와 고객의 관계가 지속됨에 따라 관련하여 고객이 체험하는 모든 경험을 CX라고 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사용자 경험 즉, UX (User Experience)와는 사람 또는 넓은 대상의 니즈에 대한 경험으로 비슷하지만 다른 점이 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;CX는 UX에서 더 나아가 회사의 전략, 사업 등을 염두에 둔다. UX가 디자인적 시각에서 다가간다면 CX는 비즈니스 적이라고 생각한다.&lt;/p&gt;&lt;p&gt;꼭 제품 또는 서비스에만 한하지 않고 고객의 전반적인 라이프 스타일부터 구체적인 니즈가 무엇인가 이해하는 데서 시작한다. 브랜드와 만나는 접점이 무엇인지 정의하고 이 점점에서 이슈가 무엇인지 분석하여 고객 경험을 더 좋게 만들어 비즈니스 목표를 달성시키는 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UX보다는 CX가 좀 더 넓은 관점이라고 생각한다. 이는 앞으로 많은 기업들에서 CX를 중요시 하게 되며 CX Consultant가 비즈니스 전략의 큰 역할을 할 것이라고 생각한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;소비자들이 경험을 중요시하는 시대가 왔다. 오프라인, 온라인 스토어 등에서 간단하게 특정 제품을 파는 형태에서 발전하여 특정 제품을 구매하는 소비자에게 해당 스토어 안에서 비주얼, 푸드, 액티비티 등 다양한 경험을 주고있다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;빅데이터, 클라우드, AR, 인공지능 등 다양한 신 기술들과의 결합을 통해 소비자들에게 더 앞선 경험을 줄 수 있는 시장이 열리고 있다. Data, Analysis, Experience, Customer 등을 고려하며&amp;nbsp;형태가 있는 제품에서부터 IT 서비스, 앱 등 무형의 서비스까지 소비자에게 더 나은 CX를 제공하는 전략이 필요하다고 생각한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;참고 :&amp;nbsp;&lt;a href=&quot;http://uxd-trend.tistory.com/37&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://uxd-trend.tistory.com/37&lt;/a&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>트렌드</category>
      <category>Customer experience</category>
      <category>CX</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/159</guid>
      <comments>https://2heedu.tistory.com/159#entry159comment</comments>
      <pubDate>Tue, 9 Oct 2018 03:56:49 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 15686] 치킨 배달</title>
      <link>https://2heedu.tistory.com/158</link>
      <description>&lt;p&gt;백준 :: BOJ :: 15686 :: 치킨 배달&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/15686&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/15686&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct s {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;int r, c, ch;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;int N, M, tmp, ans;&lt;/p&gt;&lt;p&gt;vector &amp;lt;s&amp;gt; h, c;&lt;/p&gt;&lt;p&gt;vector&amp;lt;int&amp;gt;a;&lt;/p&gt;&lt;p&gt;vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; hh;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void dfs(int n, int ii) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;if (n == M) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;int r = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;for (int i = 0; i &amp;lt; h.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;int rr = 1e9;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;for (int j = 0; j &amp;lt; a.size(); j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;rr = min(rr, hh[i][a[j]]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;r += rr;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;ans = min(ans, r);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;return;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;for (int i = ii; i &amp;lt; c.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;a.push_back(c[i].ch); dfs(n+1, i + 1); a.pop_back();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;return;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M; ans = 1e9;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;int cnt = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;for (int i = 1; i &amp;lt;= N; i++) for (int j = 1; j &amp;lt;= N; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;cin &amp;gt;&amp;gt; tmp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;if (tmp == 1) h.push_back({ i,j,0 });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;else if (tmp == 2) c.push_back({i,j,cnt++});&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;hh.resize(h.size());&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;int r = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;for (int i = 0; i &amp;lt; h.size(); i++) for (int j = 0; j &amp;lt; c.size(); j++)&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;hh[i].push_back(abs(h[i].c - c[j].c) + abs(h[i].r - c[j].r));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;dfs(0,0);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;cout &amp;lt;&amp;lt; ans;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>15686</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>치킨 배달</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/158</guid>
      <comments>https://2heedu.tistory.com/158#entry158comment</comments>
      <pubDate>Mon, 8 Oct 2018 15:33:32 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 15685] 드래곤 커브</title>
      <link>https://2heedu.tistory.com/157</link>
      <description>&lt;p&gt;백준 :: BOJ :: 15685 :: 드래곤 커브&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/15685&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/15685&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct dc {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int x, y, d, s;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;int N, ans, arr[101][101]; dc p;&lt;/p&gt;&lt;p&gt;int dx[] = {1,0,-1,0}, dy[] = {0,-1,0,1};&lt;/p&gt;&lt;p&gt;bool visited[101][101];&lt;/p&gt;&lt;p&gt;vector &amp;lt;dc&amp;gt; v; vector &amp;lt;int&amp;gt; dir;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool check(int x, int y) { return arr[y][x] &amp;amp;&amp;amp; arr[y + 1][x] &amp;amp;&amp;amp; arr[y][x + 1] &amp;amp;&amp;amp; arr[y + 1][x + 1] ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void cal() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;dir.push_back(0); dir.push_back(1);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 2; i &amp;lt;= 10; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int m = pow(2, i - 1);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; m; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (j &amp;lt; (m / 2)) dir.push_back(dir[j] + 2);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else dir.push_back(dir[j]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N; ans = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (N--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; p.x &amp;gt;&amp;gt; p.y &amp;gt;&amp;gt; p.d &amp;gt;&amp;gt; p.s;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;v.push_back({p.x,p.y,p.d,p.s});&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cal();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; v.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;p = v[i];arr[p.y][p.x] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; pow(2, p.s); j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;p.x += dx[(dir[j] + p.d)%4]; p.y += dy[(dir[j] + p.d)%4];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;arr[p.y][p.x] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; 101; i++) for (int j = 0; j &amp;lt; 101; j++) if (check(j, i)) ans++;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; ans;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>15685</category>
      <category>boj</category>
      <category>드래곤 커브</category>
      <category>백준</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/157</guid>
      <comments>https://2heedu.tistory.com/157#entry157comment</comments>
      <pubDate>Sun, 7 Oct 2018 19:52:10 +0900</pubDate>
    </item>
    <item>
      <title>[삼성 SW 테스트] 기출, 모의 기출 문제 정리 [업데이트 중]</title>
      <link>https://2heedu.tistory.com/156</link>
      <description>&lt;p&gt;[업데이트 중...]&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;최신 문제들 풀이 :&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2heedu.tistory.com/169&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;https://2heedu.tistory.com/169&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt; color: rgb(255, 0, 0);&quot;&gt;19 하반기, 19&amp;nbsp;상반기, 18&amp;nbsp;하반기, 18&amp;nbsp;상반기&amp;nbsp;관련 문제&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2heedu.tistory.com/169&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;https://2heedu.tistory.com/169&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;옛날 코드들은&amp;nbsp;코드를 작성한지 꽤 시간이 지나서 좋지않은&amp;nbsp;코드가 많습니다. 참고해주세요.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18.6667px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;다시 풀면서 수정해나가겠습니다.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;삼성 SW 테스트 (S직군 인적성) 관련 알고리즘 문제들을 정리하였다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;백준 사이트에 있는 기출 문제와 SWEA에 있는 모의 SW 테스트 문제를 정리하였다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;문제의 분류는 직접 푼 방법으로 나누어 보았고, 난이도는&amp;nbsp;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;주관적인 기준&lt;/b&gt;&lt;/span&gt;이다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt; color: rgb(9, 0, 255);&quot;&gt;&lt;b&gt;문제 정리&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[완전탐색]&lt;/b&gt;&lt;/p&gt;&lt;p&gt;시험 감독 (기출) / 백준 13458 / 난이도 1&lt;/p&gt;&lt;p&gt;보물상자 비밀번호 (모의 기출) / SWEA 5658 / 난이도 2&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[시뮬레이션]&lt;/b&gt;&lt;/p&gt;&lt;p&gt;주사위 굴리기 (기출) / 백준 14499 / 난이도 2&lt;/p&gt;&lt;p&gt;핀볼 게임 (모의 기출) / SWEA 5650 / 난이도 2&lt;/p&gt;&lt;p&gt;로봇 청소기 (기출) / 백준 14503 / 난이도 2&lt;/p&gt;&lt;p&gt;활주로 건설 (모의 기출) / SWEA 4014 / 난이도 2&lt;/p&gt;&lt;p&gt;경사로 (기출) / 백준 14890 / 난이도 2&lt;/p&gt;&lt;p&gt;특이한 자석 (모의 기출) / SWEA 4013 / 난이도 2&lt;/p&gt;&lt;p&gt;톱니바퀴 (기출) / 백준 14891 / 난이도 2&lt;/p&gt;&lt;p&gt;미생물 격리 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;감시 (기출) / 백준 15683 / 난이도 3&lt;/p&gt;&lt;p&gt;드래곤 커브 (기출) / 백준 15685 / 난이도 3&lt;/p&gt;&lt;p&gt;벽돌 깨기 (모의 기출) / SWEA 5656 / 난이도 3&lt;/p&gt;&lt;p&gt;줄기세포배양 (모의 기출) / SWEA 5653 / 난이도 3&lt;/p&gt;&lt;p&gt;원자 소멸 시뮬레이션 (모의 기출) / SWEA 5648 / 난이도 3&lt;/p&gt;&lt;p&gt;무선 충전 (모의 기출) / SWEA 5644 / 난이도 3&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[브루트포스 / 백트레킹]&lt;/b&gt;&lt;/p&gt;&lt;p&gt;요리사 (모의 기출) / SWEA 4012 / 난이도 2&lt;/p&gt;&lt;p&gt;스타트와 링크 (기출) / 백준 14889 / 난이도 2&lt;/p&gt;&lt;p&gt;숫자 만들기 (모의 기출) / SWEA 4008 / 난이도 2&lt;/p&gt;&lt;p&gt;연산자 끼워넣기 (기출) / 백준 14888 / 난이도 2&lt;/p&gt;&lt;p&gt;치킨 배달 (기출) / 백준 15686 / 난이도 2&lt;/p&gt;&lt;p&gt;보호 필름 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;벌꿀채취 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;연구소 (기출) / 백준 14502 / 난이도 2&lt;/p&gt;&lt;p&gt;사다리 조작 (기출) / 백준 15684 / 난이도 2&lt;/p&gt;&lt;p&gt;디저트 카페 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;등산로 조성 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;점심 식사시간 (모의 기출) / SWEA 5644 / 난이도 3&lt;/p&gt;&lt;p&gt;테트로미노 (기출) / 백준 14500 / 난이도 3&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[BFS]&lt;/b&gt;&lt;/p&gt;&lt;p&gt;홈 방범 서비스 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;[DP]&lt;/b&gt;&lt;/p&gt;&lt;p&gt;수영장 (모의 기출) / SWEA 1952 / 난이도 3&lt;/p&gt;&lt;p&gt;퇴사 (기출) / 백준 14501 / 난이도 3&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;코드 및 설명&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;완전탐색&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;시험 감독 (기출) / 백준 13458 / 난이도 1&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_0&quot; data-id=&quot;156_0&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_0&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_0&quot; data-id=&quot;156_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;각 방을 전부 탐색하며 필요한 감독 수를 계산한다. 인원 수 - B를 해주고 최소의 C를 구하여 더해준다.&lt;/p&gt;&lt;p&gt;[코드]&amp;nbsp;:&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/40&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/40&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_0&quot; data-id=&quot;156_0&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;보물상자 비밀번호 (모의 기출) / SWEA 5658 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_1&quot; data-id=&quot;156_1&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_1&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_1&quot; data-id=&quot;156_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;4개의 면이 있음을 유의하고 전체 경우를 탐색한다. 탐색하며 값을 벡터에 넣고 정렬한 후 정답을 구한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/114&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/114&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_1&quot; data-id=&quot;156_1&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;시뮬레이션&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;주사위 굴리기 (기출) / 백준 14499 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_2&quot; data-id=&quot;156_2&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_2&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_2&quot; data-id=&quot;156_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;주사위 배열을 만들어서 계산해준다. 범위 밖에 나갈 때 좌표를 옮기지 않는 것과 처음의 입력 x와 y가 행과 열임에 주의한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/155&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/155&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_2&quot; data-id=&quot;156_2&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;핀볼 게임 (모의 기출) / SWEA 5650 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_3&quot; data-id=&quot;156_3&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_3&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_3&quot; data-id=&quot;156_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;모든 핀볼 시작 가능 점에서 답을 구해 최대 값을 구한다. 각 블럭과 웜홀에 대해 경우를 나누어 순차적으로 시뮬레이션 한다.&lt;/p&gt;&lt;p&gt;범위에 벗어나는 경우 블럭 5와 같기 때문에 고려한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/110&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/110&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_3&quot; data-id=&quot;156_3&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;로봇 청소기 (기출) / 백준 14503 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_4&quot; data-id=&quot;156_4&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_4&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_4&quot; data-id=&quot;156_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;주어진 조건에 따라 방향 전환, 갈 수 없는 경우를 잘 나누면 쉽게 시뮬레이션 가능하다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/42&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/42&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_4&quot; data-id=&quot;156_4&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;활주로 건설 (모의 기출) / SWEA 4014 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_5&quot; data-id=&quot;156_5&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_5&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_5&quot; data-id=&quot;156_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;가로와 세로에 대하여 각각 계산을 한다. 시뮬레이션을 돌며 옆과 비교하여 계산을 해준다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/43&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/43&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_5&quot; data-id=&quot;156_5&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;경사로 (기출) / 백준 14890 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_6&quot; data-id=&quot;156_6&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_6&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_6&quot; data-id=&quot;156_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;가로와 세로에 대하여 각각 계산을 한다. 예전에 짠 코드라 너무 하드코딩 된 감이 있다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/114&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/26&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_6&quot; data-id=&quot;156_6&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;특이한 자석 (모의 기출) / SWEA 4013 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_7&quot; data-id=&quot;156_7&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_7&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_7&quot; data-id=&quot;156_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;조건에 따라 경우를 나누어 회전과 변경을 해준다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/25&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/25&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_7&quot; data-id=&quot;156_7&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;톱니바퀴 (기출) / 백준 14891 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_8&quot; data-id=&quot;156_8&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_8&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_8&quot; data-id=&quot;156_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;조건에 따라 경우를 나누어 회전과 변경을 해준다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/25&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/25&lt;/a&gt;&amp;nbsp;와 동일&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_8&quot; data-id=&quot;156_8&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;미생물 격리 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_9&quot; data-id=&quot;156_9&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_9&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_9&quot; data-id=&quot;156_9&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;순서대로 시뮬레이션을 한다. 주의할 곳은 3개 이상이 합쳐질 때 크기 비교이다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/73&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/73&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_9&quot; data-id=&quot;156_9&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;감시 (기출) / 백준 15683 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_10&quot; data-id=&quot;156_10&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_10&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_10&quot; data-id=&quot;156_10&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;카메라가 보는 방향에 따라 연산을 빠르게 하기 위해 배열에 미리 저장을 하였다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/78&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/78&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_10&quot; data-id=&quot;156_10&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;드래곤 커브 (기출) / 백준 15685 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_11&quot; data-id=&quot;156_11&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_11&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_11&quot; data-id=&quot;156_11&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;세대가 증가할 때의 규칙을 찾아야한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;0방향을 기준으로 다른 방향은 시작 방향 값 만큼만 더해서 %4를 해주면 같으므로 하나만 계산하면 된다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/157&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/157&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_11&quot; data-id=&quot;156_11&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;벽돌 깨기 (모의 기출) / SWEA 5656 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_12&quot; data-id=&quot;156_12&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_12&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_12&quot; data-id=&quot;156_12&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;모든 경우를 시뮬레이션 한다. 이때 이어진 부분을 없애는 것을 dfs를 이용하여 계산한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;벽돌을 없애고 다음 단계로 가기위해 떨어뜨리는 것은 큐를 이용하였다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/132&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/132&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_12&quot; data-id=&quot;156_12&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;줄기세포배양 (모의 기출) / SWEA 5653 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_13&quot; data-id=&quot;156_13&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_13&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_13&quot; data-id=&quot;156_13&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;최악의 경우에 대비해 넉넉하게 시작점을 175, 175로 한 후 450만큼의 배열을 할당하였다.&lt;/p&gt;&lt;p&gt;활성화, 비활성화를 고려해주기 위해 애초에 곱하기 2를 하여 0이 되면 계산을 하였다. 큐에 담아 순차적으로 시뮬레이션 했다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/133&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/133&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_13&quot; data-id=&quot;156_13&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;원자 소멸 시뮬레이션 (모의 기출) / SWEA 5648 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_14&quot; data-id=&quot;156_14&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_14&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_14&quot; data-id=&quot;156_14&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;순차적 시뮬레이션 말고도 수학적으로 풀 수 있다.&lt;/p&gt;&lt;p&gt;각 원자들에 대해 i=0에서 N-1까지, j=i+1에서 N까지 돌며 2개의 원자가 충돌 가능한지 판단하고 가능하면 충돌 시간과 2개의 원자를 벡터에 쌓는다. 모든 충돌 가능 경우를 판단 후 벡터에 쌓인 것을 충돌 시간 순으로 오름차순 정렬하여&lt;/p&gt;&lt;p&gt;순서대로 터트리고 이전 시간에 이미 터진 충돌은 제외한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/111&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/111&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_14&quot; data-id=&quot;156_14&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;무선 충전 (모의 기출) / SWEA 5644 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_15&quot; data-id=&quot;156_15&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_15&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_15&quot; data-id=&quot;156_15&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;움직이는 순서대로 시뮬레이션 한다. 여러 개의 충전 지점이 겹치는 경우를 꼼꼼히 고려하여야 한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/112&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/112&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_15&quot; data-id=&quot;156_15&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;브루트포스 백트레킹&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;요리사 (모의 기출) / SWEA 4012 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_16&quot; data-id=&quot;156_16&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_16&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_16&quot; data-id=&quot;156_16&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 2 분류로 나누는 모든 경우를 계산하여 최댓값을 구한다. 벡터로 팀을 나누고 각 팀에 대한 값을 계산한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/32&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/32&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_16&quot; data-id=&quot;156_16&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;스타트와 링크 (기출) / 백준 14889 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_17&quot; data-id=&quot;156_17&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_17&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_17&quot; data-id=&quot;156_17&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 2 분류로 나누는 모든 경우를 계산하여 최댓값을 구한다. 각 팀에 대한 값을 계산한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/8&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/8&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_17&quot; data-id=&quot;156_17&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;연산자 끼워넣기&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_18&quot; data-id=&quot;156_18&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_18&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_18&quot; data-id=&quot;156_18&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 통해 각 연산자를 조합하여 모두 계산하다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/9&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/9&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_18&quot; data-id=&quot;156_18&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;숫자 만들기 (모의 기출) / SWEA 4008 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_19&quot; data-id=&quot;156_19&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_19&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_19&quot; data-id=&quot;156_19&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 통해 각 연산 기호들의 조합을 모두 계산한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/30&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/30&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_19&quot; data-id=&quot;156_19&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;치킨 배달 (기출) / 백준 15686 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_20&quot; data-id=&quot;156_20&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_20&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_20&quot; data-id=&quot;156_20&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;치킨 집의 M개수 만큼의 조합을 모두 만들며 백트래킹한다. dfs로 조합을 만들고 확인을 한다.&lt;/p&gt;&lt;p&gt;시간을 줄이기 위해 미리 모든 집과 치킨집의 거리를 계산한 후 사용한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/158&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/158&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_20&quot; data-id=&quot;156_20&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;보호 필름 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_21&quot; data-id=&quot;156_21&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_21&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_21&quot; data-id=&quot;156_21&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;백트레킹으로 모든 경우에 대해 연산을 돌린다. 문제를 주의 깊게 읽을 필요가 있다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/29&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/29&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_21&quot; data-id=&quot;156_21&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;벌꿀채취 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_22&quot; data-id=&quot;156_22&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_22&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_22&quot; data-id=&quot;156_22&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;백트레킹으로 모든 경우에 대해 연산을 돌린다. 문제를 주의 깊게 읽을 필요가 있다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/31&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/31&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_22&quot; data-id=&quot;156_22&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;연구소 (기출) / 백준 14502 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_23&quot; data-id=&quot;156_23&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_23&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_23&quot; data-id=&quot;156_23&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 전체를 돌며 0인 곳에 3개씩 1로 만든다. 3개를 만들고 나면 2의 좌표를 돌며 바이러스를 퍼트리면서 안전영역을 구한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/7&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/7&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_23&quot; data-id=&quot;156_23&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사다리 조작 (기출) / 백준 15684 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_24&quot; data-id=&quot;156_24&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_24&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_24&quot; data-id=&quot;156_24&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 모든 사다리 경우를 만든다. 각 경우마다 확인한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/3&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/3&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_24&quot; data-id=&quot;156_24&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;디저트 카페 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_25&quot; data-id=&quot;156_25&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_25&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_25&quot; data-id=&quot;156_25&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;시간 복잡도를 줄이기 위해 방향 하나만 정해서 탐색을 하며 최소 개수만큼만 탐색한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/28&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/28&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_25&quot; data-id=&quot;156_25&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;등산로 조성 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_26&quot; data-id=&quot;156_26&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_26&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_26&quot; data-id=&quot;156_26&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;dfs의 개념을 정확히 알고 등산로가 될 수 있는 부분을 탐색한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/27&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/27&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_26&quot; data-id=&quot;156_26&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;점심 식사시간 (모의 기출) / SWEA 5644 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_27&quot; data-id=&quot;156_27&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_27&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_27&quot; data-id=&quot;156_27&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;계단에 사람들이 들어가는 경우의 조합을 다 계산한다. 계산 할때 시간에 유의한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/71&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/71&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_27&quot; data-id=&quot;156_27&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;테트로미노 (기출) / 백준 14500 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_28&quot; data-id=&quot;156_28&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_28&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_28&quot; data-id=&quot;156_28&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로 각 블럭을 구현하고 모든 경우 중 가장 큰 값을 찾는다. 그러나 개수가 작아서 배열로 가능한 경우를 미리 다 짜서&amp;nbsp;&lt;/p&gt;&lt;p&gt;19개의 경우로 그냥 값을 탐색하였다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/41&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/41&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_28&quot; data-id=&quot;156_28&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;BFS&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;홈 방범 서비스 (모의 기출) / SWEA 5644 / 난이도 2&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_29&quot; data-id=&quot;156_29&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_29&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_29&quot; data-id=&quot;156_29&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;bfs로 다이아 몬드 형태로 퍼지는 걸 연산한 후 각 비용을 계산한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/33&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/33&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_29&quot; data-id=&quot;156_29&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;DP&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;수영장 (모의 기출) / SWEA 1952 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_30&quot; data-id=&quot;156_30&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_30&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_30&quot; data-id=&quot;156_30&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;브루트포스로도 풀 수 있지만 dp로 간단한 점화식으로 답을 구할 수 있다.&lt;/p&gt;&lt;p&gt;-1개월과 -3개월의 dp값을 이용한 점화식을 세워 각 월까지의 min값을 구한다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/23&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/23&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_30&quot; data-id=&quot;156_30&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;퇴사 (기출) / 백준 14501 / 난이도 3&lt;/p&gt;&lt;button type=&quot;button&quot; class=&quot;btn_more&quot; id=&quot;more156_31&quot; data-id=&quot;156_31&quot;&gt;#코드 및 설명&lt;/button&gt;&lt;div class=&quot;moreless_content&quot; id=&quot;content156_31&quot; style=&quot;display: none;&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_31&quot; data-id=&quot;156_31&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;
  &lt;p class=&quot;txt_view&quot;&gt;&lt;p&gt;dfs로도 풀 수 있지만 점화식 구현을 통한 dp를 통해 일 별로 계산을 했다.&lt;/p&gt;&lt;p&gt;[코드] :&amp;nbsp;&lt;a href=&quot;http://2heedu.tistory.com/38&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://2heedu.tistory.com/38&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
&lt;button type=&quot;button&quot; class=&quot;btn_less&quot; id=&quot;less156_31&quot; data-id=&quot;156_31&quot;&gt;&lt;span class=&quot;txt_fold&quot;&gt;닫기&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;모든 문제 관련 출처&lt;/b&gt;&lt;/p&gt;&lt;p&gt;- 백준 SW 테스트 기출 문제 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/workbook/view/1152&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/workbook/view/1152&lt;/a&gt;&lt;/p&gt;&lt;p&gt;- SWEA 모의 SW 테스트 문제 :&amp;nbsp;&lt;a href=&quot;https://www.swexpertacademy.com/main/searchAll/searchMore.do?category=CODE&amp;amp;keyword=%EB%AA%A8%EC%9D%98+sw&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.swexpertacademy.com/main/searchAll/searchMore.do?category=CODE&amp;amp;keyword=%EB%AA%A8%EC%9D%98+sw&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>SW TEST</category>
      <category>SWEA</category>
      <category>백준</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/156</guid>
      <comments>https://2heedu.tistory.com/156#entry156comment</comments>
      <pubDate>Thu, 4 Oct 2018 19:38:06 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 14499] 주사위 굴리기</title>
      <link>https://2heedu.tistory.com/155</link>
      <description>&lt;p&gt;백준 :: BOJ :: 14499 :: 주사위 굴리기&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/14499&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/14499&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int N, M, x, y, K;&lt;/p&gt;&lt;p&gt;int arr[20][20];&lt;/p&gt;&lt;p&gt;vector&amp;lt;int&amp;gt;dice = { 0,0,0,0,0,0 };&lt;/p&gt;&lt;p&gt;int dx[] = {0,1,-1,0,0}, dy[] = {0,0,0,-1,1};&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool check(int i, int j) { return i &amp;gt;= 0 &amp;amp;&amp;amp; j &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; N &amp;amp;&amp;amp; j &amp;lt; M ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void Rolling(int d) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;int&amp;gt;tmp(dice);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (d == 1) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;dice[0] = tmp[3]; dice[2] = tmp[0]; dice[3] = tmp[5]; dice[5] = tmp[2];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else if (d == 2) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;dice[0] = tmp[2]; dice[2] = tmp[5]; dice[3] = tmp[0]; dice[5] = tmp[3];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else if (d == 3) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;dice[1] = tmp[0]; dice[0] = tmp[4]; dice[4] = tmp[5]; dice[5] = tmp[1];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;dice[1] = tmp[5]; dice[0] = tmp[1]; dice[4] = tmp[0]; dice[5] = tmp[4];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false);cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M &amp;gt;&amp;gt; y &amp;gt;&amp;gt; x &amp;gt;&amp;gt; K; vector&amp;lt;int&amp;gt; order(K);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0;i &amp;lt; N;i++) for (int j = 0; j &amp;lt; M; j++) cin &amp;gt;&amp;gt; arr[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; K; i++) cin &amp;gt;&amp;gt; order[i];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int k = 0; k &amp;lt; K; k++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (check(y + dy[order[k]], x + dx[order[k]])) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;y += dy[order[k]]; x += dx[order[k]]; Rolling(order[k]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (arr[y][x]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;dice[5] = arr[y][x]; arr[y][x] = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else arr[y][x] = dice[5];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cout &amp;lt;&amp;lt; dice[0] &amp;lt;&amp;lt; '\n';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>14499</category>
      <category>boj</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>주사위 굴리기</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/155</guid>
      <comments>https://2heedu.tistory.com/155#entry155comment</comments>
      <pubDate>Thu, 4 Oct 2018 14:58:41 +0900</pubDate>
    </item>
    <item>
      <title>[STL] List 리스트</title>
      <link>https://2heedu.tistory.com/154</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;List 리스트&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;자료구조 중 Doubly Linked list를 템플릿으로 구현 된 노드 기반 컨테이너이다.&lt;/p&gt;&lt;p&gt;STL list는 연결 리스트를 따로 만들지 않고 사용할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;특징&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;1. 저장할 데이터 개수가 가변적일 때 유연하다. vector, deque 같이 배열 기반이 아니라 노드 기반이라 유연하다.&lt;/p&gt;&lt;p&gt;2. 중간에 데이터 삽입/삭제가 빠르다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;3. 배열은 랜덤 접근이 가능하나 list는 순차 접근만 가능하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;list&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;list &amp;lt;int&amp;gt; l; int 자료형 list l 선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.push_front(a) : 첫 번째 위치에 a 데이터 추가&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.pop_front() : 첫 번째 위치 데이터 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.push_back(a) : 마지막 위치에 a 데이터 추가&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.pop_back() : 마지막 위치 데이터 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.front() : 첫 번째 위치 데이터 참조 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.back() : 마지막 위치 데이터 참조 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.clear() : 모든 데이터 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.empty() : 비었으면 true, 데이터가 있으면 false 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.size() : 데이터 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.assign(3,0) : 0으로 초기화된 3개의 원소 할당&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.rbegin() : reverse begin&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;list의 특징적인 함수&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.remove(a) : a와 같은 원소 모두 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.remove_if(조건) : 조건에 해당하는 원소 모두 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l. sort() : 오름차순 정렬&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.splice(it,l2) : l의 it이 가리키는 곳에서 l2의 모든 원소를 잘라 붙임&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.splice(it,l2,it2) : l의 it이 가리키는 곳에서 l2의 it2가 가리키는&amp;nbsp;원소를 잘라 붙임&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.unique() : 인접한 원소가 같으면 하나만 남기고 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;l.merge(l2) : l2를 l로 합병 정렬(오름차순)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>list</category>
      <category>STL</category>
      <category>리스트</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/154</guid>
      <comments>https://2heedu.tistory.com/154#entry154comment</comments>
      <pubDate>Thu, 4 Oct 2018 13:11:19 +0900</pubDate>
    </item>
    <item>
      <title>[STL] Hash_set 해시셋</title>
      <link>https://2heedu.tistory.com/153</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;Hash_set&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;hash 구조를 통해 정렬하지 않고 저장하여 map, set보다 더 빠른 검색속도를 가진다.&lt;/p&gt;&lt;p&gt;hash_map과 다르게 key만 있다. 단일 검색을 할때 사용한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;hahs_set&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hahs_set&lt;/b&gt;&lt;b&gt;&amp;lt;int&amp;gt; hs; : int 자료형 key를&amp;nbsp;가지는&amp;nbsp;&lt;/b&gt;&lt;b&gt;hahs_set hs&lt;/b&gt;&lt;b&gt;선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.size() : 노드 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.begin() : 첫 번째 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.end() : 마지막 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.find(a) : key가 a인 노드 찾아 해당 iterator 리턴, 만약 존재하지 않으면 마지막 iterator 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.insert(a) : a key&amp;nbsp;삽입&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.erase(hm.begin()) : 가장 앞 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.clear() : 모든 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.count(a) : key가 a인 원소들 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.lower_bound(a) : key가 a인 원소가 있다면 해당 위치의 반복자 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hs.upper_bound(a) : key가 a인 원소가 있다현 해당 위치 다음 위치의 반복자 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>Hash_set</category>
      <category>STL</category>
      <category>해시셋</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/153</guid>
      <comments>https://2heedu.tistory.com/153#entry153comment</comments>
      <pubDate>Wed, 3 Oct 2018 18:42:28 +0900</pubDate>
    </item>
    <item>
      <title>[STL] Hash_map 해시맵</title>
      <link>https://2heedu.tistory.com/152</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;Hash_map&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;map이 트리 구조를 통해 원소를 정렬하여 저장하는 것과 다르게&amp;nbsp;&lt;/p&gt;&lt;p&gt;hash 구조를 통해 정렬하지 않고 저장하여 map, set보다 더 빠른 검색속도를 가진다.&lt;/p&gt;&lt;p&gt;단일 검색을 할때 사용한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;hash_map&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hash_map&amp;lt;int, int&amp;gt; hm; : int 자료형 key, int 자료형 value를 가지는 hash_map hm 선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.size() : 노드 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.begin() : 첫 번째 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.end() : 마지막 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.find(a) : key가 a인 노드 찾아 해당 iterator 리턴, 만약 존재하지 않으면 마지막 iterator 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.insert(hash_map&amp;lt;int,int&amp;gt;::value_type(a,b)) : a key의 b value 삽입&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.erase(hm.begin()) : 가장 앞 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.clear() : 모든 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.count(a) : key가 a인 원소들 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.lower_bound(a) : key가 a인 원소가 있다면 해당 위치의 반복자 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.upper_bound(a) : key가 a인 원소가 있다현 해당 위치 다음 위치의 반복자 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;ex)&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hash_map&amp;lt;int,string&amp;gt; hm;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.insert(&lt;/b&gt;&lt;b&gt;(hash_map&amp;lt;int,int&amp;gt;::value_type(1,&quot;A&quot;));&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.insert(&lt;/b&gt;&lt;b&gt;(hash_map&amp;lt;int,int&amp;gt;::value_type(2,&quot;B&quot;));&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;hm.insert(&lt;/b&gt;&lt;b&gt;(hash_map&amp;lt;int,int&amp;gt;::value_type(3,&quot;C&quot;));&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;for(auto i=hm.lower_bound(1); i!=hm.upper_bound(3); i++)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;cout &amp;lt;&amp;lt; i-&amp;gt;second &amp;lt;&amp;lt; endl;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;auto it = hm.find(&quot;2&quot;);&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;if(it!=hm.end()) it-&amp;gt;second = &quot;D&quot;;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>hash_map</category>
      <category>STL</category>
      <category>해시맵</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/152</guid>
      <comments>https://2heedu.tistory.com/152#entry152comment</comments>
      <pubDate>Wed, 3 Oct 2018 18:36:06 +0900</pubDate>
    </item>
    <item>
      <title>[STL] 시퀀스 컨테이너와 연관 컨테이너</title>
      <link>https://2heedu.tistory.com/151</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;시퀀스 컨테이너&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;데이터가 선형으로 저장되며, 제약이나 규칙이 없고 순서가 그대로 유지되는 컨테이너이다.&lt;/p&gt;&lt;p&gt;종류 : vector, list, deque&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;연관 컨테이너&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;중복되는 key를 통해 자료를 저장, 검색, 삽입, 삭제한다. 대용량 데이터와 빠른 검색을 위해 사용한다.&lt;/p&gt;&lt;p&gt;중복되는 key값을 위해서는 multi를 붙여 사용한다.&lt;/p&gt;&lt;p&gt;종류 : map, set, hash_map, hash_set&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>STL</category>
      <category>시퀀스 컨테이너</category>
      <category>연관 컨테이너</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/151</guid>
      <comments>https://2heedu.tistory.com/151#entry151comment</comments>
      <pubDate>Wed, 3 Oct 2018 18:19:42 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 7576] 토마토</title>
      <link>https://2heedu.tistory.com/150</link>
      <description>&lt;p&gt;백준 :: BOJ :: 7576 :: 토마토&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/7576&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/7576&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct a {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;int N, M, ans, result;&lt;/p&gt;&lt;p&gt;int arr[1000][1000];&lt;/p&gt;&lt;p&gt;int di[] = { 0,0,1,-1 }, dj[] = {1,-1,0,0};&lt;/p&gt;&lt;p&gt;bool visited[1000][1000];&lt;/p&gt;&lt;p&gt;queue&amp;lt;a&amp;gt; q;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool check(int i, int j) { return (i &amp;gt;= 0 &amp;amp;&amp;amp; j &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; N &amp;amp;&amp;amp; j &amp;lt; M) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int bfs() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (ans == 0) return&amp;nbsp; 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!q.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int t = q.size();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;while (t--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;auto tmp = q.front(); q.pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int d = 0; d &amp;lt; 4; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;int ni = tmp.i + di[d], nj = tmp.j + dj[d];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (check(ni, nj) &amp;amp;&amp;amp; arr[ni][nj]==0 &amp;amp;&amp;amp; !visited[ni][nj]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;visited[ni][nj] = 1; ans--; q.push({ ni,nj });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;result++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (ans == 0) return result;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return -1;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;std::ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; M &amp;gt;&amp;gt; N; ans = 0; result = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; N; i++) for (int j = 0; j &amp;lt; M; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; arr[i][j];&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (arr[i][j]==1) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;q.push({ i,j }); visited[i][j] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else if (arr[i][j] == 0) ans++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; bfs();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>boj</category>
      <category>백준</category>
      <category>알고리즘</category>
      <category>토마토</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/150</guid>
      <comments>https://2heedu.tistory.com/150#entry150comment</comments>
      <pubDate>Tue, 2 Oct 2018 21:04:57 +0900</pubDate>
    </item>
    <item>
      <title>[BOJ 2178] 미로탐색</title>
      <link>https://2heedu.tistory.com/149</link>
      <description>&lt;p&gt;백준 :: BOJ :: 2178 :: 미로탐색&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.acmicpc.net/problem/2178&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.acmicpc.net/problem/2178&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct a {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int i, j, c;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;int N, M, ans;&lt;/p&gt;&lt;p&gt;int arr[101][101];&lt;/p&gt;&lt;p&gt;int di[] = { 0,0,1,-1 }, dj[] = {1,-1,0,0};&lt;/p&gt;&lt;p&gt;bool visited[101][101];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;inline bool check(int i, int j) { return (i &amp;gt; 0 &amp;amp;&amp;amp; j &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt;= N &amp;amp;&amp;amp; j &amp;lt;= M) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int bfs() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;queue&amp;lt;a&amp;gt; q;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;q.push({ 1, 1, 1 }); visited[1][1] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (!q.empty()) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;auto tmp = q.front(); q.pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (tmp.i == N &amp;amp;&amp;amp; tmp.j == M) return tmp.c;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int d = 0; d &amp;lt; 4; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;int ni = tmp.i + di[d], nj = tmp.j + dj[d];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (check(ni, nj) &amp;amp;&amp;amp; arr[ni][nj] &amp;amp;&amp;amp; !visited[ni][nj]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;q.push({ ni,nj,tmp.c + 1 }); visited[ni][nj] = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M; ans = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 1; i &amp;lt;= N; i++) for (int j = 1; j &amp;lt;= M; j++) scanf(&quot;%1d&quot;, &amp;amp;arr[i][j]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; bfs();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/BOJ</category>
      <category>2178</category>
      <category>boj</category>
      <category>미로탐색</category>
      <category>백준</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/149</guid>
      <comments>https://2heedu.tistory.com/149#entry149comment</comments>
      <pubDate>Tue, 2 Oct 2018 20:50:18 +0900</pubDate>
    </item>
    <item>
      <title>[C++] 파일 입출력 string 한 줄씩 읽어오기</title>
      <link>https://2heedu.tistory.com/148</link>
      <description>&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;string이 들어있는 파일을 읽어서 한 줄씩 vector에 넣는 코드&lt;/p&gt;&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; ReadLine(string s) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; r;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;string line(&quot;&quot;);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ifstream in(s.c_str());&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;if (in.is_open())&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;while (!in.eof())&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;getline(in, line);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;r.push_back(line);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;in.close();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return r;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;string filename;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; filename;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; v;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;v = ReadLine(filename);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-left: 2em;&quot;&gt;&amp;nbsp; string Output = &quot;aaa&quot;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ofstream ofs;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ofs.open(Output);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ofs &amp;lt;&amp;lt; 1 ;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;ofs.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>공부/SW</category>
      <category>string</category>
      <category>파일 입출력</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/148</guid>
      <comments>https://2heedu.tistory.com/148#entry148comment</comments>
      <pubDate>Tue, 2 Oct 2018 18:34:35 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Connected Cells in a Grid</title>
      <link>https://2heedu.tistory.com/147</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/connected-cell-in-a-grid/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/connected-cell-in-a-grid/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;bool visited[10][10];&lt;/p&gt;&lt;p&gt;int cnt, dy[] = {0,0,1,-1, 1, 1 , -1, -1}, dx[] = {1,-1,0,0,-1,1,1,-1};&lt;/p&gt;&lt;p&gt;inline bool check(int i, int j, int n, int m) { return (i &amp;gt;= 0 &amp;amp;&amp;amp; j &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; n &amp;amp;&amp;amp; j &amp;lt; m) ? true : false; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int dfs(int n, int m, int i, int j, int cnt, vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; v) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; visited[i][j] = 1; cnt++;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int d = 0; d &amp;lt; 8; d++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int ni = i + dy[d], nj = j + dx[d];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (check(ni,nj,n,m) &amp;amp;&amp;amp; v[ni][nj] &amp;amp;&amp;amp; !visited[ni][nj]) cnt = dfs(n,m,ni, nj, cnt, v);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return cnt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int connectedCell(vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; matrix) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int ans = 0, n = matrix.size(), m = matrix[0].size();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; memset(visited, 0, sizeof(visited));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int j = 0; j &amp;lt; m; j++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (matrix[i][j] &amp;amp;&amp;amp; !visited[i][j]) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ans = max(ans, dfs(n,m,i, j, 0, matrix));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int m;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; m;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; matrix(n);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; matrix[i].resize(m);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int j = 0; j &amp;lt; m; j++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; matrix[i][j];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int result = connectedCell(matrix);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>Connected Cells in a Grid</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/147</guid>
      <comments>https://2heedu.tistory.com/147#entry147comment</comments>
      <pubDate>Tue, 2 Oct 2018 14:33:04 +0900</pubDate>
    </item>
    <item>
      <title>[STL] Set 셋</title>
      <link>https://2heedu.tistory.com/146</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 24px;&quot;&gt;&lt;b&gt;Set 셋&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;set은 map과 비슷하지만 오직 key만 있다. map과 특징이 같고 빠른 검색이 필요할때 사용한다.&lt;/p&gt;&lt;p&gt;insert를 하게 되면 자동으로 정렬되어 저장된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;만약, key값 중복을 원하면 multiset을 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;set&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;set&amp;lt;int&amp;gt; s; : int 자료형의 set s 선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.size() : 노드 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.begin() : 첫 번째 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.end() : 마지막 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.find(a) : key가 a인 노드 찾아 해당 iterator 리턴, 만약 존재하지 않으면 마지막 iterator 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.insert(make_pair(a,b)) : a key의 b value 삽입&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.erase(a) : key가 a인 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.clear() : 모든 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.count(a) : key가 a인 원소들 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;ex) set s에 vector v추가&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;// s : 1, 3&amp;nbsp; &amp;nbsp; ,&amp;nbsp; v : 2, 3, 4&lt;/b&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;s.insert(v.begin(), v.end());&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;// s : 1, 2, 3, 4&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>set</category>
      <category>STL</category>
      <category>셋</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/146</guid>
      <comments>https://2heedu.tistory.com/146#entry146comment</comments>
      <pubDate>Tue, 2 Oct 2018 13:51:19 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Lily's Homework</title>
      <link>https://2heedu.tistory.com/145</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/lilys-homework/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/lilys-homework/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int cnt(vector&amp;lt;int&amp;gt;arr, vector&amp;lt;int&amp;gt;a, map&amp;lt;int, int&amp;gt; m) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int ans = 0;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i&amp;lt;arr.size(); i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (arr[i] != a[i]) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int tmp = m[a[i]];swap(arr[tmp], arr[i]);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m[arr[tmp]] = tmp; ans++;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int lilysHomework(vector&amp;lt;int&amp;gt; arr) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; v(arr); map&amp;lt;int, int&amp;gt; m;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; arr.size(); i++) m[arr[i]] = i;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; sort(v.begin(), v.end());&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int ans = cnt(arr, v, m);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; reverse(v.begin(), v.end());&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return min(ans, cnt(arr, v, m));&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string arr_temp_temp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; getline(cin, arr_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;string&amp;gt; arr_temp = split_string(arr_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; arr(n);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int arr_item = stoi(arr_temp[i]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr[i] = arr_item;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int result = lilysHomework(arr);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string input_string) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string::iterator new_end = unique(input_string.begin(), input_string.end(), [](const char &amp;amp;x, const char &amp;amp;y) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return x == y and x == ' ';&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; });&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; input_string.erase(new_end, input_string.end());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; while (input_string[input_string.length() - 1] == ' ') {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input_string.pop_back();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;string&amp;gt; splits;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; char delimiter = ' ';&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; size_t i = 0;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; size_t pos = input_string.find(delimiter);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; while (pos != string::npos) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; splits.push_back(input_string.substr(i, pos - i));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = pos + 1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pos = input_string.find(delimiter, i);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return splits;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>Lily's Homework</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/145</guid>
      <comments>https://2heedu.tistory.com/145#entry145comment</comments>
      <pubDate>Tue, 2 Oct 2018 13:39:37 +0900</pubDate>
    </item>
    <item>
      <title>[STL] Map 맵</title>
      <link>https://2heedu.tistory.com/144</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;Map 맵&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;각 노드가 key와 value의 쌍으로 이루어진 red-black tree이다.&lt;/p&gt;&lt;p&gt;key를 기준으로 정렬된 상태이기 때문에 검색, 삽입, 삭제 등의 속도가 빠르다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;주의할 점은 key가 중복이면 새로 추가하는 value값으로 덮어쓰기가 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;만약, key값 중복을 원하면 map말고 multimap을 사용한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;map&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;map&amp;lt;key,value&amp;gt;처럼 key, value의 pair로 선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;map&amp;lt;int,int&amp;gt; m : key와 value 자료형이 int인 map m 선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.size() : 노드 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.begin() : 첫 번째 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.end() : 마지막 원소 iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.find(a) : key가 a인 노드 찾아 해당 iterator 리턴, 만약 존재하지 않으면 마지막 iterator 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.insert(make_pair(a,b)) : a key의 b value 삽입&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.erase(a) : key가 a인 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.clear() : 모든 원소 삭제&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;m.count(a) : key가 a인 원소들 개수 리턴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;ex) unsorted 배열과 sorted 배열을 비교하여 sorting count 계산 코드&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; margin-left: 2em;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;vector &amp;lt;int&amp;gt; unsorted_arr = { 4,3,1,2 };&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector &amp;lt;int&amp;gt; sorted_arr(unsorted_arr);&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;sort(sorted_arr.begin(), sorted_arr.end());&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;map&amp;lt;int, int&amp;gt; m;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; arr.size(); i++) m[arr[i]] = i;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int ans = 0;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i&amp;lt;unsorted_arr.size(); i++) {&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt; if (unsorted_arr[i] != sorted_arr[i]) {&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt; int tmp = m[sorted_arr[i]]; swap(unsorted_arr[tmp], unsorted_arr[i]);&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt; m[unsorted_arr[tmp]] = tmp; ans++;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt; }&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt; }&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cout &amp;lt;&amp;lt; ans;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>map</category>
      <category>STL</category>
      <category>맵</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/144</guid>
      <comments>https://2heedu.tistory.com/144#entry144comment</comments>
      <pubDate>Tue, 2 Oct 2018 13:38:15 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] The Grid Search</title>
      <link>https://2heedu.tistory.com/143</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/the-grid-search/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/the-grid-search/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string gridSearch(vector&amp;lt;string&amp;gt; G, vector&amp;lt;string&amp;gt; P, int R, int r, int C, int c) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt;= R - r; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt;= C - c; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;bool chk = false;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int n = 0; n &amp;lt; r; n++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;for (int m = 0; m &amp;lt; c; m++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (G[i + n][j + m] != P[n][m]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;chk = true; break;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (chk) break;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (!chk) return &quot;YES&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return &quot;NO&quot;;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int t;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; t;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int t_itr = 0; t_itr &amp;lt; t; t_itr++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string RC_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;getline(cin, RC_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;string&amp;gt; RC = split_string(RC_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int R = stoi(RC[0]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int C = stoi(RC[1]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;string&amp;gt; G(R);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; R; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;string G_item;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;getline(cin, G_item);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;G[i] = G_item;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string rc_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;getline(cin, rc_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;string&amp;gt; rc = split_string(rc_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int r = stoi(rc[0]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int c = stoi(rc[1]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;string&amp;gt; P(r);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; r; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;string P_item;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;getline(cin, P_item);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;P[i] = P_item;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string result = gridSearch(G, P,R,r,C,c);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string input_string) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string::iterator new_end = unique(input_string.begin(), input_string.end(), [](const char &amp;amp;x, const char &amp;amp;y) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;return x == y and x == ' ';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;});&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;input_string.erase(new_end, input_string.end());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (input_string[input_string.length() - 1] == ' ') {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;input_string.pop_back();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; splits;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;char delimiter = ' ';&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t i = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t pos = input_string.find(delimiter);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (pos != string::npos) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;splits.push_back(input_string.substr(i, pos - i));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i = pos + 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;pos = input_string.find(delimiter, i);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return splits;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>The Grid Search</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/143</guid>
      <comments>https://2heedu.tistory.com/143#entry143comment</comments>
      <pubDate>Mon, 1 Oct 2018 21:32:52 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] The Time in Words</title>
      <link>https://2heedu.tistory.com/142</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/the-time-in-words/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/the-time-in-words/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string minutes[30] = { &quot;one minute&quot;,&lt;/p&gt;&lt;p&gt;&quot;two minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;three minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;four minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;five minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;six minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;seven minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;eight minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;nine minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;ten minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;eleven minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twelve minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;thirteen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;forteen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;quarter&quot;,&lt;/p&gt;&lt;p&gt;&quot;sixteen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;seventeen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;eighteen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;nineteen minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty one minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty two minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty three minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty four minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty five minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty six minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty seven minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty eight minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;twenty nine minutes&quot;,&lt;/p&gt;&lt;p&gt;&quot;half&quot; };&lt;/p&gt;&lt;p&gt;string hours[12] = { &quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;, &quot;five&quot;, &quot;six&quot;, &quot;seven&quot;, &quot;eight&quot;, &quot;nine&quot;, &quot;ten&quot;, &quot;eleven&quot;, &quot;twelve&quot; };&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string timeInWords(int h, int m) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (m == 0) return hours[h - 1] + &quot; o' clock&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else if (m &amp;lt;= 30) return minutes[m - 1] + &quot; past &quot; + hours[h - 1];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else return minutes[60 - m - 1] + &quot; to &quot; + hours[h];&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int h;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; h;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int m;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; m;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string result = timeInWords(h, m);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>The Time in Words</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/142</guid>
      <comments>https://2heedu.tistory.com/142#entry142comment</comments>
      <pubDate>Mon, 1 Oct 2018 20:56:16 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Bigger is Greater</title>
      <link>https://2heedu.tistory.com/141</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/bigger-is-greater/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/bigger-is-greater/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string biggerIsGreater(string w) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string z; int n = w.size();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = n - 1; i &amp;gt;= 0; i--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (i == 0) return &quot;no answer&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (w[i] == w[i - 1]) continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (w[i] &amp;gt; w[i - 1]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;char c; c = w[i]; w[i] = w[i - 1]; w[i - 1] = c;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;return w;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;int j = i-1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;while (j&amp;gt;=0) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (w[j] &amp;gt;= w[j + 1]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;if (j == 0) return &quot;no answer&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;j--; continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;char c = w[j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;z = w.substr(j + 1, n - (j + 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;w.erase(j, n - j);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;for (int m = 0; m &amp;lt; z.size(); m++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;							&lt;/span&gt;if (z[m] &amp;lt;= c) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;w += z[m - 1]; z[m - 1] = c;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;for (int kk = z.size() - 1; kk &amp;gt;= 0; kk--) w += z[kk];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;return w;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;							&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;							&lt;/span&gt;if (m == z.size() - 1) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;w += z[m]; z[m] = c;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;for (int kk = z.size() - 1; kk &amp;gt;= 0; kk--) w += z[kk];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;								&lt;/span&gt;return w;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;							&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return w;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int T;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; T;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int T_itr = 0; T_itr &amp;lt; T; T_itr++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string w;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;getline(cin, w);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string result = biggerIsGreater(w);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>Bigger is Greater</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/141</guid>
      <comments>https://2heedu.tistory.com/141#entry141comment</comments>
      <pubDate>Mon, 1 Oct 2018 20:49:00 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Organizing Containers of Balls</title>
      <link>https://2heedu.tistory.com/140</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/organizing-containers-of-balls/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/organizing-containers-of-balls/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string organizingContainers(vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; container) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int n = container.size(); vector&amp;lt;int&amp;gt; a(n,0), b(n,0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; n; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;b[i] += container[i][j]; a[j] += container[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;sort(a.begin(), a.end()); sort(b.begin(), b.end());&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) if (a[i] != b[i]) return &quot;Impossible&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return &quot;Possible&quot;;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int q;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; q;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int q_itr = 0; q_itr &amp;lt; q; q_itr++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int n;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; n;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; container(n);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;container[i].resize(n);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int j = 0; j &amp;lt; n; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;cin &amp;gt;&amp;gt; container[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;string result = organizingContainers(container);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>Organizing Containers of Balls</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/140</guid>
      <comments>https://2heedu.tistory.com/140#entry140comment</comments>
      <pubDate>Mon, 1 Oct 2018 19:14:39 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Queen's Attack II</title>
      <link>https://2heedu.tistory.com/139</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/queens-attack-2/problem?h_r=internal-search&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/queens-attack-2/problem?h_r=internal-search&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int queensAttack(int n, int k, int r_q, int c_q, vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; obstacles) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int ans = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;bool check[8] = {0,0,0,0,0,0,0,0};&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int ck[8] = { 0,0,0,0,0,0,0,0 };&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; k; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int xr = obstacles[i][0]; int xc = obstacles[i][1];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (xr == r_q &amp;amp;&amp;amp; xc != c_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (xc &amp;gt; c_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (check[2]) ck[2] = min(ck[2], (xc - c_q - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else { check[2] = true; ck[2] = (xc - c_q - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (check[6]) ck[6] = min(ck[6], (c_q - xc - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else { check[6] = true; ck[6] = (c_q - xc - 1);}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else if (xc == c_q &amp;amp;&amp;amp; xr != r_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (xr &amp;gt; r_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (check[0]) ck[0] = min(ck[0], (xr - r_q - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else { check[0] = true; ck[0] = (xr - r_q - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (check[4]) ck[4] = min(ck[4], (r_q - xr - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else { check[4] = true; ck[4] = (r_q - xr - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;else if (abs(xr - r_q) == abs(xc - c_q)) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (xr &amp;gt; r_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (xc &amp;gt; c_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (check[1]) ck[1] = min(ck[1], (abs(xr - r_q) - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else { check[1] = true; ck[1] = (abs(xr - r_q) - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (check[7]) ck[7] = min(ck[7], (abs(xr - r_q) - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else { check[7] = true; ck[7] = (abs(xr - r_q) - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (xc &amp;gt; c_q) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (check[3]) ck[3] = min(ck[3], (abs(xr - r_q) - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else { check[3] = true; ck[3] = (abs(xr - r_q) - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (check[5]) ck[5] = min(ck[5], (abs(xr - r_q) - 1));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;else { check[5] = true; ck[5] = (abs(xr - r_q) - 1); }&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; 8; i++) if (ck[i]) ans += ck[i];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int d = 0; d &amp;lt; 8; d++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (!check[d]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (d == 0) ans += (n - r_q);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 4 ) ans += (r_q - 1);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 2 ) ans += (n - c_q);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 6 ) ans += (c_q - 1);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 1 ) ans += (min((n-c_q),(n-r_q)));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 3 ) ans += (min((n - c_q), (r_q-1)));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 5 ) ans += (min((c_q-1), (r_q-1)));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;else if (d == 7 ) ans += (min((c_q-1), (n - r_q)));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string nk_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;getline(cin, nk_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; nk = split_string(nk_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int n = stoi(nk[0]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int k = stoi(nk[1]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string r_qC_q_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;getline(cin, r_qC_q_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; r_qC_q = split_string(r_qC_q_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int r_q = stoi(r_qC_q[0]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int c_q = stoi(r_qC_q[1]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; obstacles(k);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; k; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;obstacles[i].resize(2);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; 2; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin &amp;gt;&amp;gt; obstacles[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int result = queensAttack(n, k, r_q, c_q, obstacles);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string input_string) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string::iterator new_end = unique(input_string.begin(), input_string.end(), [](const char &amp;amp;x, const char &amp;amp;y) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;return x == y and x == ' ';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;});&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;input_string.erase(new_end, input_string.end());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (input_string[input_string.length() - 1] == ' ') {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;input_string.pop_back();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; splits;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;char delimiter = ' ';&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t i = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t pos = input_string.find(delimiter);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (pos != string::npos) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;splits.push_back(input_string.substr(i, pos - i));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i = pos + 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;pos = input_string.find(delimiter, i);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return splits;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>Queen's Attack II</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/139</guid>
      <comments>https://2heedu.tistory.com/139#entry139comment</comments>
      <pubDate>Sun, 30 Sep 2018 20:17:00 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Encryption</title>
      <link>https://2heedu.tistory.com/138</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/encryption/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/encryption/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;string encryption(string s) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string ans;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int L = s.length(), row = sqrt(L), col = row + 1, it = 0;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (row*row == L) col -= 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (row*col &amp;lt; L) row += 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;char arr[10][10]; memset(arr, 0, sizeof(arr));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; row; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; col &amp;amp;&amp;amp; it&amp;lt;L; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;arr[i][j] = s.at(it);it++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int j = 0; j &amp;lt; col; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; row; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (arr[i][j]) ans += arr[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if(j!=col-1)ans += &quot; &quot;;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string s;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;getline(cin, s);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string result = encryption(s);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>encryption</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/138</guid>
      <comments>https://2heedu.tistory.com/138#entry138comment</comments>
      <pubDate>Sun, 30 Sep 2018 17:02:31 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Non-Divisible Subset</title>
      <link>https://2heedu.tistory.com/137</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/non-divisible-subset/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/non-divisible-subset/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string);&lt;/p&gt;&lt;p&gt;int check[100];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int nonDivisibleSubset(int k, vector&amp;lt;int&amp;gt; S) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int ans = 0; memset(check, 0, sizeof(check));&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; S.size(); i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;S[i] %= k; check[S[i]]++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int tmp = k / 2; int i = tmp; int j = tmp + 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (check[0]) ans++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (!(k % 2)) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (check[tmp]) ans++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i--;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (i,j; i &amp;gt;= 1; i--, j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int z = min(check[i], check[j]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;ans += (check[i] + check[j] - (z * 2) + z);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string nk_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;getline(cin, nk_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; nk = split_string(nk_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int n = stoi(nk[0]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int k = stoi(nk[1]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string S_temp_temp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;getline(cin, S_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; S_temp = split_string(S_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;int&amp;gt; S(n);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; n; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int S_item = stoi(S_temp[i]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;S[i] = S_item;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int result = nonDivisibleSubset(k, S);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string input_string) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;string::iterator new_end = unique(input_string.begin(), input_string.end(), [](const char &amp;amp;x, const char &amp;amp;y) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;return x == y and x == ' ';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;});&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;input_string.erase(new_end, input_string.end());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (input_string[input_string.length() - 1] == ' ') {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;input_string.pop_back();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;string&amp;gt; splits;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;char delimiter = ' ';&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t i = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;size_t pos = input_string.find(delimiter);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;while (pos != string::npos) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;splits.push_back(input_string.substr(i, pos - i));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;i = pos + 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;pos = input_string.find(delimiter, i);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return splits;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>hackerrank</category>
      <category>Non-Divisible Subset</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/137</guid>
      <comments>https://2heedu.tistory.com/137#entry137comment</comments>
      <pubDate>Sun, 30 Sep 2018 16:28:32 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Forming a Magic Square</title>
      <link>https://2heedu.tistory.com/136</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/magic-square-forming/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/magic-square-forming/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int MS[8][3][3] = {{ 2,9,4,7,5,3,6,1,8 },&lt;/p&gt;&lt;p&gt;{ 4,3,8,9,5,1,2,7,6 },&lt;/p&gt;&lt;p&gt;{ 4,9,2,3,5,7,8,1,6 },&lt;/p&gt;&lt;p&gt;{ 8,3,4,1,5,9,6,7,2 },&lt;/p&gt;&lt;p&gt;{ 8,1,6,3,5,7,4,9,2 },&lt;/p&gt;&lt;p&gt;{ 2,7,6,9,5,1,4,3,8 },&lt;/p&gt;&lt;p&gt;{ 6,1,8,7,5,3,2,9,4 },&lt;/p&gt;&lt;p&gt;{ 6,7,2,1,5,9,8,3,4 }};&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int formingMagicSquare(vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; s) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int ans = 9999, cnt=0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int m = 0; m &amp;lt; 8; m++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cnt = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; 3; i++) for (int j = 0; j &amp;lt; 3; j++) cnt += abs(s[i][j] - MS[m][i][j]);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;ans = min(ans, cnt);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt; s(3);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; 3; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;s[i].resize(3);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; 3; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin &amp;gt;&amp;gt; s[i][j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int result = formingMagicSquare(s);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout &amp;lt;&amp;lt; result &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>Forming a Magic Square</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/136</guid>
      <comments>https://2heedu.tistory.com/136#entry136comment</comments>
      <pubDate>Sun, 30 Sep 2018 15:53:17 +0900</pubDate>
    </item>
    <item>
      <title>[STL] Deque 덱</title>
      <link>https://2heedu.tistory.com/135</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;Deque 덱&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Double Ended Queue 자료구조다. 즉 queue와 stack의 장점을 가져온 것이다.&lt;/p&gt;&lt;p&gt;double linked list와 비슷하다고 생각하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;장점&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;앞과 뒤에서 삽입, 삭제가 좋다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;리스트처럼 크기가 가변적이다.&lt;/p&gt;&lt;p&gt;vector처럼 원소에 랜덤 접근 가능하다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;단점&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;vector와 같이 중간에 삽입, 삭제를 위해서는 해당 위치 앞 뒤 데이터를 모두 이동해야 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); padding: 10px; text-align: center;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;#include &amp;lt;deque&amp;gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;deque&amp;lt;int&amp;gt; dq&amp;nbsp;: int형 deque dq&amp;nbsp;선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;deque&amp;nbsp;&lt;/b&gt;&lt;b&gt;dq(n) : n개의 원소를 가진 dq&amp;nbsp;선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;deque&amp;nbsp;&lt;/b&gt;&lt;b&gt;dq(n,a) : a로 초기화된 n개의 원소를 가진 dq&amp;nbsp;선언&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;deque&amp;nbsp;&lt;/b&gt;&lt;b&gt;dq(dq2) : deque&amp;nbsp;dq2를 dq에 복사&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.assign(n,a) : a값으로 n개의 원소를 v에 할당&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.at(a) : a번째 원소 (범위를 점검, 안전)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq[a] : a번째 원소 (범위를 점검X, 빠름)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.front() : 제일 앞 원소&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.back() : 마지막 원소&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.begin() : beginning iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.end() : end iterator&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.clear() : 모든 원소 제거 ( 메모리는 제거X)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.empty() : 비었는지 판단&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.erase(i) : i가 가리키는 곳 제거&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.erase(a,b) : [a,b) 범위 제거&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.insert(a,b) : a위치에 b삽입&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.insert(a,b,c) : a위치에 b개의 c 삽입&amp;nbsp; /&amp;nbsp; a위치에 [b,c)의 원소 삽입&amp;nbsp; &amp;nbsp;(값인지 iterator인지의 차이)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.max_size() : 최대 원소 개수 (메모리 크기)&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.size() : 원소의 개수&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.capacity : 메모리 크기&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq. pop_back() : 마지막 원소 제거&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.push_front(a) : dq의 앞에 a추가&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq. push_back(a) : v의 끝에 a추가&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.rbegin() : 역 순의 첫 원소 가리킴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.rend() : 역 순의 마지막의 다음 가리킴&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.reserve(n) : n개의 원소 공간 미리 동적할당&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.resize(n) : 크기를 n으로 변경&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;dq.resize(a,b) : 크기를 a로 변경하는데 더 커졌을 경우 b로 초기화&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>자료구조/STL</category>
      <category>deque</category>
      <category>STL</category>
      <category>덱</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/135</guid>
      <comments>https://2heedu.tistory.com/135#entry135comment</comments>
      <pubDate>Sun, 30 Sep 2018 14:35:04 +0900</pubDate>
    </item>
    <item>
      <title>비트 연산자</title>
      <link>https://2heedu.tistory.com/134</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;비트 연산자&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;b&gt;&lt;/b&gt;&amp;amp; : And 연산&amp;nbsp; &amp;nbsp;101 &amp;amp; 100 = 100&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;| : OR 연산&amp;nbsp; &amp;nbsp; &amp;nbsp; 011 | 100 = 111&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;^ : XOR 연산&amp;nbsp; &amp;nbsp;101 ^ 111 = 010&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;~ : 비트 반전&amp;nbsp; &amp;nbsp;~(101) = 010&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&amp;lt;&amp;lt; : 비트 열 왼쪽 이동&amp;nbsp; 1&amp;lt;&amp;lt;3 = 100&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&amp;gt;&amp;gt; : 비트 열 오른쪽 이동&amp;nbsp; 1101&amp;gt;&amp;gt;2 = 11&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;작성자 : 히더&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <category>알고리즘/정리</category>
      <category>비트 연산자</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/134</guid>
      <comments>https://2heedu.tistory.com/134#entry134comment</comments>
      <pubDate>Sat, 29 Sep 2018 20:54:36 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA 5653] 줄기세포배양</title>
      <link>https://2heedu.tistory.com/133</link>
      <description>&lt;p&gt;SW Expert Academy :: SWEA :: 5653 :: 줄기세포배양&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRJ8EKe48DFAUo&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRJ8EKe48DFAUo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;struct cell {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int life, x, y;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int t, tc, ans;&lt;/p&gt;&lt;p&gt;int N, M, K;&lt;/p&gt;&lt;p&gt;int J[450][450];&lt;/p&gt;&lt;p&gt;int dx[] = { 0,0,1,-1 }, dy[] = { 1,-1,0,0 };&lt;/p&gt;&lt;p&gt;queue&amp;lt;cell&amp;gt; q[11];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void input() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0;i &amp;lt; 11;i++)while (!q[i].empty()) q[i].pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ans = 0; memset(J, 0, sizeof(J)); cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; M &amp;gt;&amp;gt; K;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; N; ++i) for (int j = 0; j &amp;lt; M; ++j) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; J[i + 175][j + 175];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if (J[i + 175][j + 175]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;q[J[i + 175][j + 175]].push({ 2 * J[i + 175][j + 175], i + 175, j + 175 });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void cal() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt;= K; ++i) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 10; j &amp;gt;= 1; --j) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;int q_s = q[j].size();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;for (int k = 0; k &amp;lt; q_s; ++k) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;cell cl = q[j].front(); q[j].pop();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;if (cl.life &amp;gt; j) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;if (J[cl.x][cl.y]&amp;gt;0) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;J[cl.x][cl.y] *= -1; ans++;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;q[j].push({ cl.life - 1,cl.x,cl.y });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else if (cl.life == j) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;q[j].push({ j - 1,cl.x,cl.y });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;for (int l = 0; l &amp;lt; 4; ++l) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;int nx = cl.x + dx[l];int ny = cl.y + dy[l];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;if (J[nx][ny]) continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;						&lt;/span&gt;q[j].push({ 2 * j,nx,ny });J[nx][ny] = j;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else if (j &amp;gt; cl.life &amp;amp;&amp;amp; cl.life) q[j].push({ cl.life - 1,cl.x,cl.y });&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;else ans--;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; t;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (tc = 1; tc &amp;lt;= t; ++tc) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;input(); cal();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cout &amp;lt;&amp;lt; &quot;#&quot; &amp;lt;&amp;lt; tc &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; ans &amp;lt;&amp;lt; '\n';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/SWEA</category>
      <category>5653</category>
      <category>SWEA</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <category>줄기세포배양</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/133</guid>
      <comments>https://2heedu.tistory.com/133#entry133comment</comments>
      <pubDate>Sat, 29 Sep 2018 20:37:33 +0900</pubDate>
    </item>
    <item>
      <title>[SWEA 5656] 벽돌 깨기</title>
      <link>https://2heedu.tistory.com/132</link>
      <description>&lt;p&gt;SW Expert Academy :: SWEA :: 5656 :: 벽돌 깨기&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRQm6qfL0DFAUo&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWXRQm6qfL0DFAUo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int T, tc, c, N, W, H;&lt;/p&gt;&lt;p&gt;int dx[] = { 0,0,1,-1 }, dy[] = { 1,-1,0,0 };&lt;/p&gt;&lt;p&gt;int arr[5][15][12];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void go(int D) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;queue&amp;lt;int&amp;gt; q;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int j = 0; j &amp;lt; W; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = H - 1; i &amp;gt;= 0; i--) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (arr[D][i][j]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;q.push(arr[D][i][j]); arr[D][i][j] = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = H - 1; q.size(); i--, q.pop()) arr[D][i][j] = q.front();&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int dfs(int x, int y, int D) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;int k = arr[D][x][y]; int ans = 1; arr[D][x][y] = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; k; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; 4; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;int nx = x + i*dx[j]; int ny = y + i*dy[j];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (nx &amp;lt; 0 || ny &amp;lt; 0 || nx &amp;gt;= H || ny &amp;gt;= W || !arr[D][nx][ny]) continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;ans += dfs(nx, ny, D);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int cal(int D) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if (D &amp;gt; N) return 0; int ans = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 0; i &amp;lt; W; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int m = 0; m &amp;lt; H; m++) for (int n = 0; n &amp;lt; W; n++) arr[D][m][n] = arr[D - 1][m][n];&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int tmp = 0; bool flg = 1;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int j = 0; j &amp;lt; H; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (arr[D][j][i]) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;flg = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;tmp = dfs(j, i, D);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;break;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if(flg) continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;go(D); ans = max(ans, cal(D + 1) + tmp);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main() {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ios::sync_with_stdio(false); cin.tie(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cin &amp;gt;&amp;gt; T;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (tc = 1; tc &amp;lt;= T; tc++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cin &amp;gt;&amp;gt; N &amp;gt;&amp;gt; W &amp;gt;&amp;gt; H;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;int cnt = 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int i = 0; i &amp;lt; H; i++) for (int j = 0; j &amp;lt; W; j++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;cin &amp;gt;&amp;gt; c; arr[0][i][j] = c; cnt += c ? 1 : 0;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;cout &amp;lt;&amp;lt; &quot;#&quot; &amp;lt;&amp;lt; tc &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; cnt - cal(1) &amp;lt;&amp;lt; '\n';&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/SWEA</category>
      <category>5656</category>
      <category>SWEA</category>
      <category>벽돌 깨기</category>
      <category>삼성</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/132</guid>
      <comments>https://2heedu.tistory.com/132#entry132comment</comments>
      <pubDate>Sat, 29 Sep 2018 17:29:21 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘] 기본 및 복잡도</title>
      <link>https://2heedu.tistory.com/131</link>
      <description>&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;알고리즘이란?&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;유한한 단계로 문제를 해결하는 로직이다. 컴퓨터가 어떤 일을 하는 수행의 단계적 방법이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;효율적인 알고리즘&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size:10pt;&quot;&gt;&lt;b&gt;&lt;/b&gt;메모리 공간을 최적화 하는&amp;nbsp;공간적 효율성, 수행 시간에 대해 최소의 시간을 고려하는 시간적 효율성 고려해야한다.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;효율성이 즉 복잡도가 된다.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;이러한 부분은 아키텍처, 자료구조, HW 환경, SW 환경 등 다양한 요소를 고려해야한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;복잡도의 점근적 표기 Big-Oh&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;시간 복잡도를 입력 크기에 대한 함수로 표기할 수 있다. 이를 점근적 표기(Asymptotic Notation)라 한다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;가장 큰 예로 Big-Oh&amp;nbsp;표기법이 있다. Big-Oh는 최대 이런 시간이 걸린다는 의미를 가진다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(1)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :&amp;nbsp; &amp;nbsp;상수 시간 (Constant time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(logn)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;:&amp;nbsp; &amp;nbsp;로그(대수) 시간 (Logarithmic time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(n)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;:&amp;nbsp; &amp;nbsp;선형&amp;nbsp;시간 (Linear time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(nlongn)&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;:&amp;nbsp; &amp;nbsp;로그 선형&amp;nbsp;시간 (Log-linear time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(n제곱)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;:&amp;nbsp; &amp;nbsp;제곱&amp;nbsp;시간 (Quadratic time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(n세제곱)&amp;nbsp; &amp;nbsp; :&amp;nbsp; &amp;nbsp;세제곱 시간 (Cubic time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;O(2의n제곱)&amp;nbsp; &amp;nbsp;:&amp;nbsp; &amp;nbsp;지수 시간 (Exponential time)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>알고리즘/이론</category>
      <category>공간 복잡도</category>
      <category>빅오</category>
      <category>시간 복잡도</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/131</guid>
      <comments>https://2heedu.tistory.com/131#entry131comment</comments>
      <pubDate>Sat, 29 Sep 2018 14:26:25 +0900</pubDate>
    </item>
    <item>
      <title>auto</title>
      <link>https://2heedu.tistory.com/130</link>
      <description>&lt;p&gt;auto는 자동으로 타입을 추론한다. 그러나 초기화는 반드시 해주어야 한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;iterator을 사용하게 될 때 유용하다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래는 HackerRank 알고리즘 문제에서 사용했었던 auto의 예시이다. vector의 iterator type을 위해 auto를 사용했다.&lt;/p&gt;&lt;p&gt;이때 j는 iterator이라서 *j 는 v[j]의 값을 가리키게 된다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void extraLongFactorials(int n) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;vector&amp;lt;int&amp;gt; v; v.push_back(1);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (int i = 2; i &amp;lt;= n; i++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (auto j = v.begin();j != v.end();j++) *j *= i;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;for (int k = 0; k &amp;lt; v.size(); k++) {&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (v[k] &amp;lt; 10) continue;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;if (k == v.size() - 1) v.push_back(0);&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;v[k + 1] += v[k] / 10; v[k] %= 10;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;for (auto it = v.rbegin(); it != v.rend(); it++) cout &amp;lt;&amp;lt; *it;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>알고리즘/정리</category>
      <category>Auto</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/130</guid>
      <comments>https://2heedu.tistory.com/130#entry130comment</comments>
      <pubDate>Fri, 28 Sep 2018 20:07:19 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Extra Long Factorials</title>
      <link>https://2heedu.tistory.com/129</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/extra-long-factorials/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/extra-long-factorials/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;void extraLongFactorials(int n) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; v; v.push_back(1);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 2; i &amp;lt;= n; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (auto j = v.begin();j != v.end();j++) *j *= i;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int k = 0; k &amp;lt; v.size(); k++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (v[k] &amp;lt; 10) continue;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (k == v.size() - 1) v.push_back(0);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v[k + 1] += v[k] / 10; v[k] %= 10;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (auto it = v.rbegin(); it != v.rend(); it++) cout &amp;lt;&amp;lt; *it;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; extraLongFactorials(n);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>Extra Long Factorials</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/129</guid>
      <comments>https://2heedu.tistory.com/129#entry129comment</comments>
      <pubDate>Fri, 28 Sep 2018 20:02:29 +0900</pubDate>
    </item>
    <item>
      <title>[HackerRank] Climbing the Leaderboard</title>
      <link>https://2heedu.tistory.com/128</link>
      <description>&lt;p&gt;출처 :&amp;nbsp;&lt;a href=&quot;https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); padding: 10px;&quot;&gt;&lt;p&gt;#include &amp;lt;bits/stdc++.h&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;int&amp;gt; climbingLeaderboard(vector&amp;lt;int&amp;gt; scores, vector&amp;lt;int&amp;gt; alice) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int s_size = scores.size(); int a_size = alice.size();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector &amp;lt;int&amp;gt; ans(a_size), tmp(s_size); int n = 1; tmp[0] = n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 1; i &amp;lt; s_size; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (scores[i] == scores[i - 1]) tmp[i] = n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else tmp[i] = ++n;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int it = s_size - 1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int j = 0; j &amp;lt; a_size; j++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = it; i &amp;gt;=0; i--) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (scores[i] &amp;lt; alice[j]) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (i == 0) {&lt;/p&gt;&lt;p&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; ans[j] = 1; it = 1; break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if (scores[i]&amp;gt;alice[j]) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ans[j] = tmp[i] + 1; it = i;break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ans[j] = tmp[i]; it = i; break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return ans;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;int main()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; ofstream fout(getenv(&quot;OUTPUT_PATH&quot;));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int scores_count;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; scores_count;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string scores_temp_temp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; getline(cin, scores_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;string&amp;gt; scores_temp = split_string(scores_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; scores(scores_count);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; scores_count; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int scores_item = stoi(scores_temp[i]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scores[i] = scores_item;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; int alice_count;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; alice_count;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cin.ignore(numeric_limits&amp;lt;streamsize&amp;gt;::max(), '\n');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string alice_temp_temp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; getline(cin, alice_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;string&amp;gt; alice_temp = split_string(alice_temp_temp);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; alice(alice_count);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; alice_count; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int alice_item = stoi(alice_temp[i]);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alice[i] = alice_item;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;int&amp;gt; result = climbingLeaderboard(scores, alice);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; result.size(); i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fout &amp;lt;&amp;lt; result[i];&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (i != result.size() - 1) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fout &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fout.close();&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;vector&amp;lt;string&amp;gt; split_string(string input_string) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string::iterator new_end = unique(input_string.begin(), input_string.end(), [](const char &amp;amp;x, const char &amp;amp;y) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return x == y and x == ' ';&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; });&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; input_string.erase(new_end, input_string.end());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; while (input_string[input_string.length() - 1] == ' ') {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input_string.pop_back();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;string&amp;gt; splits;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; char delimiter = ' ';&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; size_t i = 0;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; size_t pos = input_string.find(delimiter);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; while (pos != string::npos) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; splits.push_back(input_string.substr(i, pos - i));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = pos + 1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pos = input_string.find(delimiter, i);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return splits;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘/기타</category>
      <category>Climbing the Leaderboard</category>
      <category>hackerrank</category>
      <category>알고리즘</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/128</guid>
      <comments>https://2heedu.tistory.com/128#entry128comment</comments>
      <pubDate>Fri, 28 Sep 2018 19:18:02 +0900</pubDate>
    </item>
    <item>
      <title>[Kotlin] Kotlin과 Java</title>
      <link>https://2heedu.tistory.com/127</link>
      <description>&lt;p&gt;참조 :&amp;nbsp;&lt;a href=&quot;https://kotlinlang.org&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://kotlinlang.org&lt;/a&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://blog.jetbrains.com/kotlin/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://blog.jetbrains.com/kotlin/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Kotlin?&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Android 앱 개발을 하면서 Java를 사용하였고 Studio에서 제공하는 Kotlin 변환 기능을 보면서 Kotlin에 관심을 가지게 되었다.&lt;/p&gt;&lt;p&gt;Kotlin은 Jetbrains에서 만든 개발언어다. Android, JVM, 브라우저 등에서 사용가능하며 앞으로 웹, 임베디드, IoT 등 다양한 플랫폼으로 진출한다는 목표를 가지고 있다고 한다. 정적 타입의 언어로 2011년에 출시되었고 많은 앱 개발자들이 사용하고 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;b&gt;Kotlin vs Java&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;1. val과 var&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin은 변수 선언에서 val과 var을 사용한다. 타입추론이 가능하여서 Java와 다르게 type 생략이 가능하다. 또한 ;을 생략가능하다.&lt;/p&gt;&lt;p&gt;var은 variable의 약자로 read/write가 가능한 일반 변수(mutable)이다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;val은 valuable의 약자로 read만 가능한 final 변수(immutable)이다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;final int tmp = 1;&lt;/p&gt;&lt;/td&gt;
&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;val tmp = 1&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot; rowspan=&quot;1&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;String tmp = &quot;a&quot;;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot; rowspan=&quot;1&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;var tmp = &quot;a&quot;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;초기화시 값을 할당하지 않는다면 type을 명시합니다.&amp;nbsp; &amp;nbsp; &amp;nbsp; val tmp: Int&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type명은 제일 앞글자를 대문자로 합니다.&lt;/p&gt;&lt;p&gt;Java에서 Void tmp = null; 처럼 val tmp: Nothing? = null 과 같이 type을 생략할 수 있습니다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;2. Non-Null / Nullable&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin은 null 안정성을 가지고 있다. 모든 변수는 null을 허용하지 않지만 변수에 ?를 붙여서 nullable로 만들 수 있다.&lt;/p&gt;&lt;p&gt;null을 값으로 가질 수 없으면 Non-Null,&amp;nbsp; &amp;nbsp;가질 수 있으면 Nullable&lt;/p&gt;&lt;p&gt;var tmp: String? = null&amp;nbsp; 과 같이 쓰며 ?를 사용한다.&lt;/p&gt;&lt;p&gt;val tmp: Nothing? = null 과 같이 type을 생략할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;3. variable cast&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서는 as와 is를 통해 casting이 가능하다. as는 값의 casting, is는 값이 맞는지 체크한다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 391px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt; Object object = &quot;a&quot;;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;int it = 0;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;if(object instanceof Integer) {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; it = (int) object;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;} &lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;val a: Any? = &quot;a&quot;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;val b: Int? = a as? Int&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;if (a is Int) {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; b = a as? Int&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;4. Println&lt;/span&gt;&lt;/p&gt;&lt;p&gt;출력을 할 때 $를 통해 간편하게 할 수 있다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;System.out.println(&quot;a&quot; + tmp);&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;println(&quot;a $tmp&quot;)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;5. Class와 Propery&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서는 1개의 primary constructor, N개의 secondary constructor을 가진다. primary constructor을 위한 init {} block을 제공한다.&lt;/p&gt;&lt;p&gt;또한 primary constructor와 함께 오는 변수는 전역 변수이다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;default 값을 가질 수 있으며 default value 정의한 생성자를 Java에서 부르려면, @JvmOverloads를 적용해야 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서는 따로 나타내지 않으면 모두 public이다. class는 아래와 같이 선언한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; class Example(&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; val name: String&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var isMan: Boolean&lt;/p&gt;&lt;p&gt;&amp;nbsp; )&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; fun main(args: Array&amp;lt;String&amp;gt;) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; val person = Example(&quot;Heedu&quot;, true)&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;위와 같은 코드가 있을 때 컴파일러가 자동으로 getter와 setter를 만들어 준다. isMan처럼 is로 시작하는 property getter에는 get이 붙지 않고 is를 사용한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;6. companion object&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서는 static 대신&amp;nbsp;companion object를 사용하여 외부 접근을 가능하게 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;7. when&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서 when은 다양하게 쓰인다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;when을 switch처럼 쓰는데 이때, break이 필요없다. 조건문 및 반복문에서 when이 is와 함께 많이 쓰인다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;8. Loop&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서 반복문 중 for문이 Java와 조금 다르다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for (i=0;i&amp;lt;10;i++)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for(i=0;i&amp;lt;=10;i++)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for(i=10;i&amp;gt;=0;i--)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for(i=0;i&amp;lt;=10;i+=3);&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for (i in 0 until 10)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for (i in 0 .. N)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for (i in 10 downTo 0)&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;for(i in 0 .. 10 step 3)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;9. Safe call과 Elvis operator&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Kotlin에서 ?. 을 통해 안전 호출을 할 수 있다. 앞의 타입이 null이 아니면 호출하여 값을 리턴하고&amp;nbsp;아니면 null을 호출한다.&lt;/p&gt;&lt;p&gt;Elvis operator ?: 은 앞의 값이 참이면 값을 반환하고 아니면 지정한 값을 반환한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; val tmp = a?.length ?: -1&lt;/p&gt;&lt;p&gt;강제호출을 할때는 !! 을 사용한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;10. 상속&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; Default class : 모든 class/function은 재 정의 가능&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; abstract : extends로 상속 구현&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; interface : implement로 상속 구현&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;public interface A {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;void init();&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;public abstract class B {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public abstract void init();&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;public class C extends B implements A {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Override&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void init() {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 392px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; Default class : 모든 class/function은 재 정의 불가&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;재 정의를 위해서는 open 사용&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; 상속의 정의는 : 으로 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; 다중 상속은 , 로 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;interface A {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;fun init()&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;abstract class B {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;abstract fun init()&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;class C : B(), A {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;override fun init() {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;11. data class&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;784&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:13px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 391px; height: 24px; border-width: 2px; border-style: solid; border-color: rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Java&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-top: 2px solid rgb(0, 0, 0); background-color: rgb(217, 229, 255);&quot;&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Kotlin&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0); border-left: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; public class User {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private long id;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private String name;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; private String email;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; @Override&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public int hashCode() {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; @Override&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; public boolean equals(Object o) {&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this == o) return true;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (o == null) return false;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.getClass() != o.getClass()) return false;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; User user = (User) o;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return id != user.id&lt;/p&gt;&lt;p style=&quot;text-align: left;&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;amp;&amp;amp; (!name.equals(user.name)&lt;/p&gt;&lt;p style=&quot;text-align: left;&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;amp;&amp;amp; !email.equals(user.email));&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; }&lt;/p&gt;&lt;/td&gt;&lt;td style=&quot;width: 391px; height: 24px; border-bottom: 2px solid rgb(0, 0, 0); border-right: 2px solid rgb(0, 0, 0);&quot;&gt;&lt;p&gt;&amp;nbsp; data class User(val id: Long = 0,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; val name: String? = null,&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; val email: String? = null)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;12. 기타&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;외에도 여러가지 Java와 다른 Kotlin 기능들이 있다. Sealed class,&amp;nbsp; singleton,&amp;nbsp; lazy evaluation,&amp;nbsp; Lambda,&amp;nbsp; ViewBinding&amp;nbsp;등이 있다.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 글을 써보면서 실제 대형 프로젝트를 kotlin을 이용해서 하기 위해서는 더 많은 공부가 필요하다고 생각했다. 아직 완전 Kotlin으로만 완성된 앱보다는 Java와의 혼용이 된 앱이 많으므로 이를 고려해야 할 것 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>공부/SW</category>
      <category>java</category>
      <category>Kotlin</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/127</guid>
      <comments>https://2heedu.tistory.com/127#entry127comment</comments>
      <pubDate>Fri, 28 Sep 2018 16:23:38 +0900</pubDate>
    </item>
    <item>
      <title>메모리와 비메모리</title>
      <link>https://2heedu.tistory.com/126</link>
      <description>&lt;p&gt;메모리&lt;/p&gt;&lt;p&gt;1. 휘발성 (RAM)&lt;/p&gt;&lt;p&gt;- D램 : PC용 주기억장치로 정보처리 속도 및 그래픽 처리 능력에 따라 SSD, DDR 등이 있다.&lt;/p&gt;&lt;p&gt;- S램 : 소비전력이 적고 처리속도가 빨라서 cache에 사용.&lt;/p&gt;&lt;p&gt;- V램 : 화상정보를 기억하기 위한 전용 메모리.&lt;/p&gt;&lt;p&gt;2. 비휘발성 (ROM)&lt;/p&gt;&lt;p&gt;- Mask롬 : 제조공정 시 고객이 원하는 정보를 저장.&lt;/p&gt;&lt;p&gt;- EP롬 : 자외선을 이용하여 정보를 지우거나 저장.&lt;/p&gt;&lt;p&gt;- EEP롬 : ROM의 특징과 입출력할 수 있는 RAM의 특징을 가짐.&lt;/p&gt;&lt;p&gt;- Flash 메모리 : 전력소모가 적고 고속 프로그래밍, 대용량 저장 가능. HDD를 대체할 수 있는 제품으로 NOR(코드저장)과 NAND(데이터저장).&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;비메모리&lt;/p&gt;&lt;p&gt;1. 시스템 IC&amp;nbsp;&lt;/p&gt;&lt;p&gt;- 마이크로컴포넌트 : 컴퓨터 제어. Micro Processor Unit, Micro Controller Unit, Digital Signal Processor.&lt;/p&gt;&lt;p&gt;- Logic (ASIC) : 사용자 요구에 의해 설계된 특정 회로 반도체로 주문형 IC&lt;/p&gt;&lt;p&gt;- Analog IC : 제반 신호의 표현 처리를 연속적인 신호변환에 의해 인식하는 IC.&lt;/p&gt;&lt;p&gt;- LDI : LCD driver IC로서 구동 또는 제어 사용.&lt;/p&gt;&lt;p&gt;2. 개별소자 : Diode, 트랜지스터처럼 직접회로(IC)와는 달리 개별품목으로서 단일기능을 갖는 제품. 개별소자가 모여 IC.&lt;/p&gt;&lt;p&gt;3. 기타 : Opto (광반도체), 반도체 센서 등&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;작성자 : 히더&lt;/p&gt;</description>
      <category>공부/기타</category>
      <category>메모리</category>
      <category>비메모리</category>
      <author>히더</author>
      <guid isPermaLink="true">https://2heedu.tistory.com/126</guid>
      <comments>https://2heedu.tistory.com/126#entry126comment</comments>
      <pubDate>Fri, 28 Sep 2018 14:07:45 +0900</pubDate>
    </item>
  </channel>
</rss>