<div class="colorscripter-code" style="color:rgb(1,1,1);overflow:auto;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;"> <table class="colorscripter-code-table" style="margin:0px;padding:0px;border:;background-color:rgb(250,250,250);" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:6px;border-right-color:rgb(229,229,229);border-right-width:2px;border-right-style:solid;"> <div style="margin:0px;padding:0px;text-align:right;color:rgb(102,102,102);line-height:130%;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;"> <div style="line-height:130%;">1</div> <div style="line-height:130%;">2</div> <div style="line-height:130%;">3</div> <div style="line-height:130%;">4</div> <div style="line-height:130%;">5</div> <div style="line-height:130%;">6</div> <div style="line-height:130%;">7</div> <div style="line-height:130%;">8</div> <div style="line-height:130%;">9</div> <div style="line-height:130%;">10</div> <div style="line-height:130%;">11</div> <div style="line-height:130%;">12</div> <div style="line-height:130%;">13</div> <div style="line-height:130%;">14</div> <div style="line-height:130%;">15</div> <div style="line-height:130%;">16</div> <div style="line-height:130%;">17</div> <div style="line-height:130%;">18</div> <div style="line-height:130%;">19</div> <div style="line-height:130%;">20</div> <div style="line-height:130%;">21</div> <div style="line-height:130%;">22</div> <div style="line-height:130%;">23</div> <div style="line-height:130%;">24</div> <div style="line-height:130%;">25</div> <div style="line-height:130%;">26</div> <div style="line-height:130%;">27</div> <div style="line-height:130%;">28</div> <div style="line-height:130%;">29</div> <div style="line-height:130%;">30</div> <div style="line-height:130%;">31</div> <div style="line-height:130%;">32</div> <div style="line-height:130%;">33</div> <div style="line-height:130%;">34</div> <div style="line-height:130%;">35</div> <div style="line-height:130%;">36</div> <div style="line-height:130%;">37</div> <div style="line-height:130%;">38</div> <div style="line-height:130%;">39</div> <div style="line-height:130%;">40</div></div></td> <td style="padding:6px 0px;"> <div style="margin:0px;padding:0px;color:rgb(1,1,1);line-height:130%;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;"> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(0,134,179);">#include</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span>vector<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span></div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(0,134,179);">#include</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span>algorithm<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span></div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(0,134,179);">#include</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span>functional<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span></div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(0,134,179);">#include</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span>iostream<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span></div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(0,134,179);">#include</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span>map<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span></div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(167,29,93);">using</span> <span style="color:rgb(167,29,93);">namespace</span> <span style="color:rgb(6,109,226);">std</span>;</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(167,29,93);">class</span> FilipTheFrog{</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(167,29,93);">public</span>:</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(6,109,226);">int</span> countReachableIslands(vector<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(6,109,226);">int</span><span style="color:rgb(167,29,93);">></span> positions, <span style="color:rgb(6,109,226);">int</span> L){</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> map<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(6,109,226);">int</span>, <span style="color:rgb(6,109,226);">int</span><span style="color:rgb(167,29,93);">></span> reachable;</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> reachable[<span style="color:rgb(0,153,204);">0</span>] <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> positions[<span style="color:rgb(0,153,204);">0</span>];</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">for</span> (map<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(6,109,226);">int</span>, <span style="color:rgb(6,109,226);">int</span><span style="color:rgb(167,29,93);">></span>::iterator map_iter <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> reachable.begin(); map_iter <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">!</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> reachable.end(); map_iter<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">+</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">+</span>)</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> {</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">for</span> (<span style="color:rgb(167,29,93);">unsigned</span> <span style="color:rgb(6,109,226);">int</span> i <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> <span style="color:rgb(0,153,204);">0</span>; i <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span> positions.size(); i<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">+</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">+</span>)</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> {</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">if</span> (abs(map_iter<span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">-</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">></span>second <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">-</span> positions[i]) <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> L)</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> {</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">if</span> (reachable.find(positions[i]) <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> reachable.end())</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> {</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> reachable[reachable.size()] <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> positions[i];</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> }</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> }</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> }</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> }</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">return</span> reachable.size();</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> }</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;">};</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"><span style="color:rgb(6,109,226);">int</span> main(){</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> FilipTheFrog result_class;</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(6,109,226);">int</span> result <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);">=</span> result_class.countReachableIslands({ <span style="color:rgb(0,153,204);">4</span>, <span style="color:rgb(0,153,204);">7</span>, <span style="color:rgb(0,153,204);">1</span>, <span style="color:rgb(0,153,204);">3</span>, <span style="color:rgb(0,153,204);">5</span> }, <span style="color:rgb(0,153,204);">1</span>);</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> </div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(6,109,226);">cout</span> <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span> result <span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span><span style="color:rgb(1,1,1);"></span><span style="color:rgb(167,29,93);"><</span> endl;</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:rgb(167,29,93);">return</span> <span style="color:rgb(0,153,204);">0</span>;</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;">}</div></div> <div style="text-align:right;font-size:9px;font-style:italic;margin-top:-13px;margin-right:5px;"><a style="color:rgb(229,229,229);text-decoration:none;" href="http://colorscripter.com/info#e" target="_blank">Colored by Color Scripter</a></div></td> <td style="padding:0px 2px 4px 0px;vertical-align:bottom;"><a style="color:#FFFFFF;text-decoration:none;" href="http://colorscripter.com/info#e" target="_blank"><span style="padding:1px;color:#FFFFFF;font-size:9px;background-color:rgb(229,229,229);">cs</span></a></td></tr></tbody></table></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.