﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Pockel</title><link>http://www.cppblog.com/pockel/</link><description /><language>zh-cn</language><lastBuildDate>Mon, 20 Apr 2026 13:37:58 GMT</lastBuildDate><pubDate>Mon, 20 Apr 2026 13:37:58 GMT</pubDate><ttl>60</ttl><item><title>PKU1088题解</title><link>http://www.cppblog.com/pockel/archive/2007/08/23/30677.html</link><dc:creator>刘超</dc:creator><author>刘超</author><pubDate>Thu, 23 Aug 2007 07:30:00 GMT</pubDate><guid>http://www.cppblog.com/pockel/archive/2007/08/23/30677.html</guid><wfw:comment>http://www.cppblog.com/pockel/comments/30677.html</wfw:comment><comments>http://www.cppblog.com/pockel/archive/2007/08/23/30677.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/pockel/comments/commentRss/30677.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/pockel/services/trackbacks/30677.html</trackback:ping><description><![CDATA[
		<p align="center"> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">滑雪 <br /></span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Time Limit:1000MS  Memory Limit:65536K<br /></span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Total Submit:</span>
				<span style="COLOR: #000000">11034</span>
				<span style="COLOR: #000000"> Accepted:</span>
				<span style="COLOR: #000000">3437</span>
				<span style="COLOR: #000000"> <br /></span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Description<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Michael 喜欢滑雪百这并不奇怪， 因为滑雪的确很刺激。可是为了获得速度，滑的区域必须向下倾斜，而且当你滑到坡底，你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个 区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 <br /></span>
				<span style="COLOR: #008080"> 7</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 8</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /> <br /></span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Input<br /></span>
				<span style="COLOR: #008080">12</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />输入的第一行表示区域的行数R和列数C(</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&lt;=</span>
				<span style="COLOR: #000000"> R,C </span>
				<span style="COLOR: #000000">&lt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">)。下面是R行，每行有C个整数，代表高度h，</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">&lt;=</span>
				<span style="COLOR: #000000">h</span>
				<span style="COLOR: #000000">&lt;=</span>
				<span style="COLOR: #000000">10000</span>
				<span style="COLOR: #000000">。<br /></span>
				<span style="COLOR: #008080">13</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Output<br /></span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />输出最长区域的长度。<br /></span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Sample Input<br /></span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">20</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #000000">3</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">21</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">16</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">17</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">18</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">19</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">6</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">22</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">15</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">24</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">20</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">7</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">23</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">14</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">23</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">22</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">21</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">8</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">24</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">12</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">11</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">25</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">26</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />Sample Output<br /></span>
				<span style="COLOR: #008080">27</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080">28</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p align="left">
				<font style="BACKGROUND-COLOR: #ffffff">
						<font color="#cc00ff">
								<font size="2">这道题目非常的好，解题方法也很多，可以用DP，也可以用记忆化搜索，当然还可以暴力破解，不过常规的DP就<br />足以解决问题了，所以我用了常规的DP来解这道题目<br />动规方程可以写为path[x][y] = MAX{path[x-1][y], path[x+1][y], path[x][y+1], path[x][y-1]}<br />如果先按排序再递推的话复杂度会相对小一些</font>
								<br />
						</font>
				</font>
				<br />
		</p>
		<p align="left">
		</p>
		<p align="left">
		</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008080"> 1</span>
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">#include</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdio.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 2</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #0000ff">string</span>
				<span style="COLOR: #000000">.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 3</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> MAX 100</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008080"> 4</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080"> 5</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">struct</span>
				<span style="COLOR: #000000"> point<br /></span>
				<span style="COLOR: #008080"> 6</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_67_86_Open_Image" onclick="this.style.display='none'; Codehighlighter1_67_86_Open_Text.style.display='none'; Codehighlighter1_67_86_Closed_Image.style.display='inline'; Codehighlighter1_67_86_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_67_86_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_67_86_Closed_Text.style.display='none'; Codehighlighter1_67_86_Open_Image.style.display='inline'; Codehighlighter1_67_86_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_67_86_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_67_86_Open_Text">
						<span style="COLOR: #000000">{<br /></span>
						<span style="COLOR: #008080"> 7</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> x,y,height;<br /></span>
						<span style="COLOR: #008080"> 8</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">points[MAX</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">MAX];<br /></span>
				<span style="COLOR: #008080"> 9</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">10</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> cmp(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">a, </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">b)<br /></span>
				<span style="COLOR: #008080">11</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_143_213_Open_Image" onclick="this.style.display='none'; Codehighlighter1_143_213_Open_Text.style.display='none'; Codehighlighter1_143_213_Closed_Image.style.display='inline'; Codehighlighter1_143_213_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_143_213_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_143_213_Closed_Text.style.display='none'; Codehighlighter1_143_213_Open_Image.style.display='inline'; Codehighlighter1_143_213_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_143_213_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_143_213_Open_Text">
						<span style="COLOR: #000000">{   <br /></span>
						<span style="COLOR: #008080">12</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> (</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #0000ff">struct</span>
						<span style="COLOR: #000000"> point</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">)a).height </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000"> (</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #0000ff">struct</span>
						<span style="COLOR: #000000"> point</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">)b).height;<br /></span>
						<span style="COLOR: #008080">13</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> path[MAX][MAX];<br /></span>
				<span style="COLOR: #008080">14</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">15</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> hills[MAX][MAX];<br /></span>
				<span style="COLOR: #008080">16</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_284_311_Open_Image" onclick="this.style.display='none'; Codehighlighter1_284_311_Open_Text.style.display='none'; Codehighlighter1_284_311_Closed_Image.style.display='inline'; Codehighlighter1_284_311_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_284_311_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_284_311_Closed_Text.style.display='none'; Codehighlighter1_284_311_Open_Image.style.display='inline'; Codehighlighter1_284_311_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> direction[</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span id="Codehighlighter1_284_311_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_284_311_Open_Text">
						<span style="COLOR: #000000">{ </span>
						<span id="Codehighlighter1_286_290_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_286_290_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">,</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">,</span>
						<span id="Codehighlighter1_292_297_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_292_297_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">,</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">,</span>
						<span id="Codehighlighter1_299_303_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_299_303_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">,</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">,</span>
						<span id="Codehighlighter1_305_310_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_305_310_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">,</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">}</span>
				</span>
				<span style="COLOR: #000000">;<br /></span>
				<span style="COLOR: #008080">17</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
				</span>
				<span style="COLOR: #008080">18</span>
				<span style="COLOR: #000000">
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> main()<br /></span>
				<span style="COLOR: #008080">19</span>
				<span style="COLOR: #000000">
						<img id="Codehighlighter1_326_1124_Open_Image" onclick="this.style.display='none'; Codehighlighter1_326_1124_Open_Text.style.display='none'; Codehighlighter1_326_1124_Closed_Image.style.display='inline'; Codehighlighter1_326_1124_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_326_1124_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_326_1124_Closed_Text.style.display='none'; Codehighlighter1_326_1124_Open_Image.style.display='inline'; Codehighlighter1_326_1124_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span id="Codehighlighter1_326_1124_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_326_1124_Open_Text">
						<span style="COLOR: #000000">{        <br /></span>
						<span style="COLOR: #008080">20</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> r, c, i, j, k, ans, x, y;<br /></span>
						<span style="COLOR: #008080">21</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    scanf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d%d</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">r, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">c);<br /></span>
						<span style="COLOR: #008080">22</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    k </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">23</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (i </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; i </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000"> r; </span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">i)<br /></span>
						<span style="COLOR: #008080">24</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (j </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; j </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000"> c; </span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">j)<br /></span>
						<span style="COLOR: #008080">25</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_446_557_Open_Image" onclick="this.style.display='none'; Codehighlighter1_446_557_Open_Text.style.display='none'; Codehighlighter1_446_557_Closed_Image.style.display='inline'; Codehighlighter1_446_557_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_446_557_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_446_557_Closed_Text.style.display='none'; Codehighlighter1_446_557_Open_Image.style.display='inline'; Codehighlighter1_446_557_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_446_557_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_446_557_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">26</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            scanf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">%d</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">hills[i][j]);<br /></span>
								<span style="COLOR: #008080">27</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            points[k].x </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> i;<br /></span>
								<span style="COLOR: #008080">28</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            points[k].y </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> j;<br /></span>
								<span style="COLOR: #008080">29</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            points[k</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">].height </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> hills[i][j];<br /></span>
								<span style="COLOR: #008080">30</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">31</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /></span>
						<span style="COLOR: #008080">32</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        qsort(points, k, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(</span>
						<span style="COLOR: #0000ff">struct</span>
						<span style="COLOR: #000000"> point), cmp);<br /></span>
						<span style="COLOR: #008080">33</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
						</span>
						<span style="COLOR: #008080">34</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (i </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">r; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /></span>
						<span style="COLOR: #008080">35</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (j </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; j </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">c;j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /></span>
						<span style="COLOR: #008080">36</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                path[i][j] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;    ans </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">37</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            <br /></span>
						<span style="COLOR: #008080">38</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (i</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">k; </span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">i)<br /></span>
						<span style="COLOR: #008080">39</span>
						<span style="COLOR: #000000">
								<img id="Codehighlighter1_718_1083_Open_Image" onclick="this.style.display='none'; Codehighlighter1_718_1083_Open_Text.style.display='none'; Codehighlighter1_718_1083_Closed_Image.style.display='inline'; Codehighlighter1_718_1083_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_718_1083_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_718_1083_Closed_Text.style.display='none'; Codehighlighter1_718_1083_Open_Image.style.display='inline'; Codehighlighter1_718_1083_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
						<span id="Codehighlighter1_718_1083_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_718_1083_Open_Text">
								<span style="COLOR: #000000">{<br /></span>
								<span style="COLOR: #008080">40</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (j</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;j</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">4</span>
								<span style="COLOR: #000000">;</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">j)<br /></span>
								<span style="COLOR: #008080">41</span>
								<span style="COLOR: #000000">
										<img id="Codehighlighter1_746_992_Open_Image" onclick="this.style.display='none'; Codehighlighter1_746_992_Open_Text.style.display='none'; Codehighlighter1_746_992_Closed_Image.style.display='inline'; Codehighlighter1_746_992_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_746_992_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_746_992_Closed_Text.style.display='none'; Codehighlighter1_746_992_Open_Image.style.display='inline'; Codehighlighter1_746_992_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
								<span id="Codehighlighter1_746_992_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.cppblog.com/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_746_992_Open_Text">
										<span style="COLOR: #000000">{<br /></span>
										<span style="COLOR: #008080">42</span>
										<span style="COLOR: #000000">
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    x</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">points[i].x</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">direction[j][</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">];<br /></span>
										<span style="COLOR: #008080">43</span>
										<span style="COLOR: #000000">
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    y</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">points[i].y</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">direction[j][</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">];<br /></span>
										<span style="COLOR: #008080">44</span>
										<span style="COLOR: #000000">
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (x</span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">x</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">r</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">y</span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">y</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">c</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">hills[x][y]</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">points[i].height</span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000">path[points[i].x][points[i].y]</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">path[x][y])<br /></span>
										<span style="COLOR: #008080">45</span>
										<span style="COLOR: #000000">
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        path[points[i].x][points[i].y]</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">path[x][y]</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /></span>
										<span style="COLOR: #008080">46</span>
										<span style="COLOR: #000000">
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
								</span>
								<span style="COLOR: #008080">47</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (ans</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">path[points[i].x][points[i].y])<br /></span>
								<span style="COLOR: #008080">48</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    ans</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">path[points[i].x][points[i].y];<br /></span>
								<span style="COLOR: #008080">49</span>
								<span style="COLOR: #000000">
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #008080">50</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">,ans</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">);<br /></span>
						<span style="COLOR: #008080">51</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /></span>
						<span style="COLOR: #008080">52</span>
						<span style="COLOR: #000000">
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
		<p align="left">
				<br />
		</p>
<img src ="http://www.cppblog.com/pockel/aggbug/30677.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/pockel/" target="_blank">刘超</a> 2007-08-23 15:30 <a href="http://www.cppblog.com/pockel/archive/2007/08/23/30677.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PKU1001 题解</title><link>http://www.cppblog.com/pockel/archive/2007/08/23/30669.html</link><dc:creator>刘超</dc:creator><author>刘超</author><pubDate>Thu, 23 Aug 2007 05:15:00 GMT</pubDate><guid>http://www.cppblog.com/pockel/archive/2007/08/23/30669.html</guid><wfw:comment>http://www.cppblog.com/pockel/comments/30669.html</wfw:comment><comments>http://www.cppblog.com/pockel/archive/2007/08/23/30669.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/pockel/comments/commentRss/30669.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/pockel/services/trackbacks/30669.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Exponentiation 																				Time						 Limit:500MS  Memory Limit:10000KTotal Submit:						22256						 Accepted:						5036						 DescriptionProblems involving the computation of ...&nbsp;&nbsp;<a href='http://www.cppblog.com/pockel/archive/2007/08/23/30669.html'>阅读全文</a><img src ="http://www.cppblog.com/pockel/aggbug/30669.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/pockel/" target="_blank">刘超</a> 2007-08-23 13:15 <a href="http://www.cppblog.com/pockel/archive/2007/08/23/30669.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>