Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (35 sloc) 89 KB
---
layout : article
title: "[백준] 3055번 C/C++ 풀이 _ 탈출"
aside:
toc: true
tags: Algorithm
category : Algorithm
author: melonicedlatte
published : True
hellogohn_num : 356
key : 2018-09-17-021623
---
<h3>출처 :&nbsp;https://www.acmicpc.net/problem/3055</h3><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="page-header" style="border-radius: 0px !important;"><h1 style="margin-top: 5px; font-size: 28px; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 35px; color: rgb(88, 95, 105); text-shadow: none; border-radius: 0px !important;"><span id="problem_title" class="" style="border-radius: 0px !important;">탈출</span>&nbsp;<span class="label label-success problem-label" style="padding: 4px 7px; font-size: 11px; font-weight: 400;">성공</span><div class="btn-group pull-right problem-button" style="border-radius: 0px !important;"><button class="btn btn-default" type="button" id="favorite_button" data-favorite="0" style="border-top-left-radius: 4px; border-bottom-left-radius: 4px; font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; text-transform: none; padding: 6px 12px; box-shadow: none; outline: 0px !important;"><span class="glyphicon glyphicon-star-empty" id="favorite_image" style="border-radius: 0px !important;"></span></button><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#" id="lang-select-button" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; text-transform: none; padding-top: 6px; padding-bottom: 6px; box-shadow: none; outline: 0px !important;"><span class="lang-select-text" style="border-radius: 0px !important;">한국어&nbsp;</span>&nbsp;&nbsp;<span class="caret" style="border-top-style: solid; border-radius: 0px !important;"></span></button></div></h1></div></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="table-responsive" style="border-radius: 0px !important;"><table class="table" id="problem-info" style="width: 1140px; border-radius: 0px !important;"><thead style="border-radius: 0px !important;"><tr style="border-radius: 0px !important;"><th style="line-height: 1.42857; border-bottom: none; width: 183px; border-radius: 0px !important;">시간 제한</th><th style="line-height: 1.42857; border-bottom: none; width: 183px; border-radius: 0px !important;">메모리 제한</th><th style="line-height: 1.42857; border-bottom: none; width: 194px; border-radius: 0px !important;">제출</th><th style="line-height: 1.42857; border-bottom: none; width: 194px; border-radius: 0px !important;">정답</th><th style="line-height: 1.42857; border-bottom: none; width: 193px; border-radius: 0px !important;">맞은 사람</th><th style="line-height: 1.42857; border-bottom: none; width: 193px; border-radius: 0px !important;">정답 비율</th></tr></thead><tbody style="border-radius: 0px !important;"><tr style="border-radius: 0px !important;"><td style="line-height: 1.42857; border-radius: 0px !important;">1 초</td><td style="line-height: 1.42857; border-radius: 0px !important;">128 MB</td><td style="line-height: 1.42857; border-radius: 0px !important;">8586</td><td style="line-height: 1.42857; border-radius: 0px !important;">2532</td><td style="line-height: 1.42857; border-radius: 0px !important;">1726</td><td style="line-height: 1.42857; border-radius: 0px !important;">28.157%</td></tr></tbody></table></div></div><div id="problem-body" style="color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="description" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">문제</h2></div><div id="problem_description" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">사악한 암흑의 군주 이민혁은 드디어 마법 구슬을 손에 넣었고, 그 능력을 실험해보기 위해 근처의 티떱숲에 홍수를 일으키려고 한다. 이 숲에는 고슴도치가 한 마리 살고 있다. 고슴도치는 제일 친한 친구인 비버의 굴로 가능한 빨리 도망가 홍수를 피하려고 한다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">티떱숲의 지도는 R행 C열로 이루어져 있다. 비어있는 곳은 '.'로 표시되어 있고, 물이 차있는 지역은 '*', 돌은 'X'로 표시되어 있다. 비버의 굴은 'D'로, 고슴도치의 위치는 'S'로 나타내어져 있다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">매 분마다 고슴도치는 현재 있는 칸과 인접한 네 칸 중 하나로 이동할 수 있다. (위, 아래, 오른쪽, 왼쪽) 물도 매 분마다 비어있는 칸으로 확장한다. 물이 있는 칸과 인접해있는 비어있는 칸(적어도 한 변을 공유)은 물이 차게 된다. 물과 고슴도치는 돌을 통과할 수 없다. 또, 고슴도치는 물로 차있는 구역으로 이동할 수 없고, 물도 비버의 소굴로 이동할 수 없다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">티떱숲의 지도가 주어졌을 때, 고슴도치가 안전하게 비버의 굴로 이동하기 위해 필요한 최소 시간을 구하는 프로그램을 작성하시오.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">고슴도치는 물이 찰 예정인 칸으로 이동할 수 없다. 즉, 다음 시간에 물이 찰 예정인 칸으로 고슴도치는 이동할 수 없다. 이동할 수 있으면 고슴도치가 물에 빠지기 때문이다.&nbsp;</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="input" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">입력</h2></div><div id="problem_input" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">첫째 줄에 50보다 작거나 같은 자연수 R과 C가 주어진다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">다음 R개 줄에는 티떱숲의 지도가 주어지며, 문제에서 설명한 문자만 주어진다. 'D'와 'S'는 하나씩만 주어진다.</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="output" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">출력</h2></div><div id="problem_output" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">첫째 줄에 고슴도치가 비버의 굴로 이동할 수 있는 가장 빠른 시간을 출력한다. 만약, 안전하게 비버의 굴로 이동할 수 없다면, "KAKTUS"를 출력한다.</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><div class="row" style="border-radius: 0px !important;"><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleinput1" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 입력 1&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-input-1" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-input-1" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">3 3
D.*
...
.S.
</pre></section></div><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleoutput1" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 출력 1&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-output-1" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-output-1" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">3
</pre></section></div></div></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><div class="row" style="border-radius: 0px !important;"><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleinput2" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 입력 2&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-input-2" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-input-2" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">3 3
D.*
...
..S
</pre></section></div><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleoutput2" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 출력 2&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-output-2" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-output-2" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">KAKTUS
</pre></section></div></div></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><div class="row" style="border-radius: 0px !important;"><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleinput3" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 입력 3&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-input-3" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-input-3" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">3 6
D...*.
.X.X..
....S.
</pre></section></div><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleoutput3" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 출력 3&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-output-3" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-output-3" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">6
</pre></section></div></div></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><div class="row" style="border-radius: 0px !important;"><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleinput4" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 입력 4&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-input-4" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-input-4" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">5 4
.D.*
....
..X.
S.*.
....
</pre></section></div><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleoutput4" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 출력 4&nbsp;<button type="button" class="btn btn-link copy-button" data-clipboard-target="#sample-output-4" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-output-4" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">4
</pre></section></div></div></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"></div></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><section id="source" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">출처</h2></div><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="https://www.acmicpc.net/category/45" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">Contest&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/17" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">Croatian Open Competition in Informatics&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/24" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">COCI 2006/2007&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/108" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">Contest #1</a>&nbsp;4번</p><ul style="border-radius: 0px !important;"><li style="color: rgb(85, 85, 85); border-radius: 0px !important;">문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">baekjoon</a></li><li style="color: rgb(85, 85, 85); border-radius: 0px !important;">데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/cjstjdgur123" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">cjstjdgur123</a></li></ul></section></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><section id="problem_link" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">링크</h2></div><ul style="border-radius: 0px !important;"><li style="color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="http://acm.tju.edu.cn/toj/showp2947.html" rel="nofollow" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">TJU Online Judge</a></li><li style="color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="http://www.spoj.com/problems/CSLIKAR/" rel="nofollow" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">Sphere Online Judge</a></li></ul></section></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><section id="problem_tags" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">알고리즘 분류</h2></div><ul class="spoiler-list" style="border-radius: 0px !important;"><li style="color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="https://www.acmicpc.net/problem/tag/BFS" class="spoiler-link" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">BFS</a></li><li style="color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="https://www.acmicpc.net/problem/tag/%EC%8B%9C%EB%AE%AC%EB%A0%88%EC%9D%B4%EC%85%98" class="spoiler-link" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">시뮬레이션</a></li></ul></section></div><h3>풀이</h3><p>알고리즘은 bfs를 이용하면 풀 수 있는 문제입니다.&nbsp;<br>알고리즘을 모른다기보다는 시뮬레이션이라 구현이 다소 복잡한 문제였습니다.&nbsp;</p><p>저 같은 경우에는 map에는 초기 배치를 저장했습니다. <br>고슴도치가 방문한 곳을 저장하는 goseum_depth, 물이 방문한 곳을 저장하는 water_depth 배열을 생성했습니다.<br>큐는 두 개를 사용하여 '물'과 '고슴도치' 에 대한 각 단계의 bfs 를 진행했습니다.&nbsp;</p><p>water 큐에서 new_row와 new_col을 받은 다음에 인덱스 체크, 기존에 물이 차있었는지 여부, 비버 집인지, 돌인지를 체크합니다.&nbsp;<br>goseum 큐에서는 new_row와 new_col 을 받은 다음에 직전 단계에서 물이 차있었으면 고슴도치가 갈 수 없다고 판단하고 넘깁니다.<br>해당 구문을 통과하면 water 과 같이 조건 체크를 하고 목적지에 도달하면 depth 를 출력해줍니다.&nbsp;&nbsp;</p><p>자세한 풀이는 소스코드를 참조해주세요~</p><p><a href="http://mygumi.tistory.com/232">http://mygumi.tistory.com/232</a>&nbsp;<br></p><p>비슷한 풀이입니다. 참고해주세요~&nbsp;</p><h3>소스코드</h3><div class="colorscripter-code" style="color: rgb(255, 255, 255); overflow: auto; font-family: Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace !important; position: relative !important; line-height: 1.2;"><table class="colorscripter-code-table" style="margin:0; padding:0; border:none; background-color:#1E1E1E; border-radius:4px;" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:6px; border-right:2px solid #4f4f4f"><div style="margin: 0px; padding: 0px; word-break: normal; text-align: right; color: rgb(170, 170, 170); line-height: 1.2;"><div style="line-height: 1.2;"><span style="font-size: 14px;">1</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">2</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">3</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">4</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">5</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">6</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">7</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">8</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">9</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">10</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">11</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">12</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">13</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">14</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">15</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">16</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">17</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">18</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">19</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">20</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">21</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">22</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">23</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">24</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">25</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">26</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">27</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">28</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">29</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">30</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">31</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">32</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">33</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">34</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">35</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">36</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">37</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">38</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">39</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">40</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">41</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">42</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">43</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">44</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">45</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">46</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">47</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">48</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">49</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">50</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">51</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">52</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">53</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">54</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">55</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">56</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">57</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">58</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">59</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">60</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">61</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">62</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">63</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">64</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">65</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">66</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">67</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">68</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">69</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">70</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">71</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">72</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">73</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">74</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">75</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">76</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">77</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">78</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">79</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">80</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">81</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">82</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">83</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">84</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">85</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">86</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">87</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">88</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">89</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">90</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">91</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">92</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">93</span></div><div style="line-height: 1.2;"><span style="font-size: 14px;">94</span></div></div></td><td style="padding-top: 6px; padding-bottom: 6px;"><div style="margin: 0px; padding: 0px; line-height: 1.2;"><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#include</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">iostream</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#include</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">vector</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#include</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">algorithm</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#include</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">queue</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(86, 156, 214); font-size: 14px;">using</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">namespace</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">std</span><span style="font-size: 14px;">;&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#define</span><span style="font-size: 14px;">&nbsp;RC_MX&nbsp;</span><span style="font-size: 14px;">50</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">1</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#define</span><span style="font-size: 14px;">&nbsp;SIDE&nbsp;</span><span style="font-size: 14px;">4</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(78, 201, 176); font-size: 14px;">#pragma</span><span style="font-size: 14px;">&nbsp;warning(disable:</span><span style="font-size: 14px;">4996</span><span style="font-size: 14px;">)</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;main()&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">char</span><span style="font-size: 14px;">&nbsp;map[RC_MX][RC_MX]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;{&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;};</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;goseum_depth[RC_MX][RC_MX];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;water_depth[RC_MX][RC_MX];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;side_arr[SIDE][</span><span style="font-size: 14px;">2</span><span style="font-size: 14px;">]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;{&nbsp;{</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">,</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">},{</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">,</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">},{</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">,</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">},{</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">,</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">}&nbsp;};</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">queue</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">pair</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">,&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="font-size: 14px;">&nbsp;goseum_queue,&nbsp;water_queue;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;R,&nbsp;C;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">scanf</span><span style="font-size: 14px;">(</span><span style="color: rgb(227, 162, 92); font-size: 14px;">"%d&nbsp;%d"</span><span style="font-size: 14px;">,&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="font-size: 14px;">R,&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="font-size: 14px;">C);</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;goseum_size&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">,&nbsp;water_size&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;input을&nbsp;처리한다.&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">for</span><span style="font-size: 14px;">&nbsp;(</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;&nbsp;row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;R;&nbsp;row</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">)</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">for</span><span style="font-size: 14px;">&nbsp;(</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;&nbsp;col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;C;&nbsp;col</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">){</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_depth[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;water_depth[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">scanf</span><span style="font-size: 14px;">(</span><span style="color: rgb(227, 162, 92); font-size: 14px;">"&nbsp;%c"</span><span style="font-size: 14px;">,&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="font-size: 14px;">map[row][col]);</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'S'</span><span style="font-size: 14px;">)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_queue.push({&nbsp;row&nbsp;,&nbsp;col&nbsp;});</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_size</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_depth[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">else</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'*'</span><span style="font-size: 14px;">)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_queue.push({&nbsp;row&nbsp;,&nbsp;col&nbsp;});</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_size</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_depth[row][col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;물&nbsp;먼저</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;depth&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">while</span><span style="font-size: 14px;">&nbsp;(goseum_size)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;물&nbsp;갱신&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">while</span><span style="font-size: 14px;">&nbsp;(water_size)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_size</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">pair</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">,&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="font-size: 14px;">&nbsp;this_water&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;water_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">front</span><span style="font-size: 14px;">();&nbsp;water_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">pop</span><span style="font-size: 14px;">();</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">for</span><span style="font-size: 14px;">&nbsp;(</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;side_idx&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;&nbsp;side_idx&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;SIDE;&nbsp;side_idx</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;this_water.first&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">&nbsp;side_arr[side_idx][</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;this_water.second&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">&nbsp;side_arr[side_idx][</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;인덱스&nbsp;체크</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="font-size: 14px;">&nbsp;new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;R)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="font-size: 14px;">&nbsp;new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;C)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'X'</span><span style="font-size: 14px;">)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;돌체크&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'D'</span><span style="font-size: 14px;">)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;비버체크</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(water_depth[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;이전단계&nbsp;물&nbsp;체크&nbsp;&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_depth[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;depth;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_queue.push({&nbsp;new_row,&nbsp;new_col&nbsp;});</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;고슴&nbsp;도치&nbsp;갱신</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">while</span><span style="font-size: 14px;">(goseum_size){</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_size</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">-</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">pair</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">,&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="font-size: 14px;">&nbsp;this_goseum&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;goseum_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">front</span><span style="font-size: 14px;">();&nbsp;goseum_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">pop</span><span style="font-size: 14px;">();</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;이전&nbsp;단계에서&nbsp;물이&nbsp;넘친&nbsp;구역이라면&nbsp;그냥&nbsp;넘긴다.&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;water_depth[this_goseum.first][this_goseum.second]</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="font-size: 14px;">&nbsp;water_depth[this_goseum.first][this_goseum.second]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;depth)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">for</span><span style="font-size: 14px;">&nbsp;(</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;side_idx&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;&nbsp;side_idx&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;SIDE;&nbsp;side_idx</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;this_goseum.first&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">&nbsp;side_arr[side_idx][</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">int</span><span style="font-size: 14px;">&nbsp;new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;this_goseum.second&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">&nbsp;side_arr[side_idx][</span><span style="font-size: 14px;">1</span><span style="font-size: 14px;">];</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;인덱스&nbsp;체크</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="font-size: 14px;">&nbsp;new_row&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;R)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">|</span><span style="font-size: 14px;">&nbsp;new_col&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;C)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'X'</span><span style="font-size: 14px;">)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;돌체크&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;water_depth[new_row][new_col]</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&amp;</span><span style="font-size: 14px;">&nbsp;water_depth[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&lt;</span><span style="font-size: 14px;">&nbsp;depth)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;이전단계&nbsp;물&nbsp;체크&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(goseum_depth[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">&gt;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">)&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">continue</span><span style="font-size: 14px;">;&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;이전&nbsp;고슴도치&nbsp;방문&nbsp;여부&nbsp;체크</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(map[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="color: rgb(227, 162, 92); font-size: 14px;">'D'</span><span style="font-size: 14px;">)&nbsp;{&nbsp;</span><span style="color: rgb(87, 166, 74); font-size: 14px;">//&nbsp;정답이면&nbsp;종료</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">printf</span><span style="font-size: 14px;">(</span><span style="color: rgb(227, 162, 92); font-size: 14px;">"%d"</span><span style="font-size: 14px;">,&nbsp;depth);</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">return</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_depth[new_row][new_col]&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;depth;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_queue.push({&nbsp;new_row,&nbsp;new_col&nbsp;});</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">if</span><span style="font-size: 14px;">&nbsp;(goseum_size&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">)&nbsp;{</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goseum_size&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;goseum_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">size</span><span style="font-size: 14px;">();&nbsp;&nbsp;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;water_size&nbsp;</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">=</span><span style="font-size: 14px;">&nbsp;water_queue.</span><span style="color: rgb(220, 220, 220); font-size: 14px;">size</span><span style="font-size: 14px;">();</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;depth</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="color:#FF3399"></span><span style="color: rgb(86, 156, 214); font-size: 14px;">+</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;}</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(220, 220, 220); font-size: 14px;">printf</span><span style="font-size: 14px;">(</span><span style="color: rgb(227, 162, 92); font-size: 14px;">"KAKTUS"</span><span style="font-size: 14px;">);</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(86, 156, 214); font-size: 14px;">return</span><span style="font-size: 14px;">&nbsp;</span><span style="font-size: 14px;">0</span><span style="font-size: 14px;">;</span></div><div style="padding: 0px 6px; white-space: pre; line-height: 1.2;"><span style="font-size: 14px;">}</span></div></div><div style="text-align: right; margin-top: -13px; margin-right: 5px; font-size: 9px; font-style: italic; line-height: 1.2;"><a href="http://colorscripter.com/info#e" target="_blank" style="color: rgb(79, 79, 79);">Colored by Color Scripter</a></div></td><td style="vertical-align: bottom; padding-right: 2px; padding-bottom: 4px;"><a href="http://colorscripter.com/info#e" target="_blank" style="color: white;"><span style="font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;">cs</span></a></td></tr></tbody></table></div>
You can’t perform that action at this time.