﻿<?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++博客-&amp;豪-文章分类-ACM题目</title><link>http://www.cppblog.com/qywyh/category/1629.html</link><description>豪-&gt;blog</description><language>zh-cn</language><lastBuildDate>Mon, 19 May 2008 14:36:20 GMT</lastBuildDate><pubDate>Mon, 19 May 2008 14:36:20 GMT</pubDate><ttl>60</ttl><item><title>pku3311</title><link>http://www.cppblog.com/qywyh/articles/29328.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Fri, 03 Aug 2007 14:57:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/29328.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/29328.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/29328.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/29328.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/29328.html</trackback:ping><description><![CDATA[<p align=center><font color=blue size=5></p>
<p align=center>Hie with the Pie</font> <br>Time Limit:2000MS&nbsp; Memory Limit:65536K<br>Total Submit:501 Accepted:183 </p>
<p><font color=blue size=5>Description</font><br><font face="Times New Roman" size=3>
<p>The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait for 1 or more (up to 10) orders to be processed before he starts any deliveries. Needless to say, he would like to take the shortest route in delivering these goodies and returning to the pizzeria, even if it means passing the same location(s) or the pizzeria more than once on the way. He has commissioned you to write a program to help him.</p>
</font>
<p>&#160;</p>
<p><font color=blue size=5>Input</font><br><font face="Times New Roman" size=3>
<p>Input will consist of multiple test cases. The first line will contain a single integer <em>n</em> indicating the number of orders to deliver, where 1 &#8804; <em>n</em> &#8804; 10. After this will be <em>n</em> + 1 lines each containing <em>n</em> + 1 integers indicating the times to travel between the pizzeria (numbered 0) and the <em>n</em> locations (numbers 1 to <em>n</em>). The <em>j</em>th value on the <em>i</em>th line indicates the time to go directly from location <em>i</em> to location <em>j</em> without visiting any other locations along the way. Note that there may be quicker ways to go from <em>i</em> to <em>j</em> via other locations, due to different speed limits, traffic lights, etc. Also, the time values may not be symmetric, i.e., the time to go directly from location <em>i</em> to <em>j</em> may not be the same as the time to go directly from location <em>j</em> to <em>i</em>. An input value of <em>n</em> = 0 will terminate input.</p>
</font>
<p>&#160;</p>
<p><font color=blue size=5>Output</font><br><font face="Times New Roman" size=3>
<p>For each test case, you should output a single number indicating the minimum time to deliver all of the pizzas and return to the pizzeria.</p>
</font>
<p>&#160;</p>
<p><font color=blue size=5>Sample Input</font><br><font face="Times New Roman" size=3>
<pre>3
0 1 10 10
1 0 1 2
10 1 0 10
10 2 10 0
0</pre>
</font>
<p>&#160;</p>
<p><font color=blue size=5>Sample Output</font><br><font face="Times New Roman" size=3>
<pre>8</pre>
</font>
<p>&#160;</p>
<p><font color=blue size=5>Source</font><br><font face="Times New Roman" color=#0000ff size=3><a href="http://acm.pku.edu.cn/JudgeOnline/searchproblem?field=source&amp;key=East Central North America 2006"><u>East Central North America 2006</u></a><br></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" twffan="done"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><span style="COLOR: #000000" twffan="done">#include&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">cstdio</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">#include&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">memory</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">const</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;INF&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;0x7fffffff;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;n,&nbsp;d[</span><span style="COLOR: #000000" twffan="done">12</span><span style="COLOR: #000000" twffan="done">][</span><span style="COLOR: #000000" twffan="done">2100</span><span style="COLOR: #000000" twffan="done">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;g[</span><span style="COLOR: #000000" twffan="done">12</span><span style="COLOR: #000000" twffan="done">][</span><span style="COLOR: #000000" twffan="done">12</span><span style="COLOR: #000000" twffan="done">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">void&nbsp;floyd()&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i,&nbsp;j,&nbsp;k;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(k</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;k</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;k</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(j</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;j</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;j</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(g[i][k]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[k][j]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;(g[i][j]&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;||&nbsp;g[i][k]</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">g[k][j]&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[i][j]))&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g[i][j]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;g[i][k]&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;g[k][j];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">void&nbsp;solve()&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i,&nbsp;j,&nbsp;k,&nbsp;bit,&nbsp;t,&nbsp;tmp,&nbsp;one[</span><span style="COLOR: #000000" twffan="done">15</span><span style="COLOR: #000000" twffan="done">],&nbsp;tmpb,&nbsp;ans&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;INF;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;memset(d,&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">,&nbsp;sizeof(d));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;memset(g,&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">,&nbsp;sizeof(g));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(j</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;j</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;j</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">g[i][j]);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;floyd();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;d[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(j</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;j</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">(n</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">);&nbsp;j</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bit&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;j;&nbsp;tmp&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(k</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;k</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;k</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(bit</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">(</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">k)&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;bit</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one[tmp</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;k;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(tmp&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;i)&nbsp;continue;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(k</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;k</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">tmp;&nbsp;k</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmpb&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;bit</span><span style="COLOR: #000000" twffan="done">^</span><span style="COLOR: #000000" twffan="done">(</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">one[k]);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][tmpb]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][one[k]]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;||&nbsp;d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][one[k]]&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;d[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][tmpb])&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;g[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][one[k]]&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;d[</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">][tmpb];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(t</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;t</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">tmp;&nbsp;t</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(t&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;k)&nbsp;continue;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[one[t]][tmpb]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[one[t]][one[k]]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;||&nbsp;d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[one[t]][one[k]]&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;d[one[t]][tmpb])&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d[one[k]][bit]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;g[one[t]][one[k]]&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;d[one[t]][tmpb];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[i][(</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">n</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;g[i][</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">]&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;ans&nbsp;</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">&nbsp;d[i][(</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">n</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">]</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">g[i][</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">])&nbsp;ans&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;d[i][(</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&lt;&lt;</span><span style="COLOR: #000000" twffan="done">n</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">]</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">g[i][</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d\n</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;ans);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;main()&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">while</span><span style="COLOR: #000000" twffan="done">&nbsp;(scanf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">n)&nbsp;!</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;EOF)&nbsp;{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(n&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">)&nbsp;break;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;solve();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done">}</span></div>
<p><br></font></p>
<img src ="http://www.cppblog.com/qywyh/aggbug/29328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-08-03 22:57 <a href="http://www.cppblog.com/qywyh/articles/29328.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku3268 dij+heap</title><link>http://www.cppblog.com/qywyh/articles/28653.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Mon, 23 Jul 2007 12:51:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/28653.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/28653.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/28653.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/28653.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/28653.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 写了个比较通用的堆，可直接用作优先队列Silver Cow Party Time Limit:2000MS&nbsp; Memory Limit:65536KTotal Submit:1112 Accepted:326 DescriptionOne cow from each of N farms (1 &#8804; N &#8804; 1000) conveniently numb...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/28653.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/28653.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-07-23 20:51 <a href="http://www.cppblog.com/qywyh/articles/28653.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ural 1018(简单的树状dp)</title><link>http://www.cppblog.com/qywyh/articles/22412.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Fri, 20 Apr 2007 12:05:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/22412.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/22412.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/22412.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/22412.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/22412.html</trackback:ping><description><![CDATA[<div align=center twffan="done">
<div class=title twffan="done">1018. A Binary Apple Tree</div>
Time Limit: 1.0 second<br>Memory Limit: 16 MB<br></div>
<p>Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will enumerate by natural numbers the root of binary apple tree, points of branching and the ends of twigs. This way we may distinguish different branches by their ending points. We will assume that root of tree always is numbered by 1 and all numbers used for enumerating are numbered in range from 1 to <em>N</em>, where <em>N</em> is the total number of all enumerated points. For instance in the picture below <em>N</em> is equal to 5. Here is an example of an enumerated tree with four branches:<br>
<pre>   2   5
\ /
3   4
\ /
1
</pre>
As you may know it's not convenient to pick an apples from a tree when there are too much of branches. That's why some of them should be removed from a tree. But you are interested in removing branches in the way of minimal loss of apples. So your are given amounts of apples on a branches and amount of branches that should be preserved. Your task is to determine how many apples can remain on a tree after removing of excessive branches.
<p>&#160;</p>
<h3 class=subtitle>Input</h3>
<p>First line of input contains two numbers: <em>N</em> and <em>Q</em> (1 &#8804; <em>Q</em> &#8804; <em>N</em>, 1 &lt; <em>N</em> &#8804; 100). <em>N</em> denotes the number of enumerated points in a tree. <em>Q</em> denotes amount of branches that should be preserved. Next <em>N</em>-1 lines contains descriptions of branches. Each description consists of a three integer numbers divided by spaces. The first two of them define branch by it's ending points. The third number defines the number of apples on this branch. You may assume that no branch contains more than 30000 apples.</p>
<h3 class=subtitle>Output</h3>
<p>Output file should contain the only number — amount of apples that can be preserved. And don't forget to preserve tree's root ;-)</p>
<h3 class=subtitle>Sample</h3>
<table class=sample>
    <tbody>
        <tr>
            <th>
            <div twffan="done">input</div>
            </th>
            <th>
            <div twffan="done">output</div>
            </th>
        </tr>
        <tr>
            <td>
            <pre>5 2
            1 3 1
            1 4 10
            2 3 20
            3 5 20
            </pre>
            </td>
            <td>
            <pre>21
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<br><strong>Problem Source: </strong>Ural State University Internal Contest '99 #2 <br>
<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" twffan="done"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><span style="COLOR: #000000" twffan="done">#include&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">iostream</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">using</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #0000ff" twffan="done">namespace</span><span style="COLOR: #000000" twffan="done">&nbsp;std;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">const</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;MAXN&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">110</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">const</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;MAXQ&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">110</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;n,&nbsp;q;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;d[MAXN][MAXQ];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;g[MAXN][MAXN],&nbsp;deg[MAXN],&nbsp;nw[MAXN],&nbsp;son[MAXN][</span><span style="COLOR: #000000" twffan="done">2</span><span style="COLOR: #000000" twffan="done">];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;root;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;f[MAXN],&nbsp;isleaf[MAXN];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img id=Codehighlighter1_238_263_Open_Image onclick="this.style.display='none'; Codehighlighter1_238_263_Open_Text.style.display='none'; Codehighlighter1_238_263_Closed_Image.style.display='inline'; Codehighlighter1_238_263_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_238_263_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_238_263_Closed_Text.style.display='none'; Codehighlighter1_238_263_Open_Image.style.display='inline'; Codehighlighter1_238_263_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top twffan="done">inline&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;maxt(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;a,&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;b)&nbsp;</span><span id=Codehighlighter1_238_263_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_238_263_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;a&nbsp;</span><span style="COLOR: #000000" twffan="done">&gt;</span><span style="COLOR: #000000" twffan="done">&nbsp;b&nbsp;</span><span style="COLOR: #000000" twffan="done">?</span><span style="COLOR: #000000" twffan="done">&nbsp;a&nbsp;:&nbsp;b;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top twffan="done">}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img id=Codehighlighter1_282_450_Open_Image onclick="this.style.display='none'; Codehighlighter1_282_450_Open_Text.style.display='none'; Codehighlighter1_282_450_Closed_Image.style.display='inline'; Codehighlighter1_282_450_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_282_450_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_282_450_Closed_Text.style.display='none'; Codehighlighter1_282_450_Open_Image.style.display='inline'; Codehighlighter1_282_450_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">void</span><span style="COLOR: #000000" twffan="done">&nbsp;DFS(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;v)&nbsp;</span><span id=Codehighlighter1_282_450_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_282_450_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i,&nbsp;t&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img id=Codehighlighter1_321_424_Open_Image onclick="this.style.display='none'; Codehighlighter1_321_424_Open_Text.style.display='none'; Codehighlighter1_321_424_Closed_Image.style.display='inline'; Codehighlighter1_321_424_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_321_424_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_321_424_Closed_Text.style.display='none'; Codehighlighter1_321_424_Open_Image.style.display='inline'; Codehighlighter1_321_424_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span id=Codehighlighter1_321_424_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_321_424_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img id=Codehighlighter1_353_421_Open_Image onclick="this.style.display='none'; Codehighlighter1_353_421_Open_Text.style.display='none'; Codehighlighter1_353_421_Closed_Image.style.display='inline'; Codehighlighter1_353_421_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_353_421_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_353_421_Closed_Text.style.display='none'; Codehighlighter1_353_421_Open_Image.style.display='inline'; Codehighlighter1_353_421_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(g[v][i]&nbsp;</span><span style="COLOR: #000000" twffan="done">!=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;&amp;</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">!</span><span style="COLOR: #000000" twffan="done">f[i])&nbsp;</span><span id=Codehighlighter1_353_421_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_353_421_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;son[v][t</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;i;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f[i]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nw[i]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;g[v][i];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DFS(i);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(</span><span style="COLOR: #000000" twffan="done">!</span><span style="COLOR: #000000" twffan="done">t)&nbsp;isleaf[v]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top twffan="done">}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img id=Codehighlighter1_467_592_Open_Image onclick="this.style.display='none'; Codehighlighter1_467_592_Open_Text.style.display='none'; Codehighlighter1_467_592_Closed_Image.style.display='inline'; Codehighlighter1_467_592_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_467_592_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_467_592_Closed_Text.style.display='none'; Codehighlighter1_467_592_Open_Image.style.display='inline'; Codehighlighter1_467_592_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">void</span><span style="COLOR: #000000" twffan="done">&nbsp;buildT()&nbsp;</span><span id=Codehighlighter1_467_592_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_467_592_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i;<br><img id=Codehighlighter1_499_550_Open_Image onclick="this.style.display='none'; Codehighlighter1_499_550_Open_Text.style.display='none'; Codehighlighter1_499_550_Closed_Image.style.display='inline'; Codehighlighter1_499_550_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_499_550_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_499_550_Closed_Text.style.display='none'; Codehighlighter1_499_550_Open_Image.style.display='inline'; Codehighlighter1_499_550_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">n;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span id=Codehighlighter1_499_550_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_499_550_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img id=Codehighlighter1_520_547_Open_Image onclick="this.style.display='none'; Codehighlighter1_520_547_Open_Text.style.display='none'; Codehighlighter1_520_547_Closed_Image.style.display='inline'; Codehighlighter1_520_547_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_520_547_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_520_547_Closed_Text.style.display='none'; Codehighlighter1_520_547_Open_Image.style.display='inline'; Codehighlighter1_520_547_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(deg[i]&nbsp;</span><span style="COLOR: #000000" twffan="done">==</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">2</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span id=Codehighlighter1_520_547_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_520_547_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;i;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">break</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;f[root]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;nw[root]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;DFS(root);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top twffan="done">}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img id=Codehighlighter1_618_867_Open_Image onclick="this.style.display='none'; Codehighlighter1_618_867_Open_Text.style.display='none'; Codehighlighter1_618_867_Closed_Image.style.display='inline'; Codehighlighter1_618_867_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_618_867_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_618_867_Closed_Text.style.display='none'; Codehighlighter1_618_867_Open_Image.style.display='inline'; Codehighlighter1_618_867_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;DP(</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;ti,&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;tl)&nbsp;</span><span id=Codehighlighter1_618_867_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_618_867_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(tl&nbsp;</span><span style="COLOR: #000000" twffan="done">&lt;=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(d[ti][tl]&nbsp;</span><span style="COLOR: #000000" twffan="done">!=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;d[ti][tl];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">if</span><span style="COLOR: #000000" twffan="done">&nbsp;(isleaf[ti])&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;nw[ti];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;k,&nbsp;tmp&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img id=Codehighlighter1_755_819_Open_Image onclick="this.style.display='none'; Codehighlighter1_755_819_Open_Text.style.display='none'; Codehighlighter1_755_819_Closed_Image.style.display='inline'; Codehighlighter1_755_819_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_755_819_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_755_819_Closed_Text.style.display='none'; Codehighlighter1_755_819_Open_Image.style.display='inline'; Codehighlighter1_755_819_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(k</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;k</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">tl;&nbsp;k</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span id=Codehighlighter1_755_819_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_755_819_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmp&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;maxt(tmp,&nbsp;DP(son[ti][</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">],&nbsp;k)</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">DP(son[ti][</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">],&nbsp;tl</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">k));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;d[ti][tl]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;tmp&nbsp;</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">&nbsp;nw[ti];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;d[ti][tl];<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top twffan="done">}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top twffan="done"><br><img id=Codehighlighter1_881_1147_Open_Image onclick="this.style.display='none'; Codehighlighter1_881_1147_Open_Text.style.display='none'; Codehighlighter1_881_1147_Closed_Image.style.display='inline'; Codehighlighter1_881_1147_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_881_1147_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_881_1147_Closed_Text.style.display='none'; Codehighlighter1_881_1147_Open_Image.style.display='inline'; Codehighlighter1_881_1147_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top twffan="done"></span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;main()&nbsp;</span><span id=Codehighlighter1_881_1147_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_881_1147_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">int</span><span style="COLOR: #000000" twffan="done">&nbsp;i,&nbsp;j,&nbsp;k,&nbsp;x,&nbsp;y,&nbsp;w;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d%d</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">n,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">q);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;memset(g,&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #0000ff" twffan="done">sizeof</span><span style="COLOR: #000000" twffan="done">(g));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;memset(d,&nbsp;</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #0000ff" twffan="done">sizeof</span><span style="COLOR: #000000" twffan="done">(d));<br><img id=Codehighlighter1_1007_1089_Open_Image onclick="this.style.display='none'; Codehighlighter1_1007_1089_Open_Text.style.display='none'; Codehighlighter1_1007_1089_Closed_Image.style.display='inline'; Codehighlighter1_1007_1089_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top twffan="done"><img id=Codehighlighter1_1007_1089_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1007_1089_Closed_Text.style.display='none'; Codehighlighter1_1007_1089_Open_Image.style.display='inline'; Codehighlighter1_1007_1089_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">for</span><span style="COLOR: #000000" twffan="done">&nbsp;(i</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">&lt;</span><span style="COLOR: #000000" twffan="done">n</span><span style="COLOR: #000000" twffan="done">-</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">;&nbsp;i</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">)&nbsp;</span><span id=Codehighlighter1_1007_1089_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" twffan="done"><img src="http://www.cppblog.com/Images/dot.gif" twffan="done"></span><span id=Codehighlighter1_1007_1089_Open_Text twffan="done"><span style="COLOR: #000000" twffan="done">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d%d%d</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">x,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">y,&nbsp;</span><span style="COLOR: #000000" twffan="done">&amp;</span><span style="COLOR: #000000" twffan="done">w);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g[x][y]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;g[y][x]&nbsp;</span><span style="COLOR: #000000" twffan="done">=</span><span style="COLOR: #000000" twffan="done">&nbsp;w;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deg[x]</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">,&nbsp;deg[y]</span><span style="COLOR: #000000" twffan="done">++</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000" twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;buildT();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">%d\n</span><span style="COLOR: #000000" twffan="done">"</span><span style="COLOR: #000000" twffan="done">,&nbsp;DP(root,&nbsp;q</span><span style="COLOR: #000000" twffan="done">+</span><span style="COLOR: #000000" twffan="done">1</span><span style="COLOR: #000000" twffan="done">));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top twffan="done">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff" twffan="done">return</span><span style="COLOR: #000000" twffan="done">&nbsp;</span><span style="COLOR: #000000" twffan="done">0</span><span style="COLOR: #000000" twffan="done">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top twffan="done">}</span></span></div>
<br>
<img src ="http://www.cppblog.com/qywyh/aggbug/22412.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-04-20 20:05 <a href="http://www.cppblog.com/qywyh/articles/22412.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>挺难的状态DP pku 1038</title><link>http://www.cppblog.com/qywyh/articles/22199.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 18 Apr 2007 03:42:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/22199.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/22199.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/22199.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/22199.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/22199.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Bugs Integrated, Inc. Time Limit:15000MS&nbsp; Memory Limit:30000KTotal Submit:1180 Accepted:309 Case Time Limit:5000MS DescriptionBugs Integrated, Inc. is a major manufacturer of advanced memory ch...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/22199.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/22199.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-04-18 11:42 <a href="http://www.cppblog.com/qywyh/articles/22199.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku2904 3维dp</title><link>http://www.cppblog.com/qywyh/articles/20583.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sun, 25 Mar 2007 16:41:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/20583.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/20583.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/20583.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/20583.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/20583.html</trackback:ping><description><![CDATA[开始时候粗心，状态转移时候k写成k-1了，查了n久.<br /><br /><p align="center"><font color="blue" size="5">The Mailboxes Manufacturers Problem</font><br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:299 Accepted:227 </p><p><font color="blue" size="5">Description</font><br /><font face="Times New Roman" size="3"><span lang="en-us" twffan="done"><p>In the good old days when Swedish children were still allowed to blowup their fingers with fire-crackers, gangs of excited kids would plague certain smaller cities during Easter time, with only one thing in mind: To blow things up. Small boxes were easy to blow up, and thus mailboxes became a popular target. Now, a small mailbox manufacturer is interested in how many fire-crackers his new mailbox prototype can withstand without exploding and has hired you to help him. He will provide you with <i>k</i> (1 ≤ <i>k</i> ≤ 10) identical mailbox prototypes each fitting up to <i>m</i> (1 ≤ <i>m</i> ≤ 100) crackers. However, he is not sure of how many firecrackers he needs to provide you with in order for you to be able to solve his problem, so he asks you. You think for a while and then say, “Well,if I blow up a mailbox I can’t use it again, so if you would provide me with only <i>k</i> = 1 mailboxes, I would have to start testing with 1 cracker, then 2 crackers, and so on until it finally exploded. In the worst case, that is if it does not blow up even when filled with m crackers, I would need 1 + 2 + 3 + … + <i>m</i> = <i>m</i> × (<i>m</i> + 1) ⁄ 2 crackers. If <i>m</i> = 100 that would mean more than 5000 fire-crackers!” “That’s too many,” he replies. “What if I give you more than <i>k</i> = 1 mailboxes? Can you find a strategy that requires less crackers?”</p><p>Can you? And what is the minimum number of crackers that you should ask him to provide you with?</p><p>You may assume the following:</p><ol><li>If a mailbox can withstand <i>x</i> fire-crackers, it can also withstand <i>x</i> − 1 fire-crackers. 
</li><li>Upon an explosion, a mailbox is either totally destroyed (blown up) or unharmed, which means that it can be reused in another test explosion.</li></ol><p>Note: If the mailbox can withstand a full load of <i>m</i> fire-crackers, then the manufacturer will of course be satisfied with that answer. But otherwise he is looking for the maximum number of crackers that his mailboxes can withstand.</p></span></font></p><p></p><p><font color="blue" size="5">Input</font><br /><font face="Times New Roman" size="3"><span lang="en-us" twffan="done"><p>The input starts with a single integer <i>N</i> (1 ≤ <i>N</i> ≤ 10) indicating the number of test cases to follow. Each test case is described by a line containing two integers: <i>k</i> and <i>m</i>, separated by a single space.</p></span></font></p><p></p><p><font color="blue" size="5">Output</font><br /><font face="Times New Roman" size="3"><p>For each test case print one line with a single integer indicating the minimum number of fire-crackers that is needed, in the worst case, in order to figure out how many crackers the mailbox prototype can withstand.</p></font></p><p></p><p><font color="blue" size="5">Sample Input</font><br /><font face="Times New Roman" size="3"><pre>4
1 10
1 100
3 73
5 100</pre></font></p><p></p><p><font color="blue" size="5">Sample Output</font><br /><font face="Times New Roman" size="3"><pre>55
5050
382
495</pre></font></p><p></p><p><font color="blue" size="5">Source</font><br /><font face="Times New Roman" size="3">Svenskt Mästerskap i Programmering/Norgesmesterskapet 2002<br /></font></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"><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">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />using namespace std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span><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">&lt;&lt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">28</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> d[</span><span style="COLOR: #000000">11</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">101</span><span style="COLOR: #000000">][</span><span style="COLOR: #000000">101</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sum(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> ret </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">i; k</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">j; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) ret </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    return ret;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> max(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> b) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    return a </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> b ? a : b;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> caseTime; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i, j, k, t, K, M, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">caseTime);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (caseTime</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">K, </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">M);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">M; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">i; j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">M; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                d[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> sum(i, j);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />            }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />        }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">; k</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">K; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (l</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; l</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">M; l</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">l</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">M; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    j </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (i </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> j) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        d[k][i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        continue;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    d[k][i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (t</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">i; t</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">j; t</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> i) tmp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> d[k][i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (t </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> j) tmp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> d[k</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][i][j</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> tmp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> max(d[k</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][i][t</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">], d[k</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][t</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        tmp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> max(d[k</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][i][t</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">], d[k][t</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (d[k][i][j] </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> tmp) d[k][i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                    }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />                }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />            }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />        }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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">, d[K][</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][M]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />    return </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />}</span></div><img src ="http://www.cppblog.com/qywyh/aggbug/20583.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-03-26 00:41 <a href="http://www.cppblog.com/qywyh/articles/20583.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku 2486 树状dp</title><link>http://www.cppblog.com/qywyh/articles/18618.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sat, 10 Feb 2007 10:55:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/18618.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/18618.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/18618.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/18618.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/18618.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Apple Tree</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:541 Accepted:148 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amount of apples. Wshxzt starts her happy trip at one node. She can eat up all the apples in the nodes she reaches. HX is a kind guy. He knows that eating too many can make the lovely girl become fat. So he doesn’t allow Wshxzt to go more than K steps in the tree. It costs one step when she goes from one node to another adjacent node. Wshxzt likes apple very much. So she wants to eat as many as she can. Can you tell how many apples she can eat in at most K steps.</font>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">There are several test cases in the input <br />Each test case contains three parts. <br />The first part is two numbers N K, whose meanings we have talked about just now. We denote the nodes by 1 2 ... N. Since it is a tree, each node can reach any other in only one route. (1&lt;=N&lt;=100, 0&lt;=K&lt;=200) <br />The second part contains N integers (All integers are nonnegative and not bigger than 1000). The ith number is the amount of apples in Node i. <br />The third part contains N-1 line. There are two numbers A,B in each line, meaning that Node A and Node B are adjacent. <br />Input will be ended by the end of file. <br /><br />Note: Wshxzt starts at Node 1.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">For each test case, output the maximal numbers of apples Wshxzt can eat at a line.</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>2 1 
0 11
1 2
3 2
0 1 2
1 2
1 3
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>11
2
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">POJ Contest,Author:magicpig@ZSU<br /><br /><br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />using namespace std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> N </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">210</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> adj[N][N];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n, k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> w[N];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> go[N][N], bk[N][N];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> dfs(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> dp(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">);<br /><img id="Codehighlighter1_204_229_Open_Image" onclick="this.style.display='none'; Codehighlighter1_204_229_Open_Text.style.display='none'; Codehighlighter1_204_229_Closed_Image.style.display='inline'; Codehighlighter1_204_229_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_204_229_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_204_229_Closed_Text.style.display='none'; Codehighlighter1_204_229_Open_Image.style.display='inline'; Codehighlighter1_204_229_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />inline </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> max(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b) </span>
				<span id="Codehighlighter1_204_229_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_204_229_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> a </span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> b </span>
						<span style="COLOR: #000000">?</span>
						<span style="COLOR: #000000"> a : b;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_243_310_Open_Image" onclick="this.style.display='none'; Codehighlighter1_243_310_Open_Text.style.display='none'; Codehighlighter1_243_310_Closed_Image.style.display='inline'; Codehighlighter1_243_310_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_243_310_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_243_310_Closed_Text.style.display='none'; Codehighlighter1_243_310_Open_Image.style.display='inline'; Codehighlighter1_243_310_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_243_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_243_310_Open_Text">
						<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_283_297_Open_Image" onclick="this.style.display='none'; Codehighlighter1_283_297_Open_Text.style.display='none'; Codehighlighter1_283_297_Closed_Image.style.display='inline'; Codehighlighter1_283_297_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_283_297_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_283_297_Closed_Text.style.display='none'; Codehighlighter1_283_297_Open_Image.style.display='inline'; Codehighlighter1_283_297_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (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">n, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">k) </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> EOF) </span>
						<span id="Codehighlighter1_283_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_283_297_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img id="Codehighlighter1_326_666_Open_Image" onclick="this.style.display='none'; Codehighlighter1_326_666_Open_Text.style.display='none'; Codehighlighter1_326_666_Closed_Image.style.display='inline'; Codehighlighter1_326_666_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_326_666_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_326_666_Closed_Text.style.display='none'; Codehighlighter1_326_666_Open_Image.style.display='inline'; Codehighlighter1_326_666_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> solve() </span>
				<span id="Codehighlighter1_326_666_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_666_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, l;<br /><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;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img id="Codehighlighter1_376_418_Open_Image" onclick="this.style.display='none'; Codehighlighter1_376_418_Open_Text.style.display='none'; Codehighlighter1_376_418_Closed_Image.style.display='inline'; Codehighlighter1_376_418_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_376_418_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_376_418_Closed_Text.style.display='none'; Codehighlighter1_376_418_Open_Image.style.display='inline'; Codehighlighter1_376_418_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_376_418_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_376_418_Open_Text">
								<span style="COLOR: #000000">{<br /><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">w[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        adj[i][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img id="Codehighlighter1_444_526_Open_Image" onclick="this.style.display='none'; Codehighlighter1_444_526_Open_Text.style.display='none'; Codehighlighter1_444_526_Closed_Image.style.display='inline'; Codehighlighter1_444_526_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_444_526_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_444_526_Closed_Text.style.display='none'; Codehighlighter1_444_526_Open_Image.style.display='inline'; Codehighlighter1_444_526_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">n</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_444_526_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_444_526_Open_Text">
								<span style="COLOR: #000000">{<br /><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">x, </span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">y);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        adj[x][</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">adj[x][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">]] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> y;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        adj[y][</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">adj[y][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">]] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(go, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, sizeof(go));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(bk, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, sizeof(bk));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    dfs(</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> ans </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> max(go[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][k], bk[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][k]);<br /><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"> w[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img id="Codehighlighter1_693_989_Open_Image" onclick="this.style.display='none'; Codehighlighter1_693_989_Open_Text.style.display='none'; Codehighlighter1_693_989_Closed_Image.style.display='inline'; Codehighlighter1_693_989_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_693_989_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_693_989_Closed_Text.style.display='none'; Codehighlighter1_693_989_Open_Image.style.display='inline'; Codehighlighter1_693_989_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> dfs(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> p, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> pp) </span>
				<span id="Codehighlighter1_693_989_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_693_989_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> ts;    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img id="Codehighlighter1_750_987_Open_Image" onclick="this.style.display='none'; Codehighlighter1_750_987_Open_Text.style.display='none'; Codehighlighter1_750_987_Closed_Image.style.display='inline'; Codehighlighter1_750_987_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_750_987_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_750_987_Closed_Text.style.display='none'; Codehighlighter1_750_987_Open_Image.style.display='inline'; Codehighlighter1_750_987_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">adj[p][</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">]; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_750_987_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_750_987_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        ts </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> adj[p][i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (ts </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> pp) </span>
								<span style="COLOR: #0000ff">continue</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        dfs(ts, p);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        bk[ts][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        bk[ts][</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        go[ts][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (l</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">k; l</span>
								<span style="COLOR: #000000">&gt;=</span>
								<span style="COLOR: #000000">2</span>
								<span style="COLOR: #000000">; l</span>
								<span style="COLOR: #000000">--</span>
								<span style="COLOR: #000000">) bk[ts][l] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> bk[ts][l</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"> w[ts];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (l</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">k; l</span>
								<span style="COLOR: #000000">&gt;=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">; l</span>
								<span style="COLOR: #000000">--</span>
								<span style="COLOR: #000000">) go[ts][l] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> go[ts][l</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> w[ts];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        dp(p, ts);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img id="Codehighlighter1_1014_1397_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1014_1397_Open_Text.style.display='none'; Codehighlighter1_1014_1397_Closed_Image.style.display='inline'; Codehighlighter1_1014_1397_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
						<img id="Codehighlighter1_1014_1397_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1014_1397_Closed_Text.style.display='none'; Codehighlighter1_1014_1397_Open_Image.style.display='inline'; Codehighlighter1_1014_1397_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> dp(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> x, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> y) </span>
				<span id="Codehighlighter1_1014_1397_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_1014_1397_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t1[N], t2[N];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(t1, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, sizeof(t1));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(t2, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, sizeof(t2));<br /><img id="Codehighlighter1_1127_1229_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1127_1229_Open_Text.style.display='none'; Codehighlighter1_1127_1229_Closed_Image.style.display='inline'; Codehighlighter1_1127_1229_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1127_1229_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1127_1229_Closed_Text.style.display='none'; Codehighlighter1_1127_1229_Open_Image.style.display='inline'; Codehighlighter1_1127_1229_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_1127_1229_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_1127_1229_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_1152_1226_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1152_1226_Open_Text.style.display='none'; Codehighlighter1_1152_1226_Closed_Image.style.display='inline'; Codehighlighter1_1152_1226_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1152_1226_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1152_1226_Closed_Text.style.display='none'; Codehighlighter1_1152_1226_Open_Image.style.display='inline'; Codehighlighter1_1152_1226_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">i; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_1152_1226_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_1152_1226_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            t1[i] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> max(t1[i], max(bk[x][j]</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">go[y][i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">j], bk[y][j]</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">go[x][i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">j]));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1253_1329_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1253_1329_Open_Text.style.display='none'; Codehighlighter1_1253_1329_Closed_Image.style.display='inline'; Codehighlighter1_1253_1329_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1253_1329_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1253_1329_Closed_Text.style.display='none'; Codehighlighter1_1253_1329_Open_Image.style.display='inline'; Codehighlighter1_1253_1329_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_1253_1329_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_1253_1329_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_1278_1326_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1278_1326_Open_Text.style.display='none'; Codehighlighter1_1278_1326_Closed_Image.style.display='inline'; Codehighlighter1_1278_1326_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1278_1326_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1278_1326_Closed_Text.style.display='none'; Codehighlighter1_1278_1326_Open_Image.style.display='inline'; Codehighlighter1_1278_1326_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">i; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_1278_1326_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_1278_1326_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            t2[i] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> max(t2[i], bk[x][j]</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">bk[y][i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1352_1395_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1352_1395_Open_Text.style.display='none'; Codehighlighter1_1352_1395_Closed_Image.style.display='inline'; Codehighlighter1_1352_1395_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1352_1395_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1352_1395_Closed_Text.style.display='none'; Codehighlighter1_1352_1395_Open_Image.style.display='inline'; Codehighlighter1_1352_1395_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_1352_1395_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_1352_1395_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        bk[x][i] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> t2[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        go[x][i] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> t1[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/18618.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2007-02-10 18:55 <a href="http://www.cppblog.com/qywyh/articles/18618.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku1717 标号法(DP)</title><link>http://www.cppblog.com/qywyh/articles/14347.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sun, 29 Oct 2006 12:42:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/14347.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/14347.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/14347.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/14347.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/14347.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Dominoes</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:1022 Accepted:333 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">A domino is a flat, thumbsized tile, the face of which is divided into two squares, each left blank or bearing from one to six dots. There is a row of dominoes laid out on a table: <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/1717_1.jpg" twffan="done" /></center><br />The number of dots in the top line is 6+1+1+1=9 and the number of dots in the bottom line is 1+5+3+2=11. The gap between the top line and the bottom line is 2. The gap is the absolute value of difference between two sums. <br /><br />Each domino can be turned by 180 degrees keeping its face always upwards. <br /><br />What is the smallest number of turns needed to minimise the gap between the top line and the bottom line? <br /><br />For the figure above it is sufficient to turn the last domino in the row in order to decrease the gap to 0. In this case the answer is 1. <br />Write a program that: computes the smallest number of turns needed to minimise the gap between the top line and the bottom line.</font>
				<font face="宋体, MS Song">
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">The first line of the input contains an integer n, 1 &lt;= n &lt;= 1000. This is the number of dominoes laid out on the table. <br /><br />Each of the next n lines contains two integers a, b separated by a single space, 0 &lt;= a, b &lt;= 6. The integers a and b written in the line i + 1 of the input file, 1 &lt;= i &lt;= 1000, are the numbers of dots on the i-th domino in the row, respectively, in the top line and in the bottom one. <br /></font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">Output the smallest number of turns needed to minimise the gap between the top line and the bottom line. </font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>4
6 1
1 5
1 3
1 2
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>1
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">CEOI 1997<br /><br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">8000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<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">&lt;&lt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">28</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_103_146_Open_Image" onclick="this.style.display='none'; Codehighlighter1_103_146_Open_Text.style.display='none'; Codehighlighter1_103_146_Closed_Image.style.display='inline'; Codehighlighter1_103_146_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_103_146_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_103_146_Closed_Text.style.display='none'; Codehighlighter1_103_146_Open_Image.style.display='inline'; Codehighlighter1_103_146_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span style="COLOR: #0000ff">struct</span>
				<span style="COLOR: #000000"> DATA </span>
				<span id="Codehighlighter1_103_146_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_103_146_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> da[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> dx;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> q;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />DATA dp[</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">bool</span>
				<span style="COLOR: #000000"> f[</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> queue[MAXN], front, rear;<br /><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 /><img id="Codehighlighter1_224_1687_Open_Image" onclick="this.style.display='none'; Codehighlighter1_224_1687_Open_Text.style.display='none'; Codehighlighter1_224_1687_Closed_Image.style.display='inline'; Codehighlighter1_224_1687_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_224_1687_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_224_1687_Closed_Text.style.display='none'; Codehighlighter1_224_1687_Open_Image.style.display='inline'; Codehighlighter1_224_1687_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_224_1687_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_224_1687_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> a[MAXN], x, y;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, k, w, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> d </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> ans </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> INF;<br /><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">n);<br /><img id="Codehighlighter1_362_440_Open_Image" onclick="this.style.display='none'; Codehighlighter1_362_440_Open_Text.style.display='none'; Codehighlighter1_362_440_Closed_Image.style.display='inline'; Codehighlighter1_362_440_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_362_440_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_362_440_Closed_Text.style.display='none'; Codehighlighter1_362_440_Open_Image.style.display='inline'; Codehighlighter1_362_440_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_362_440_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_362_440_Open_Text">
								<span style="COLOR: #000000">{<br /><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">x, </span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">y);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        a[i] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> x </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000"> y;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        d </span>
								<span style="COLOR: #000000">+=</span>
								<span style="COLOR: #000000"> a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(f, </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(f));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    dp[d</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">7500</span>
						<span style="COLOR: #000000">].dx </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> d; dp[d</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">7500</span>
						<span style="COLOR: #000000">].q </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; f[d</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">7500</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">;<br /><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">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) dp[d</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">7500</span>
						<span style="COLOR: #000000">].da[i] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    front </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; rear </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; w </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_622_1280_Open_Image" onclick="this.style.display='none'; Codehighlighter1_622_1280_Open_Text.style.display='none'; Codehighlighter1_622_1280_Closed_Image.style.display='inline'; Codehighlighter1_622_1280_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_622_1280_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_622_1280_Closed_Text.style.display='none'; Codehighlighter1_622_1280_Open_Image.style.display='inline'; Codehighlighter1_622_1280_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">do</span>
						<span style="COLOR: #000000"> </span>
						<span id="Codehighlighter1_622_1280_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_622_1280_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_652_1220_Open_Image" onclick="this.style.display='none'; Codehighlighter1_652_1220_Open_Text.style.display='none'; Codehighlighter1_652_1220_Closed_Image.style.display='inline'; Codehighlighter1_652_1220_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_652_1220_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_652_1220_Closed_Text.style.display='none'; Codehighlighter1_652_1220_Open_Image.style.display='inline'; Codehighlighter1_652_1220_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_652_1220_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_652_1220_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            j </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> dp[d</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">7500</span>
										<span style="COLOR: #000000">].da[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            k </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> d  </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> j </span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">2</span>
										<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_768_1210_Open_Image" onclick="this.style.display='none'; Codehighlighter1_768_1210_Open_Text.style.display='none'; Codehighlighter1_768_1210_Closed_Image.style.display='inline'; Codehighlighter1_768_1210_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_768_1210_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_768_1210_Closed_Text.style.display='none'; Codehighlighter1_768_1210_Open_Image.style.display='inline'; Codehighlighter1_768_1210_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (</span>
										<span style="COLOR: #000000">!</span>
										<span style="COLOR: #000000">f[k</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">7500</span>
										<span style="COLOR: #000000">] </span>
										<span style="COLOR: #000000">||</span>
										<span style="COLOR: #000000"> dp[k</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">7500</span>
										<span style="COLOR: #000000">].q </span>
										<span style="COLOR: #000000">&gt;</span>
										<span style="COLOR: #000000"> w </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">) </span>
										<span id="Codehighlighter1_768_1210_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_768_1210_Open_Text">
												<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_798_927_Open_Image" onclick="this.style.display='none'; Codehighlighter1_798_927_Open_Text.style.display='none'; Codehighlighter1_798_927_Closed_Image.style.display='inline'; Codehighlighter1_798_927_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_798_927_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_798_927_Closed_Text.style.display='none'; Codehighlighter1_798_927_Open_Image.style.display='inline'; Codehighlighter1_798_927_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (k </span>
												<span style="COLOR: #000000">==</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">0</span>
												<span style="COLOR: #000000">) </span>
												<span id="Codehighlighter1_798_927_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_798_927_Open_Text">
														<span style="COLOR: #000000">{<br /><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">, w </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> </span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    system(</span>
														<span style="COLOR: #000000">"</span>
														<span style="COLOR: #000000">pause</span>
														<span style="COLOR: #000000">"</span>
														<span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                f[k</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">true</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                queue[rear</span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[k</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].dx </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[k</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].q </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> w </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">for</span>
												<span style="COLOR: #000000"> (l</span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000">0</span>
												<span style="COLOR: #000000">; l</span>
												<span style="COLOR: #000000">&lt;</span>
												<span style="COLOR: #000000">n; l</span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">) dp[k</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].da[l] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> dp[d</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].da[l];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[k</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].da[i] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">dp[d</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">7500</span>
												<span style="COLOR: #000000">].da[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        d </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> queue[front</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        w </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> dp[d</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">7500</span>
								<span style="COLOR: #000000">].q;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (front </span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000"> rear);  <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    j </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">7500</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">bool</span>
						<span style="COLOR: #000000"> isFind </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_1373_1624_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1373_1624_Open_Text.style.display='none'; Codehighlighter1_1373_1624_Closed_Image.style.display='inline'; Codehighlighter1_1373_1624_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1373_1624_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1373_1624_Closed_Text.style.display='none'; Codehighlighter1_1373_1624_Open_Image.style.display='inline'; Codehighlighter1_1373_1624_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">7500</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_1373_1624_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_1373_1624_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_1395_1482_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1395_1482_Open_Text.style.display='none'; Codehighlighter1_1395_1482_Closed_Image.style.display='inline'; Codehighlighter1_1395_1482_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1395_1482_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1395_1482_Closed_Text.style.display='none'; Codehighlighter1_1395_1482_Open_Image.style.display='inline'; Codehighlighter1_1395_1482_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (f[j</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">i]) </span>
								<span id="Codehighlighter1_1395_1482_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_1395_1482_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            isFind </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><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">&gt;</span>
										<span style="COLOR: #000000"> dp[j</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">i].q) ans </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> dp[j</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">i].q;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img id="Codehighlighter1_1504_1591_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1504_1591_Open_Text.style.display='none'; Codehighlighter1_1504_1591_Closed_Image.style.display='inline'; Codehighlighter1_1504_1591_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_1504_1591_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1504_1591_Closed_Text.style.display='none'; Codehighlighter1_1504_1591_Open_Image.style.display='inline'; Codehighlighter1_1504_1591_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (f[j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">i]) </span>
								<span id="Codehighlighter1_1504_1591_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_1504_1591_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            isFind </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><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">&gt;</span>
										<span style="COLOR: #000000"> dp[j</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i].q) ans </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> dp[j</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i].q;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (isFind) </span>
								<span style="COLOR: #0000ff">break</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">pause</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/14347.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-29 20:42 <a href="http://www.cppblog.com/qywyh/articles/14347.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>状态压缩DP, pku3020</title><link>http://www.cppblog.com/qywyh/articles/13822.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 18 Oct 2006 09:29:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13822.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13822.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13822.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13822.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13822.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Antenna PlacementTime Limit:1000MS  Memory Limit:65536KTotal Submit:380 Accepted:125 						Description								The Global Aerial Research Centre has been allotted the task of building the fifth...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/13822.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/13822.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-18 17:29 <a href="http://www.cppblog.com/qywyh/articles/13822.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>zju1250(dp, 是dp都记下, 便于复习)</title><link>http://www.cppblog.com/qywyh/articles/13587.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 11 Oct 2006 16:41:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13587.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13587.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13587.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13587.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13587.html</trackback:ping><description><![CDATA[
		<font color="blue" size="+2">
				<div align="center">
						<br />Always On the Run</div>
		</font>
		<hr />
		<center>
				<font color="green">Time limit:</font> 1 Seconds   <font color="green">Memory limit: </font>32768K   <br /><font color="green">Total Submit:</font> 125   <font color="green">Accepted Submit:</font> 70   </center>
		<hr />
Screeching tires. Searching lights. Wailing sirens. Police cars everywhere. Trisha Quickfinger did it again! Stealing the `Mona Lisa' had been more difficult than planned, but being the world's best art thief means expecting the unexpected. So here she is, the wrapped frame tucked firmly under her arm, running to catch the northbound metro to Charles-de-Gaulle airport. 
<p>But even more important than actually stealing the painting is to shake off the police that will soon be following her. Trisha's plan is simple: for several days she will be flying from one city to another, making one flight per day. When she is reasonably sure that the police has lost her trail, she will fly to Atlanta and meet her `customer' (known only as Mr. P.) to deliver the painting. </p><p>Her plan is complicated by the fact that nowadays, even when you are stealing expensive art, you have to watch your spending budget. Trisha therefore wants to spend the least money possible on her escape flights. This is not easy, since airlines prices and flight availability vary from day to day. The price and availability of an airline connection depends on the two cities involved and the day of travel. Every pair of cities has a `flight schedule' which repeats every few days. The length of the period may be different for each pair of cities and for each direction. </p><p>Although Trisha is a good at stealing paintings, she easily gets confused when booking airline flights. This is where you come in. </p><p><br /><b>Input </b><br /><br />The input contains the descriptions of several scenarios in which Trisha tries to escape. Every description starts with a line containing two integers n and k. n is the number of cities through which Trisha's escape may take her, and k is the number of flights she will take. The cities are numbered 1, 2, ..., n, where 1 is Paris, her starting point, and n is Atlanta, her final destination. The numbers will satisfy 2 &lt;= n &lt;= 10 and 1 &lt;= k &lt;= 1000. <br />Next you are given n(n - 1) flight schedules, one per line, describing the connection between every possible pair of cities. The first n - 1 flight schedules correspond to the flights from city 1 to all other cities (2, 3, ..., n), the next n - 1 lines to those from city 2 to all others (1, 3, 4, ..., n), and so on. </p><p>The description of the flight schedule itself starts with an integer d, the length of the period in days, with 1 &lt;= d &lt;= 30. Following this are d non-negative integers, representing the cost of the flight between the two cities on days 1, 2, ..., d. A cost of 0 means that there is no flight between the two cities on that day. </p><p>So, for example, the flight schedule ``3 75 0 80'' means that on the first day the flight costs 75, on the second day there is no flight, on the third day it costs 80, and then the cycle repeats: on the fourth day the flight costs 75, there is no flight on the fifth day, etc. </p><p>The input is terminated by a scenario having n = k = 0. </p><p><br /><b>Output </b><br /><br />For each scenario in the input, first output the number of the scenario, as shown in the sample output. If it is possible for Trisha to travel k days, starting in city 1, each day flying to a different city than the day before, and finally (after k days) arriving in city n, then print ``The best flight costs x.'', where x is the least amount that the k flights can cost. <br /><br />If it is not possible to travel in such a way, print ``No flight possible.''. </p><p>Print a blank line after each scenario. </p><p><br /><b>Sample Input </b><br /><br />3 6<br />2 130 150<br />3 75 0 80<br />7 120 110 0 100 110 120 0<br />4 60 70 60 50<br />3 0 135 140<br />2 70 80<br />2 3<br />2 0 70<br />1 80<br />0 0</p><p><br /><b>Sample Output </b><br /><br />Scenario #1<br />The best flight costs 460.</p><p>Scenario #2<br />No flight possible.<br /></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"><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">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">11</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXM </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">2000000000</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n, m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a[MAXN][MAXN][MAXM];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> d[MAXM][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><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 /><img id="Codehighlighter1_203_1641_Open_Image" onclick="this.style.display='none'; Codehighlighter1_203_1641_Open_Text.style.display='none'; Codehighlighter1_203_1641_Closed_Image.style.display='inline'; Codehighlighter1_203_1641_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_203_1641_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_203_1641_Closed_Text.style.display='none'; Codehighlighter1_203_1641_Open_Image.style.display='inline'; Codehighlighter1_203_1641_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_203_1641_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_203_1641_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i, j, k, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> t, t1;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> tmp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img id="Codehighlighter1_298_1604_Open_Image" onclick="this.style.display='none'; Codehighlighter1_298_1604_Open_Text.style.display='none'; Codehighlighter1_298_1604_Closed_Image.style.display='inline'; Codehighlighter1_298_1604_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_298_1604_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_298_1604_Closed_Text.style.display='none'; Codehighlighter1_298_1604_Open_Image.style.display='inline'; Codehighlighter1_298_1604_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (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">n, </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">m) </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> EOF) </span><span id="Codehighlighter1_298_1604_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_298_1604_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (n </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000"> m </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        memset(a, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(a));<br /><img id="Codehighlighter1_399_674_Open_Image" onclick="this.style.display='none'; Codehighlighter1_399_674_Open_Text.style.display='none'; Codehighlighter1_399_674_Closed_Image.style.display='inline'; Codehighlighter1_399_674_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_399_674_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_399_674_Closed_Text.style.display='none'; Codehighlighter1_399_674_Open_Image.style.display='inline'; Codehighlighter1_399_674_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_399_674_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_399_674_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_434_664_Open_Image" onclick="this.style.display='none'; Codehighlighter1_434_664_Open_Text.style.display='none'; Codehighlighter1_434_664_Closed_Image.style.display='inline'; Codehighlighter1_434_664_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_434_664_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_434_664_Closed_Text.style.display='none'; Codehighlighter1_434_664_Open_Image.style.display='inline'; Codehighlighter1_434_664_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_434_664_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_434_664_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_464_650_Open_Image" onclick="this.style.display='none'; Codehighlighter1_464_650_Open_Text.style.display='none'; Codehighlighter1_464_650_Closed_Image.style.display='inline'; Codehighlighter1_464_650_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_464_650_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_464_650_Closed_Text.style.display='none'; Codehighlighter1_464_650_Open_Image.style.display='inline'; Codehighlighter1_464_650_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (i </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> j) </span><span id="Codehighlighter1_464_650_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_464_650_Open_Text"><span style="COLOR: #000000">{<br /><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">num[i][j]);<br /><img id="Codehighlighter1_560_632_Open_Image" onclick="this.style.display='none'; Codehighlighter1_560_632_Open_Text.style.display='none'; Codehighlighter1_560_632_Closed_Image.style.display='inline'; Codehighlighter1_560_632_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_560_632_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_560_632_Closed_Text.style.display='none'; Codehighlighter1_560_632_Open_Image.style.display='inline'; Codehighlighter1_560_632_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; k</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">num[i][j]; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_560_632_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_560_632_Open_Text"><span style="COLOR: #000000">{<br /><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">a[i][j][k]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img id="Codehighlighter1_705_795_Open_Image" onclick="this.style.display='none'; Codehighlighter1_705_795_Open_Text.style.display='none'; Codehighlighter1_705_795_Closed_Image.style.display='inline'; Codehighlighter1_705_795_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_705_795_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_705_795_Closed_Text.style.display='none'; Codehighlighter1_705_795_Open_Image.style.display='inline'; Codehighlighter1_705_795_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">m; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_705_795_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_705_795_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_740_785_Open_Image" onclick="this.style.display='none'; Codehighlighter1_740_785_Open_Text.style.display='none'; Codehighlighter1_740_785_Closed_Image.style.display='inline'; Codehighlighter1_740_785_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_740_785_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_740_785_Closed_Text.style.display='none'; Codehighlighter1_740_785_Open_Image.style.display='inline'; Codehighlighter1_740_785_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_740_785_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_740_785_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                d[i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img id="Codehighlighter1_826_922_Open_Image" onclick="this.style.display='none'; Codehighlighter1_826_922_Open_Text.style.display='none'; Codehighlighter1_826_922_Closed_Image.style.display='inline'; Codehighlighter1_826_922_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_826_922_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_826_922_Closed_Text.style.display='none'; Codehighlighter1_826_922_Open_Image.style.display='inline'; Codehighlighter1_826_922_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_826_922_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_826_922_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_860_912_Open_Image" onclick="this.style.display='none'; Codehighlighter1_860_912_Open_Text.style.display='none'; Codehighlighter1_860_912_Closed_Image.style.display='inline'; Codehighlighter1_860_912_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_860_912_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_860_912_Closed_Text.style.display='none'; Codehighlighter1_860_912_Open_Image.style.display='inline'; Codehighlighter1_860_912_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (a[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j][</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_860_912_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_860_912_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                d[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> a[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][j][</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img id="Codehighlighter1_953_1386_Open_Image" onclick="this.style.display='none'; Codehighlighter1_953_1386_Open_Text.style.display='none'; Codehighlighter1_953_1386_Closed_Image.style.display='inline'; Codehighlighter1_953_1386_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_953_1386_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_953_1386_Closed_Text.style.display='none'; Codehighlighter1_953_1386_Open_Image.style.display='inline'; Codehighlighter1_953_1386_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">2</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">m; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_953_1386_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_953_1386_Open_Text"><span style="COLOR: #000000">{<br /><img id="Codehighlighter1_988_1376_Open_Image" onclick="this.style.display='none'; Codehighlighter1_988_1376_Open_Text.style.display='none'; Codehighlighter1_988_1376_Closed_Image.style.display='inline'; Codehighlighter1_988_1376_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_988_1376_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_988_1376_Closed_Text.style.display='none'; Codehighlighter1_988_1376_Open_Image.style.display='inline'; Codehighlighter1_988_1376_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_988_1376_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_988_1376_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                t </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> INF;<br /><img id="Codehighlighter1_1052_1333_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1052_1333_Open_Text.style.display='none'; Codehighlighter1_1052_1333_Closed_Image.style.display='inline'; Codehighlighter1_1052_1333_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1052_1333_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1052_1333_Closed_Text.style.display='none'; Codehighlighter1_1052_1333_Open_Image.style.display='inline'; Codehighlighter1_1052_1333_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (k</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; k</span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000">n; k</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span id="Codehighlighter1_1052_1333_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_1052_1333_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (k </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> j) </span><span style="COLOR: #0000ff">continue</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    t1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> num[k][j] </span><span style="COLOR: #000000">&gt;</span><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"> i </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> num[k][j] : num[k][j];<br /><img id="Codehighlighter1_1240_1315_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1240_1315_Open_Text.style.display='none'; Codehighlighter1_1240_1315_Closed_Image.style.display='inline'; Codehighlighter1_1240_1315_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1240_1315_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1240_1315_Closed_Text.style.display='none'; Codehighlighter1_1240_1315_Open_Image.style.display='inline'; Codehighlighter1_1240_1315_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (a[k][j][t1] </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"> d[i</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][k] </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> a[k][j][t1]) </span><span id="Codehighlighter1_1240_1315_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_1240_1315_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        t </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> d[i</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">][k] </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> a[k][j][t1];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                d[i][j] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Scenario #%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">tmp);<br /><img id="Codehighlighter1_1458_1532_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1458_1532_Open_Text.style.display='none'; Codehighlighter1_1458_1532_Closed_Image.style.display='inline'; Codehighlighter1_1458_1532_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1458_1532_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1458_1532_Closed_Text.style.display='none'; Codehighlighter1_1458_1532_Open_Image.style.display='inline'; Codehighlighter1_1458_1532_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (d[m][n] </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> INF) </span><span id="Codehighlighter1_1458_1532_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_1458_1532_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">The best flight costs %d.\n\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, d[m][n]);<br /><img id="Codehighlighter1_1539_1598_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1539_1598_Open_Text.style.display='none'; Codehighlighter1_1539_1598_Closed_Image.style.display='inline'; Codehighlighter1_1539_1598_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1539_1598_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1539_1598_Closed_Text.style.display='none'; Codehighlighter1_1539_1598_Open_Image.style.display='inline'; Codehighlighter1_1539_1598_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span></span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span id="Codehighlighter1_1539_1598_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_1539_1598_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">No flight possible.\n\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><img src ="http://www.cppblog.com/qywyh/aggbug/13587.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-12 00:41 <a href="http://www.cppblog.com/qywyh/articles/13587.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>zju1721 单源最短路(运用计算几何构图)</title><link>http://www.cppblog.com/qywyh/articles/13474.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sun, 08 Oct 2006 17:05:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13474.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13474.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13474.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13474.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13474.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: BellmanFord实现The DoorsTime limit: 1 Seconds   Memory limit: 32768K   Total Submit: 214   Accepted Submit: 63   You are to find the length of the shortest path through a chamber containing obstructing ...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/13474.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/13474.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-09 01:05 <a href="http://www.cppblog.com/qywyh/articles/13474.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>zju1986 单调上升子序列（nlogn）</title><link>http://www.cppblog.com/qywyh/articles/13339.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 04 Oct 2006 04:20:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13339.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13339.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13339.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13339.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13339.html</trackback:ping><description><![CDATA[
		<p>
		</p>
		<p>解题报告：<a href="http://www.mydrs.org/program/list.asp?id=583"><font color="#800080">http://www.mydrs.org/program/list.asp?id=583</font></a><br /><br /></p>
		<center>
				<font color="blue" size="+2">Bridging Signals</font>
		</center>
		<hr />
		<center>
				<font color="green">Time limit:</font> 1 Seconds   <font color="green">Memory limit: </font>32768K   <br /><font color="green">Total Submit:</font> 946   <font color="green">Accepted Submit:</font> 495   </center>
		<hr />
		<p>'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of two functional blocks cross each other all over the place. At this late stage of the process, it is too expensive to redo the routing. Instead, the engineers have to bridge the signals, using the third dimension, so that no two signals cross. However, bridging is a complicated operation, and thus it is desirable to bridge as few signals as possible. The call for a computer program that finds the maximum number of signals which may be connected on the silicon surface without crossing each other, is imminent. Bearing in mind that there may be thousands of signal ports at the boundary of a functional block, the problem asks quite a lot of the programmer. Are you up to the task? </p>
		<p align="center">
				<img height="246" src="http://acm.zju.edu.cn/showimg.php?pid=1986&amp;file=1986.gif" width="612" twffan="done" />
		</p>
		<p>Figure 1. To the left: The two blocks' ports and their signal mapping (4, 2, 6, 3, 1, 5). To the right: At most three signals may be routed on the silicon surface without crossing each other. The dashed signals must be bridged.</p>
		<p>A typical situation is schematically depicted in figure 1. The ports of the two functional blocks are numbered from 1 to p, from top to bottom. The signal mapping is described by a permutation of the numbers 1 to p in the form of a list of p unique numbers in the range 1 to p, in which the ith number specifies which port on the right side should be connected to the ith port on the left side. Two signals cross if and only if the straight lines connecting the two ports of each pair do.</p>
		<p>
				<br />
				<b>Input</b>
		</p>
		<p>On the first line of the input, there is a single positive integer n, telling the number of test scenarios to follow. Each test scenario begins with a line containing a single positive integer p &lt; 40000, the number of ports on the two functional blocks. Then follow p lines, describing the signal mapping:</p>
		<p>On the ith line is the port number of the block on the right side which should be connected to the ith port of the block on the left side.</p>
		<p>
				<br />
				<b>Output</b>
		</p>
		<p>For each test scenario, output one line containing the maximum number of signals which may be routed on the silicon surface without crossing each other.</p>
		<p>
				<br />
				<b>Sample Input</b>
		</p>
		<p>4<br />6<br />4<br />2<br />6<br />3<br />1<br />5<br />10<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />1<br />8<br />8<br />7<br />6<br />5<br />4<br />3<br />2<br />1<br />9<br />5<br />8<br />9<br />2<br />3<br />1<br />7<br />4<br />6<br /><br /><b>Sample Output</b></p>
		<p>3<br />9<br />1<br />4<br /></p>
		<p>
		</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">
				<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>iostream&gt;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />using</span>
				<span style="COLOR: #000000"> </span>
				<span>namespace std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span>40001;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span>void Solve()<br /><img id="Codehighlighter1_80_556_Open_Image" onclick="this.style.display='none'; Codehighlighter1_80_556_Open_Text.style.display='none'; Codehighlighter1_80_556_Closed_Image.style.display='inline'; Codehighlighter1_80_556_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_80_556_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_80_556_Closed_Text.style.display='none'; Codehighlighter1_80_556_Open_Image.style.display='inline'; Codehighlighter1_80_556_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span>
						<img src="http://www.cppblog.com/images/dot.gif" />
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int i, j, k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int l, r, m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int t;<br /><img id="Codehighlighter1_141_143_Open_Image" onclick="this.style.display='none'; Codehighlighter1_141_143_Open_Text.style.display='none'; Codehighlighter1_141_143_Closed_Image.style.display='inline'; Codehighlighter1_141_143_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_141_143_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_141_143_Closed_Text.style.display='none'; Codehighlighter1_141_143_Open_Image.style.display='inline'; Codehighlighter1_141_143_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> d[MAXN] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span id="Codehighlighter1_141_143_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>
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">}</span>;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int a[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> len </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span>0;<br /><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>&amp;n);<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span>++) <br /><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>&amp;a[i]);<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span>++)<br /><img id="Codehighlighter1_260_529_Open_Image" onclick="this.style.display='none'; Codehighlighter1_260_529_Open_Text.style.display='none'; Codehighlighter1_260_529_Closed_Image.style.display='inline'; Codehighlighter1_260_529_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_260_529_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_260_529_Closed_Text.style.display='none'; Codehighlighter1_260_529_Open_Image.style.display='inline'; Codehighlighter1_260_529_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span>
								<img src="http://www.cppblog.com/images/dot.gif" />
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (a[i] </span>
								<span>&gt; d[len])<br /><img id="Codehighlighter1_285_320_Open_Image" onclick="this.style.display='none'; Codehighlighter1_285_320_Open_Text.style.display='none'; Codehighlighter1_285_320_Closed_Image.style.display='inline'; Codehighlighter1_285_320_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_285_320_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_285_320_Closed_Text.style.display='none'; Codehighlighter1_285_320_Open_Image.style.display='inline'; Codehighlighter1_285_320_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span>
										<img src="http://www.cppblog.com/images/dot.gif" />
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            len </span>
										<span style="COLOR: #000000">+=</span>
										<span style="COLOR: #000000"> </span>
										<span>1;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            d[len] </span>
										<span>= a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000">
										<br />
										<img id="Codehighlighter1_331_526_Open_Image" onclick="this.style.display='none'; Codehighlighter1_331_526_Open_Text.style.display='none'; Codehighlighter1_331_526_Closed_Image.style.display='inline'; Codehighlighter1_331_526_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_331_526_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_331_526_Closed_Text.style.display='none'; Codehighlighter1_331_526_Open_Image.style.display='inline'; Codehighlighter1_331_526_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_331_526_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_331_526_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            l </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span>1;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            r </span>
										<span>= len;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">while</span>
										<span style="COLOR: #000000"> (l </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> r </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> </span>
										<span>1)<br /><img id="Codehighlighter1_379_459_Open_Image" onclick="this.style.display='none'; Codehighlighter1_379_459_Open_Text.style.display='none'; Codehighlighter1_379_459_Closed_Image.style.display='inline'; Codehighlighter1_379_459_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_379_459_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_379_459_Closed_Text.style.display='none'; Codehighlighter1_379_459_Open_Image.style.display='inline'; Codehighlighter1_379_459_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span>
												<img src="http://www.cppblog.com/images/dot.gif" />
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                m </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> (l </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> r) </span>
												<span style="COLOR: #000000">/</span>
												<span style="COLOR: #000000"> </span>
												<span>2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (d[m] </span>
												<span>&lt; a[i])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    l </span>
												<span>= m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                else<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    r </span>
												<span>= m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span>
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            if</span>
										<span> (d[l] &gt; a[i]) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                d[l] </span>
										<span>= a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            else<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                d[r] </span>
										<span>= a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span>
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf("</span>
						<span style="COLOR: #000000">%d\n</span>
						<span>", len);        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span>int main()<br /><img id="Codehighlighter1_571_684_Open_Image" onclick="this.style.display='none'; Codehighlighter1_571_684_Open_Text.style.display='none'; Codehighlighter1_571_684_Closed_Image.style.display='inline'; Codehighlighter1_571_684_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_571_684_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_571_684_Closed_Text.style.display='none'; Codehighlighter1_571_684_Open_Image.style.display='inline'; Codehighlighter1_571_684_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span>
						<img src="http://www.cppblog.com/images/dot.gif" />
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span>int caseTime;<br /><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>&amp;caseTime);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (caseTime</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> </span>
						<span>0)<br /><img id="Codehighlighter1_639_653_Open_Image" onclick="this.style.display='none'; Codehighlighter1_639_653_Open_Text.style.display='none'; Codehighlighter1_639_653_Closed_Image.style.display='inline'; Codehighlighter1_639_653_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_639_653_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_639_653_Closed_Text.style.display='none'; Codehighlighter1_639_653_Open_Image.style.display='inline'; Codehighlighter1_639_653_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span>
								<img src="http://www.cppblog.com/images/dot.gif" />
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        Solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span>
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system("pause</span>
						<span>");<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span> 0;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<p>
				<br />
				<br />
		</p>
		<p>
				<em>
						<br />
						<br />
						<br />
				</em>
		</p>
<img src ="http://www.cppblog.com/qywyh/aggbug/13339.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-04 12:20 <a href="http://www.cppblog.com/qywyh/articles/13339.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>zju1137 匈牙利算法（加标号规划成二分图）</title><link>http://www.cppblog.com/qywyh/articles/13210.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sun, 01 Oct 2006 14:53:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13210.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13210.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13210.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13210.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13210.html</trackback:ping><description><![CDATA[
		<center>
				<font color="blue" size="+2">Girls and Boys</font>
		</center>
		<hr />
		<center>
				<font color="green">Time limit:</font> 10 Seconds   <font color="green">Memory limit: </font>32768K   <br /><font color="green">Total Submit:</font> 628   <font color="green">Accepted Submit:</font> 188   </center>
		<hr />
		<p>the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: there are no two students in the set who have been “romantically involved”. The result of the program is the number of students in such a set.<br /><br />The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:<br /><br />the number of students<br />the description of each student, in the following format<br />student_identifier:(number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3 ...<br />or<br />student_identifier:(0)<br /><br />The student_identifier is an integer number between 0 and n-1, for n subjects.<br />For each given data set, the program should write to standard output a line containing the result.<br /><br />An example is given in Figure 1. </p>
		<p>
				<br />
				<b>Input</b>
		</p>
		<p>7<br />0: (3) 4 5 6<br />1: (2) 4 6<br />2: (0)<br />3: (0)<br />4: (2) 0 1<br />5: (1) 0<br />6: (2) 0 1<br />3<br />0: (2) 1 2<br />1: (1) 0<br />2: (1) 0</p>
		<p>
				<br />
				<b>Output</b>
		</p>
		<p>5<br />2 <br /></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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1001</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> uN, vN;  </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">u,ｖ数目 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">bool</span>
				<span style="COLOR: #000000"> g[MAXN][MAXN];</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">g[i][j] 表示 xi与yj相连 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">bool</span>
				<span style="COLOR: #000000"> p[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> xM[MAXN], yM[MAXN]; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 输出量 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">bool</span>
				<span style="COLOR: #000000"> chk[MAXN]; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">辅助量 检查某轮 y[v]是否被check </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> sign[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> N;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">bool</span>
				<span style="COLOR: #000000"> SearchPath(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> u)<br /><img id="Codehighlighter1_270_474_Open_Image" onclick="this.style.display='none'; Codehighlighter1_270_474_Open_Text.style.display='none'; Codehighlighter1_270_474_Closed_Image.style.display='inline'; Codehighlighter1_270_474_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_270_474_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_270_474_Closed_Text.style.display='none'; Codehighlighter1_270_474_Open_Image.style.display='inline'; Codehighlighter1_270_474_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_270_474_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_270_474_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> v;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (v</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; v</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">vN; v</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_303_457_Open_Image" onclick="this.style.display='none'; Codehighlighter1_303_457_Open_Text.style.display='none'; Codehighlighter1_303_457_Closed_Image.style.display='inline'; Codehighlighter1_303_457_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_303_457_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_303_457_Closed_Text.style.display='none'; Codehighlighter1_303_457_Open_Image.style.display='inline'; Codehighlighter1_303_457_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_303_457_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_303_457_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (g[u][v] </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">!</span>
								<span style="COLOR: #000000">chk[v])<br /><img id="Codehighlighter1_333_454_Open_Image" onclick="this.style.display='none'; Codehighlighter1_333_454_Open_Text.style.display='none'; Codehighlighter1_333_454_Closed_Image.style.display='inline'; Codehighlighter1_333_454_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_333_454_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_333_454_Closed_Text.style.display='none'; Codehighlighter1_333_454_Open_Image.style.display='inline'; Codehighlighter1_333_454_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_333_454_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_333_454_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            chk[v] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (yM[v] </span>
										<span style="COLOR: #000000">==</span>
										<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">||</span>
										<span style="COLOR: #000000"> SearchPath(yM[v])) <br /><img id="Codehighlighter1_398_450_Open_Image" onclick="this.style.display='none'; Codehighlighter1_398_450_Open_Text.style.display='none'; Codehighlighter1_398_450_Closed_Image.style.display='inline'; Codehighlighter1_398_450_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_398_450_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_398_450_Closed_Text.style.display='none'; Codehighlighter1_398_450_Open_Image.style.display='inline'; Codehighlighter1_398_450_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_398_450_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_398_450_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                yM[v] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> u;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                xM[u] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> v;<br /><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: #0000ff">true</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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: #0000ff">false</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> MaxMatch()<br /><img id="Codehighlighter1_493_708_Open_Image" onclick="this.style.display='none'; Codehighlighter1_493_708_Open_Text.style.display='none'; Codehighlighter1_493_708_Closed_Image.style.display='inline'; Codehighlighter1_493_708_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_493_708_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_493_708_Closed_Text.style.display='none'; Codehighlighter1_493_708_Open_Image.style.display='inline'; Codehighlighter1_493_708_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_493_708_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_493_708_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> u;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> ret </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(xM, </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(xM));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(yM, </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(yM));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (u</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; u</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">uN; u</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_598_693_Open_Image" onclick="this.style.display='none'; Codehighlighter1_598_693_Open_Text.style.display='none'; Codehighlighter1_598_693_Closed_Image.style.display='inline'; Codehighlighter1_598_693_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_598_693_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_598_693_Closed_Text.style.display='none'; Codehighlighter1_598_693_Open_Image.style.display='inline'; Codehighlighter1_598_693_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_598_693_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_598_693_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (xM[u] </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_621_690_Open_Image" onclick="this.style.display='none'; Codehighlighter1_621_690_Open_Text.style.display='none'; Codehighlighter1_621_690_Closed_Image.style.display='inline'; Codehighlighter1_621_690_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_621_690_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_621_690_Closed_Text.style.display='none'; Codehighlighter1_621_690_Open_Image.style.display='inline'; Codehighlighter1_621_690_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_621_690_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_621_690_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            memset(chk, </span>
										<span style="COLOR: #0000ff">false</span>
										<span style="COLOR: #000000">, </span>
										<span style="COLOR: #0000ff">sizeof</span>
										<span style="COLOR: #000000">(chk));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (SearchPath(u)) ret</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> ret;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> SetSign(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> v, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> s)<br /><img id="Codehighlighter1_738_837_Open_Image" onclick="this.style.display='none'; Codehighlighter1_738_837_Open_Text.style.display='none'; Codehighlighter1_738_837_Closed_Image.style.display='inline'; Codehighlighter1_738_837_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_738_837_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_738_837_Closed_Text.style.display='none'; Codehighlighter1_738_837_Open_Image.style.display='inline'; Codehighlighter1_738_837_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_738_837_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_738_837_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    sign[v] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> s;<br /><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">N; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (sign[i] </span>
						<span style="COLOR: #000000">==</span>
						<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">&amp;&amp;</span>
						<span style="COLOR: #000000"> p[v][i])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            SetSign(i, </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">s);     <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> Solve()<br /><img id="Codehighlighter1_853_1730_Open_Image" onclick="this.style.display='none'; Codehighlighter1_853_1730_Open_Text.style.display='none'; Codehighlighter1_853_1730_Closed_Image.style.display='inline'; Codehighlighter1_853_1730_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_853_1730_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_853_1730_Closed_Text.style.display='none'; Codehighlighter1_853_1730_Open_Image.style.display='inline'; Codehighlighter1_853_1730_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_853_1730_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_853_1730_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> tU, tV;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> num;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(g, </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(g));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(p, </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(p));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(sign, </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(sign));<br /><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">N; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1005_1117_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1005_1117_Open_Text.style.display='none'; Codehighlighter1_1005_1117_Closed_Image.style.display='inline'; Codehighlighter1_1005_1117_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1005_1117_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1005_1117_Closed_Text.style.display='none'; Codehighlighter1_1005_1117_Open_Image.style.display='inline'; Codehighlighter1_1005_1117_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1005_1117_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_1005_1117_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        scanf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">\n%d: (%d)</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">tU, </span>
								<span style="COLOR: #000000">&amp;</span>
								<span style="COLOR: #000000">num);<br /><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">num; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1068_1114_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1068_1114_Open_Text.style.display='none'; Codehighlighter1_1068_1114_Closed_Image.style.display='inline'; Codehighlighter1_1068_1114_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1068_1114_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1068_1114_Closed_Text.style.display='none'; Codehighlighter1_1068_1114_Open_Image.style.display='inline'; Codehighlighter1_1068_1114_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1068_1114_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_1068_1114_Open_Text">
										<span style="COLOR: #000000">{<br /><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">tV);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            p[tU][tV] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">-------------DFS标号法(划分二分图)-------------------- </span>
						<span style="COLOR: #008000">
								<br />
								<img id="Codehighlighter1_1174_1460_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1174_1460_Open_Text.style.display='none'; Codehighlighter1_1174_1460_Closed_Image.style.display='inline'; Codehighlighter1_1174_1460_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1174_1460_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1174_1460_Closed_Text.style.display='none'; Codehighlighter1_1174_1460_Open_Image.style.display='inline'; Codehighlighter1_1174_1460_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </span>
						<span id="Codehighlighter1_1174_1460_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">/**/</span>
						<span id="Codehighlighter1_1174_1460_Open_Text">
								<span style="COLOR: #008000">/*</span>
								<span style="COLOR: #008000">******************************************<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    邻接表的DFS标号:<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    void setmark(int v,int sign)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    {<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        sig[v]=sign;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        int i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        for (i=0;i&lt;nu[v];i++)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            if (!sig[d[v][i]])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                setmark(d[v][i],sign^3);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    } <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    for (v=0;v&lt;n;v++)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        if (!sig[v]) setmark(v,1);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    *******************************************</span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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">N; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (sign[i] </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">) SetSign(i, </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">------------------------------------------    </span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">        <br /><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">N; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1591_1678_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1591_1678_Open_Text.style.display='none'; Codehighlighter1_1591_1678_Closed_Image.style.display='inline'; Codehighlighter1_1591_1678_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1591_1678_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1591_1678_Closed_Text.style.display='none'; Codehighlighter1_1591_1678_Open_Image.style.display='inline'; Codehighlighter1_1591_1678_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1591_1678_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_1591_1678_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (sign[i] </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1615_1675_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1615_1675_Open_Text.style.display='none'; Codehighlighter1_1615_1675_Closed_Image.style.display='inline'; Codehighlighter1_1615_1675_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1615_1675_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1615_1675_Closed_Text.style.display='none'; Codehighlighter1_1615_1675_Open_Image.style.display='inline'; Codehighlighter1_1615_1675_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1615_1675_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_1615_1675_Open_Text">
										<span style="COLOR: #000000">{<br /><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">N; j</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (p[i][j]) g[i][j] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">            <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    uN </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> vN </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> N;<br /><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">, N</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">MaxMatch()); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><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 /><img id="Codehighlighter1_1745_1807_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1745_1807_Open_Text.style.display='none'; Codehighlighter1_1745_1807_Closed_Image.style.display='inline'; Codehighlighter1_1745_1807_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1745_1807_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1745_1807_Closed_Text.style.display='none'; Codehighlighter1_1745_1807_Open_Image.style.display='inline'; Codehighlighter1_1745_1807_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_1745_1807_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_1745_1807_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (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">N) </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> EOF)<br /><img id="Codehighlighter1_1780_1794_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1780_1794_Open_Text.style.display='none'; Codehighlighter1_1780_1794_Closed_Image.style.display='inline'; Codehighlighter1_1780_1794_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1780_1794_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1780_1794_Closed_Text.style.display='none'; Codehighlighter1_1780_1794_Open_Image.style.display='inline'; Codehighlighter1_1780_1794_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1780_1794_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_1780_1794_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        Solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/13210.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-10-01 22:53 <a href="http://www.cppblog.com/qywyh/articles/13210.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku3018月赛被卡的一道简单dp..</title><link>http://www.cppblog.com/qywyh/articles/13163.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Fri, 29 Sep 2006 17:46:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13163.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13163.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13163.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13163.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13163.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Giftbox</font>
				<br />Time Limit:4000MS  Memory Limit:131072K<br />Total Submit:1210 Accepted:218 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">
						<span lang="en-us" twffan="done">
								<p>
										<img hspace="10" src="http://acm.pku.edu.cn/JudgeOnline/images/3018_1.jpg" align="right" twffan="done" />Bobobo and Bottle are good friends, and the birthday of Bottle is coming. So Bobobo is considering preparing Bottle an unexpected gift for his birthday. As a common sense that when a person at his or her birthday party, he or she will open the gift with the presence of the person who gives the gift and then expresses the appreciation. Bobobo knows that the characteristic of Bottle is rush when he receives something important, so he wants to play a joke on him in this way…</p>
								<p>Bobobo comes into a gift shop, and there are a lot of different kinds of gift boxes. Bobobo intends to choose various boxes with different size and choose one of the gift boxes to contain the precious gift and place this box into another bigger box and place this bigger box into another bigger one… So Bottle will not see the gift until he opens the innermost box. Imagine the process of his opening the boxes, how rush Bottle will be ^_^ !</p>
								<p>The gift boxes are <i>n</i>-dimensional. An <i>n</i>-dimensional box with dimensions ( <i>X</i><sub>1</sub>, <i>X</i><sub>2</sub>, …, <i>X<sub>n</sub></i> ) can be put into another box with dimensions ( <i>Y</i><sub>1</sub>, <i>Y</i><sub>2</sub>, …, <i>Y<sub>n</sub></i> ) if there exists a permutation <i>π</i> on { 1, 2, …, <i>n</i> } such that <i>X<sub>π</sub></i><sub><span style="VERTICAL-ALIGN: sub" twffan="done">1</span></sub> &lt; <i>Y</i><sub>1</sub>, <i>X<sub>π</sub></i><sub><span style="VERTICAL-ALIGN: sub" twffan="done">2</span></sub> &lt; <i>Y</i><sub>2</sub>, …, <i>X<sub>π</sub></i><sub><span style="VERTICAL-ALIGN: sub; FONT-STYLE: italic" twffan="done">n</span></sub> &lt; <i>Y<sub>n</sub></i>. The gift is also <i>n</i>-dimensional and it can be put into a box if it satisfies the criterion above. And Bobobo must try his best to choose as many as boxes to contain the gift.</p>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<span lang="en-us" twffan="done">
								<p>The input file contains multiple test cases. The first line of each test case contains two numbers. The first one is a positive integer number <i>N</i> (1 ≤ <i>N</i> ≤ 500), the number of boxes in the gift shop, and the second one is a positive number <i>d</i> (3 ≤ <i>d</i> ≤ 1 000), the dimension of all the boxes. The next one line contains <i>d</i> positive integers ( <i>G</i><sub>1</sub>, <i>G</i><sub>2</sub>, …, <i>G<sub>d</sub></i> ) representing the dimensions of the gift. And the subsequent <i>N</i> lines each contain <i>d</i> positive integers ( <i>X</i><sub>1</sub>, <i>X</i><sub>2</sub>, …, <i>X<sub>d</sub></i> ) representing the dimensions of each box. You may assume that all the numbers you encounter are positive integers and less than 2<sup>31</sup>. The input data is terminated by EOF.</p>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<span lang="en-us" twffan="done">
								<p>The output of each test case will contain only one line. Output the maximum number of the boxes that Bobobo can choose. If Bobobo can not find any box which can contain the gift, output “Please look for another gift shop!”</p>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>5 7
4 6 8 2 7 5 3
2 8 13 6 10 9 4
80 70 12 3 6 8 2
8 7 4 6 9 10 12
100 200 300 400 500 600 700
800 800 800 800 800 800 800</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>3</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">POJ Monthly--2006.09.29, sza</font>
		</p>
		<p> </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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">algorithm</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">510</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXM </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1010</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n, m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> data[MAXN][MAXM];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> map[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i, j, k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> f[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> d[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> ans;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> DP(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b)<br /><img id="Codehighlighter1_225_395_Open_Image" onclick="this.style.display='none'; Codehighlighter1_225_395_Open_Text.style.display='none'; Codehighlighter1_225_395_Closed_Image.style.display='inline'; Codehighlighter1_225_395_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_225_395_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_225_395_Closed_Text.style.display='none'; Codehighlighter1_225_395_Open_Image.style.display='inline'; Codehighlighter1_225_395_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_225_395_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_225_395_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (d[b] </span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> d[b];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_298_368_Open_Image" onclick="this.style.display='none'; Codehighlighter1_298_368_Open_Text.style.display='none'; Codehighlighter1_298_368_Closed_Image.style.display='inline'; Codehighlighter1_298_368_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_298_368_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_298_368_Closed_Text.style.display='none'; Codehighlighter1_298_368_Open_Image.style.display='inline'; Codehighlighter1_298_368_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_298_368_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_298_368_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (f[i] </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> b </span>
								<span style="COLOR: #000000">!=</span>
								<span style="COLOR: #000000"> i </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> map[b][i] </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> t </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> DP(i) </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">) t </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> DP(i) </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    d[b] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> d[b];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_409_1211_Open_Image" onclick="this.style.display='none'; Codehighlighter1_409_1211_Open_Text.style.display='none'; Codehighlighter1_409_1211_Closed_Image.style.display='inline'; Codehighlighter1_409_1211_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_409_1211_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_409_1211_Closed_Text.style.display='none'; Codehighlighter1_409_1211_Open_Image.style.display='inline'; Codehighlighter1_409_1211_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_409_1211_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_409_1211_Open_Text">
						<span style="COLOR: #000000">{   <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (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">n, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">m) </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> EOF)<br /><img id="Codehighlighter1_459_1174_Open_Image" onclick="this.style.display='none'; Codehighlighter1_459_1174_Open_Text.style.display='none'; Codehighlighter1_459_1174_Closed_Image.style.display='inline'; Codehighlighter1_459_1174_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_459_1174_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_459_1174_Closed_Text.style.display='none'; Codehighlighter1_459_1174_Open_Image.style.display='inline'; Codehighlighter1_459_1174_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_459_1174_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_459_1174_Open_Text">
								<span style="COLOR: #000000">{<br /><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">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_498_614_Open_Image" onclick="this.style.display='none'; Codehighlighter1_498_614_Open_Text.style.display='none'; Codehighlighter1_498_614_Closed_Image.style.display='inline'; Codehighlighter1_498_614_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_498_614_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_498_614_Closed_Text.style.display='none'; Codehighlighter1_498_614_Open_Image.style.display='inline'; Codehighlighter1_498_614_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_498_614_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_498_614_Open_Text">
										<span style="COLOR: #000000">{<br /><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">m; j</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><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">data[i][j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            sort(data[i], data[i]</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">m);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        memset(f, </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #0000ff">sizeof</span>
								<span style="COLOR: #000000">(f));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><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">1</span>
								<span style="COLOR: #000000">; i</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><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">m; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (data[i][j] </span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000"> data[</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">][j])<br /><img id="Codehighlighter1_769_802_Open_Image" onclick="this.style.display='none'; Codehighlighter1_769_802_Open_Text.style.display='none'; Codehighlighter1_769_802_Closed_Image.style.display='inline'; Codehighlighter1_769_802_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_769_802_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_769_802_Closed_Text.style.display='none'; Codehighlighter1_769_802_Open_Image.style.display='inline'; Codehighlighter1_769_802_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
								<span id="Codehighlighter1_769_802_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_769_802_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    f[i] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                <br /><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">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_859_1002_Open_Image" onclick="this.style.display='none'; Codehighlighter1_859_1002_Open_Text.style.display='none'; Codehighlighter1_859_1002_Closed_Image.style.display='inline'; Codehighlighter1_859_1002_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_859_1002_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_859_1002_Closed_Text.style.display='none'; Codehighlighter1_859_1002_Open_Image.style.display='inline'; Codehighlighter1_859_1002_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_859_1002_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_859_1002_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                map[i][j] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (k</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">; k</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">m; k</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_908_997_Open_Image" onclick="this.style.display='none'; Codehighlighter1_908_997_Open_Text.style.display='none'; Codehighlighter1_908_997_Closed_Image.style.display='inline'; Codehighlighter1_908_997_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_908_997_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_908_997_Closed_Text.style.display='none'; Codehighlighter1_908_997_Open_Image.style.display='inline'; Codehighlighter1_908_997_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
										<span id="Codehighlighter1_908_997_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_908_997_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (data[i][k] </span>
												<span style="COLOR: #000000">&gt;=</span>
												<span style="COLOR: #000000"> data[j][k])<br /><img id="Codehighlighter1_950_991_Open_Image" onclick="this.style.display='none'; Codehighlighter1_950_991_Open_Text.style.display='none'; Codehighlighter1_950_991_Closed_Image.style.display='inline'; Codehighlighter1_950_991_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_950_991_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_950_991_Closed_Text.style.display='none'; Codehighlighter1_950_991_Open_Image.style.display='inline'; Codehighlighter1_950_991_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span>
												<span id="Codehighlighter1_950_991_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_950_991_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        map[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> </span>
														<span style="COLOR: #000000">0</span>
														<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        </span>
														<span style="COLOR: #0000ff">break</span>
														<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        memset(d, </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #0000ff">sizeof</span>
								<span style="COLOR: #000000">(d));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        ans </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> DP(</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Please look for another gift shop!\n</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000">
										<br />
										<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);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                       <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">pause</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/13163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-30 01:46 <a href="http://www.cppblog.com/qywyh/articles/13163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku(1696) 用叉积判断异侧</title><link>http://www.cppblog.com/qywyh/articles/13029.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 27 Sep 2006 05:54:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/13029.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/13029.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/13029.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/13029.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/13029.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Space Ant</font>
				<br />Time Limit:1000MS  Memory Limit:10000K<br />Total Submit:113 Accepted:84 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye on the left side of its head and just three feet all on the right side of its body and suffers from three walking limitations: <br /><ol><li>It can not turn right due to its special body structure. <br /></li><li>It leaves a red path while walking. <br /></li><li>It hates to pass over a previously red colored path, and never does that.</li></ol><br />The pictures transmitted by the Discovery space ship depicts that plants in the Y1999 grow in special points on the planet. Analysis of several thousands of the pictures have resulted in discovering a magic coordinate system governing the grow points of the plants. In this coordinate system with x and y axes, <b>no two plants share the same x or y</b>. <br />An M11 needs to eat exactly one plant in each day to stay alive. When it eats one plant, it remains there for the rest of the day with no move. Next day, it looks for another plant to go there and eat it. If it can not reach any other plant it dies by the end of the day. Notice that it can reach a plant in any distance. <br />The problem is to find a path for an M11 to let it live longest. <br />Input is a set of (x, y) coordinates of plants. Suppose A with the coordinates (xA, yA) is the plant with the least y-coordinate. M11 starts from point (0,yA) heading towards plant A. Notice that the solution path should not cross itself and all of the turns should be counter-clockwise. Also note that the solution may visit more than two plants located on a same straight line. <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/1696_1.jpg" twffan="done" /></center></font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">The first line of the input is M, the number of test cases to be solved (1 &lt;= M &lt;= 10). For each test case, the first line is N, the number of plants in that test case (1 &lt;= N &lt;= 50), followed by N lines for each plant data. Each plant data consists of three integers: the first number is the unique plant index (1..N), followed by two positive integers x and y representing the coordinates of the plant. Plants are sorted by the increasing order on their indices in the input file. Suppose that the values of coordinates are at most 100.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">Output should have one separate line for the solution of each test case. A solution is the number of plants on the solution path, followed by the indices of visiting plants in the path in the order of their visits.</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>2
10
1 4 5
2 9 8
3 5 9
4 1 7
5 3 2
6 6 3
7 10 10
8 8 1
9 2 4
10 7 6
14
1 6 11
2 11 9
3 8 7
4 12 8
5 9 20
6 3 2
7 1 6
8 2 13
9 15 1
10 14 17
11 13 19
12 5 18
13 7 3
14 10 16
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>10 8 7 3 4 9 5 6 2 1 10
14 9 10 11 5 12 8 7 6 13 4 14 1 3 2
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Tehran 1999</font>
		</p>
		<p> </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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cmath</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">algorithm</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2000000000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">struct</span>
				<span style="COLOR: #000000"> XYDATA<br /><img id="Codehighlighter1_146_166_Open_Image" onclick="this.style.display='none'; Codehighlighter1_146_166_Open_Text.style.display='none'; Codehighlighter1_146_166_Closed_Image.style.display='inline'; Codehighlighter1_146_166_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_146_166_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_146_166_Closed_Text.style.display='none'; Codehighlighter1_146_166_Open_Image.style.display='inline'; Codehighlighter1_146_166_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_146_166_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_146_166_Open_Text">
						<span style="COLOR: #000000">{<br /><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, index;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> inorder(XYDATA a, XYDATA b)<br /><img id="Codehighlighter1_202_252_Open_Image" onclick="this.style.display='none'; Codehighlighter1_202_252_Open_Text.style.display='none'; Codehighlighter1_202_252_Closed_Image.style.display='inline'; Codehighlighter1_202_252_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_202_252_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_202_252_Closed_Text.style.display='none'; Codehighlighter1_202_252_Open_Image.style.display='inline'; Codehighlighter1_202_252_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_202_252_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_202_252_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> a.y </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000"> b.y </span>
						<span style="COLOR: #000000">||</span>
						<span style="COLOR: #000000"> (a.y </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> b.y </span>
						<span style="COLOR: #000000">&amp;&amp;</span>
						<span style="COLOR: #000000"> a.x </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000"> b.x);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> cross(XYDATA a, XYDATA b)<br /><img id="Codehighlighter1_285_318_Open_Image" onclick="this.style.display='none'; Codehighlighter1_285_318_Open_Text.style.display='none'; Codehighlighter1_285_318_Closed_Image.style.display='inline'; Codehighlighter1_285_318_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_285_318_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_285_318_Closed_Text.style.display='none'; Codehighlighter1_285_318_Open_Image.style.display='inline'; Codehighlighter1_285_318_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_285_318_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_285_318_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> a.x </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> b.y </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000"> a.y </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> b.x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">double</span>
				<span style="COLOR: #000000"> Cos(XYDATA a, XYDATA b)<br /><img id="Codehighlighter1_352_431_Open_Image" onclick="this.style.display='none'; Codehighlighter1_352_431_Open_Text.style.display='none'; Codehighlighter1_352_431_Closed_Image.style.display='inline'; Codehighlighter1_352_431_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_352_431_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_352_431_Closed_Text.style.display='none'; Codehighlighter1_352_431_Open_Image.style.display='inline'; Codehighlighter1_352_431_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_352_431_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_352_431_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> (a.x</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">b.x</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">a.y</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">b.y) </span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #000000"> (sqrt(a.x</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">a.x</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">a.y</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">a.y) </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000"> sqrt(b.x</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">b.x</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">b.y</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">b.y));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> Solve()<br /><img id="Codehighlighter1_446_1481_Open_Image" onclick="this.style.display='none'; Codehighlighter1_446_1481_Open_Text.style.display='none'; Codehighlighter1_446_1481_Closed_Image.style.display='inline'; Codehighlighter1_446_1481_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_446_1481_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_446_1481_Closed_Text.style.display='none'; Codehighlighter1_446_1481_Open_Image.style.display='inline'; Codehighlighter1_446_1481_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_446_1481_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_1481_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">out</span>
						<span style="COLOR: #000000">[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> outSize </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000"> ;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">bool</span>
						<span style="COLOR: #000000"> mp[</span>
						<span style="COLOR: #000000">101</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">101</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">double</span>
						<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    XYDATA a[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    XYDATA v, u;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> beg;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">n);<br /><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">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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%d</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">a[i].index, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">a[i].x, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">a[i].y);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    sort(a, a</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">n, inorder);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><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">101</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">101</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            mp[i][j] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">false</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    v.x </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> a[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">].x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    v.y </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    mp[a[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">].x][a[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">].y] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">true</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    beg </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">out</span>
						<span style="COLOR: #000000">[outSize</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> a[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">].index;<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_886_1387_Open_Image" onclick="this.style.display='none'; Codehighlighter1_886_1387_Open_Text.style.display='none'; Codehighlighter1_886_1387_Closed_Image.style.display='inline'; Codehighlighter1_886_1387_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_886_1387_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_886_1387_Closed_Text.style.display='none'; Codehighlighter1_886_1387_Open_Image.style.display='inline'; Codehighlighter1_886_1387_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_886_1387_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_886_1387_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">bool</span>
								<span style="COLOR: #000000"> isFind </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">false</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        tmp </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">2</span>
								<span style="COLOR: #000000">;<br /><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">n; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (beg </span>
								<span style="COLOR: #000000">!=</span>
								<span style="COLOR: #000000"> j </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">!</span>
								<span style="COLOR: #000000">mp[a[j].x][a[j].y])<br /><img id="Codehighlighter1_988_1206_Open_Image" onclick="this.style.display='none'; Codehighlighter1_988_1206_Open_Text.style.display='none'; Codehighlighter1_988_1206_Closed_Image.style.display='inline'; Codehighlighter1_988_1206_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_988_1206_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_988_1206_Closed_Text.style.display='none'; Codehighlighter1_988_1206_Open_Image.style.display='inline'; Codehighlighter1_988_1206_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_988_1206_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_988_1206_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                u.x </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> a[j].x </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[beg].x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                u.y </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> a[j].y </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[beg].y;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">int</span>
										<span style="COLOR: #000000"> cro </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> cross(v, u);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (cro </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">)    <br /><img id="Codehighlighter1_1098_1201_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1098_1201_Open_Text.style.display='none'; Codehighlighter1_1098_1201_Closed_Image.style.display='inline'; Codehighlighter1_1098_1201_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1098_1201_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1098_1201_Closed_Text.style.display='none'; Codehighlighter1_1098_1201_Open_Image.style.display='inline'; Codehighlighter1_1098_1201_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
										<span id="Codehighlighter1_1098_1201_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_1098_1201_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    isFind </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #0000ff">true</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (Cos(v, u) </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> tmp) <br /><img id="Codehighlighter1_1152_1195_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1152_1195_Open_Text.style.display='none'; Codehighlighter1_1152_1195_Closed_Image.style.display='inline'; Codehighlighter1_1152_1195_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1152_1195_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1152_1195_Closed_Text.style.display='none'; Codehighlighter1_1152_1195_Open_Image.style.display='inline'; Codehighlighter1_1152_1195_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span>
												<span id="Codehighlighter1_1152_1195_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_1152_1195_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        tmp </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> Cos(v, u);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        t </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (isFind)<br /><img id="Codehighlighter1_1224_1358_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1224_1358_Open_Text.style.display='none'; Codehighlighter1_1224_1358_Closed_Image.style.display='inline'; Codehighlighter1_1224_1358_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1224_1358_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1224_1358_Closed_Text.style.display='none'; Codehighlighter1_1224_1358_Open_Image.style.display='inline'; Codehighlighter1_1224_1358_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1224_1358_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_1224_1358_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            v.x </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> a[t].x </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[beg].x;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            v.y </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> a[t].y </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[beg].y;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            mp[a[t].x][a[t].y] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            beg </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">out</span>
										<span style="COLOR: #000000">[outSize</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> a[t].index;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000"> <br /><img id="Codehighlighter1_1370_1384_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1370_1384_Open_Text.style.display='none'; Codehighlighter1_1370_1384_Closed_Image.style.display='inline'; Codehighlighter1_1370_1384_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1370_1384_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1370_1384_Closed_Text.style.display='none'; Codehighlighter1_1370_1384_Open_Image.style.display='inline'; Codehighlighter1_1370_1384_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_1370_1384_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_1370_1384_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, outSize);<br /><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">outSize; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</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: #0000ff">out</span>
						<span style="COLOR: #000000">[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_1496_1572_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1496_1572_Open_Text.style.display='none'; Codehighlighter1_1496_1572_Closed_Image.style.display='inline'; Codehighlighter1_1496_1572_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1496_1572_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1496_1572_Closed_Text.style.display='none'; Codehighlighter1_1496_1572_Open_Image.style.display='inline'; Codehighlighter1_1496_1572_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_1496_1572_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_1496_1572_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (n</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1545_1559_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1545_1559_Open_Text.style.display='none'; Codehighlighter1_1545_1559_Closed_Image.style.display='inline'; Codehighlighter1_1545_1559_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1545_1559_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1545_1559_Closed_Text.style.display='none'; Codehighlighter1_1545_1559_Open_Image.style.display='inline'; Codehighlighter1_1545_1559_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1545_1559_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_1545_1559_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        Solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/13029.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-27 13:54 <a href="http://www.cppblog.com/qywyh/articles/13029.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>线形模型中分， 三维DP(pku2292)</title><link>http://www.cppblog.com/qywyh/articles/12992.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Tue, 26 Sep 2006 10:51:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12992.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12992.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12992.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12992.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12992.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Optimal Keypad</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:168 Accepted:80 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">Optimus Mobiles produces mobile phones that support SMS messages. The Mobiles have a keypad of 12 keys, numbered 1 to 12. There is a character string assigned to each key. To type in the n-th character in the character string of a particular key, one should press the key n times. Optimus Mobiles wishes to solve the problem of assigning character strings to the keys such that for typing a random text out of a dictionary of common words, the average typing effort (i.e. the average number of keystrokes) is minimal. <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/2292_1.jpg" twffan="done" /><br />Figure 1</center><br />To be more precise, consider a set of characters {a, b, c,..., z, +, *, /, ?} printed on a label tape as in Fig. 2. We want to cut the tape into 12 pieces each containing one or more characters. The 12 labels are numbered 1 to 12 from left to right and will be assigned to the keypad keys in that order. <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/2292_2.jpg" twffan="done" /><br />Figure 2</center><br />You are to write a program to find the 11 cutting positions for a given dictionary of common words. The cutting positions should minimize the average number of keystrokes over all common words in the dictionary. Your output should be a string of 11 characters, where character i in this string is the first character of the (i+1)<sup>th</sup> label.</font>
				<font face="宋体, MS Song">
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">The first line contains a single integer t (1 &lt;= t &lt;= 10), the number of test cases. Each test case starts with a line, containing an integer M (1 &lt;= M &lt;= 10000), the number of common words in the test case. In each M subsequent line, there is a common word. Each common word contains at most 30 characters from the alphabet {a, b, c,..., z, +, *, /, ?}.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">The output contains one line per test case containing an optimal cut string. Obviously, there may be more than a single optimal cut string, so print the optimal cut string which is the smallest one in lexicographic order.</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>2
2
hi
ok
5
hello
bye
how
when
who
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>bcdefghijko
bcdefhlnowy
</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Tehran 2003<br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">100000000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> f[</span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> s[</span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> l[</span>
				<span style="COLOR: #000000">13</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">30</span>
				<span style="COLOR: #000000">];<br /><img id="Codehighlighter1_138_291_Open_Image" onclick="this.style.display='none'; Codehighlighter1_138_291_Open_Text.style.display='none'; Codehighlighter1_138_291_Closed_Image.style.display='inline'; Codehighlighter1_138_291_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_138_291_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_138_291_Closed_Text.style.display='none'; Codehighlighter1_138_291_Open_Image.style.display='inline'; Codehighlighter1_138_291_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> c[] </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span id="Codehighlighter1_138_291_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_138_291_Open_Text">
						<span style="COLOR: #000000">{</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">a</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">b</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">c</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </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">'</span>
						<span style="COLOR: #000000">e</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">f</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">g</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">h</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">i</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">j</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">k</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">l</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">m</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">n</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">o</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />            , </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">p</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">q</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">r</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">s</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">t</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">u</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">v</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">w</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">x</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">y</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">z</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">?</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">}</span>
				</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> OutPut(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> k, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> j)<br /><img id="Codehighlighter1_328_475_Open_Image" onclick="this.style.display='none'; Codehighlighter1_328_475_Open_Text.style.display='none'; Codehighlighter1_328_475_Closed_Image.style.display='inline'; Codehighlighter1_328_475_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_328_475_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_328_475_Closed_Text.style.display='none'; Codehighlighter1_328_475_Open_Image.style.display='inline'; Codehighlighter1_328_475_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_328_475_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_328_475_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (l[k][i][j] </span>
						<span style="COLOR: #000000">&gt;=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_353_473_Open_Image" onclick="this.style.display='none'; Codehighlighter1_353_473_Open_Text.style.display='none'; Codehighlighter1_353_473_Closed_Image.style.display='inline'; Codehighlighter1_353_473_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_353_473_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_353_473_Closed_Text.style.display='none'; Codehighlighter1_353_473_Open_Image.style.display='inline'; Codehighlighter1_353_473_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_353_473_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_353_473_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        OutPut(l[k][i][j], i, s[k][i][j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">%c</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, c[s[k][i][j]</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        OutPut(k</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">l[k][i][j], s[k][i][j]</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">, j);    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> Solve()<br /><img id="Codehighlighter1_491_1374_Open_Image" onclick="this.style.display='none'; Codehighlighter1_491_1374_Open_Text.style.display='none'; Codehighlighter1_491_1374_Closed_Image.style.display='inline'; Codehighlighter1_491_1374_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_491_1374_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_491_1374_Closed_Text.style.display='none'; Codehighlighter1_491_1374_Open_Image.style.display='inline'; Codehighlighter1_491_1374_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_491_1374_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_491_1374_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, k, p, q, t, e;<br /><img id="Codehighlighter1_548_550_Open_Image" onclick="this.style.display='none'; Codehighlighter1_548_550_Open_Text.style.display='none'; Codehighlighter1_548_550_Closed_Image.style.display='inline'; Codehighlighter1_548_550_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_548_550_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_548_550_Closed_Text.style.display='none'; Codehighlighter1_548_550_Open_Image.style.display='inline'; Codehighlighter1_548_550_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> cntLable[</span>
						<span style="COLOR: #000000">300</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span id="Codehighlighter1_548_550_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_548_550_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> sum;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> tmpS[</span>
						<span style="COLOR: #000000">31</span>
						<span style="COLOR: #000000">];<br /><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">n);<br /><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">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_619_700_Open_Image" onclick="this.style.display='none'; Codehighlighter1_619_700_Open_Text.style.display='none'; Codehighlighter1_619_700_Closed_Image.style.display='inline'; Codehighlighter1_619_700_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_619_700_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_619_700_Closed_Text.style.display='none'; Codehighlighter1_619_700_Open_Image.style.display='inline'; Codehighlighter1_619_700_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_619_700_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_619_700_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        scanf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">%s</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, tmpS);<br /><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">strlen(tmpS); j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            cntLable[tmpS[j]]</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (k</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">12</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">30</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">30</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_776_845_Open_Image" onclick="this.style.display='none'; Codehighlighter1_776_845_Open_Text.style.display='none'; Codehighlighter1_776_845_Closed_Image.style.display='inline'; Codehighlighter1_776_845_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_776_845_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_776_845_Closed_Text.style.display='none'; Codehighlighter1_776_845_Open_Image.style.display='inline'; Codehighlighter1_776_845_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
						<span id="Codehighlighter1_776_845_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_776_845_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                f[k][i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                s[k][i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                l[k][i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">init k=1</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </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">30</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_883_989_Open_Image" onclick="this.style.display='none'; Codehighlighter1_883_989_Open_Text.style.display='none'; Codehighlighter1_883_989_Closed_Image.style.display='inline'; Codehighlighter1_883_989_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_883_989_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_883_989_Closed_Text.style.display='none'; Codehighlighter1_883_989_Open_Image.style.display='inline'; Codehighlighter1_883_989_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_883_989_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_883_989_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        sum </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><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">i, k</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">30</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">, k</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_931_986_Open_Image" onclick="this.style.display='none'; Codehighlighter1_931_986_Open_Text.style.display='none'; Codehighlighter1_931_986_Closed_Image.style.display='inline'; Codehighlighter1_931_986_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_931_986_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_931_986_Closed_Text.style.display='none'; Codehighlighter1_931_986_Open_Image.style.display='inline'; Codehighlighter1_931_986_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_931_986_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_931_986_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            sum </span>
										<span style="COLOR: #000000">+=</span>
										<span style="COLOR: #000000"> cntLable[c[j]] </span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000"> k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            f[</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][i][j] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> sum;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (k</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">12</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">30</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">i</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">k</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">30</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1069_1335_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1069_1335_Open_Text.style.display='none'; Codehighlighter1_1069_1335_Closed_Image.style.display='inline'; Codehighlighter1_1069_1335_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1069_1335_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1069_1335_Closed_Text.style.display='none'; Codehighlighter1_1069_1335_Open_Image.style.display='inline'; Codehighlighter1_1069_1335_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
						<span id="Codehighlighter1_1069_1335_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_1069_1335_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (t</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">i; t</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">j; t</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1099_1330_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1099_1330_Open_Text.style.display='none'; Codehighlighter1_1099_1330_Closed_Image.style.display='inline'; Codehighlighter1_1099_1330_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1099_1330_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1099_1330_Closed_Text.style.display='none'; Codehighlighter1_1099_1330_Open_Image.style.display='inline'; Codehighlighter1_1099_1330_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
								<span id="Codehighlighter1_1099_1330_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_1099_1330_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    e </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> k</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> t</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">?</span>
										<span style="COLOR: #000000"> k</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000"> : t</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (p</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">; p</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">e; p</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (f[k][i][j] </span>
										<span style="COLOR: #000000">&gt;</span>
										<span style="COLOR: #000000"> f[p][i][t] </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> f[k</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">p][t</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][j])<br /><img id="Codehighlighter1_1221_1324_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1221_1324_Open_Text.style.display='none'; Codehighlighter1_1221_1324_Closed_Image.style.display='inline'; Codehighlighter1_1221_1324_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1221_1324_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1221_1324_Closed_Text.style.display='none'; Codehighlighter1_1221_1324_Open_Image.style.display='inline'; Codehighlighter1_1221_1324_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        </span>
										<span id="Codehighlighter1_1221_1324_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_1221_1324_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            f[k][i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> f[p][i][t] </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> f[k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">p][t</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            s[k][i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            l[k][i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> p;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                        }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    OutPut(</span>
						<span style="COLOR: #000000">12</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">29</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_1388_1462_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1388_1462_Open_Text.style.display='none'; Codehighlighter1_1388_1462_Closed_Image.style.display='inline'; Codehighlighter1_1388_1462_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1388_1462_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1388_1462_Closed_Text.style.display='none'; Codehighlighter1_1388_1462_Open_Image.style.display='inline'; Codehighlighter1_1388_1462_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_1388_1462_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_1388_1462_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><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">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (n</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1435_1449_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1435_1449_Open_Text.style.display='none'; Codehighlighter1_1435_1449_Closed_Image.style.display='inline'; Codehighlighter1_1435_1449_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1435_1449_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1435_1449_Closed_Text.style.display='none'; Codehighlighter1_1435_1449_Open_Image.style.display='inline'; Codehighlighter1_1435_1449_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1435_1449_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_1435_1449_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        Solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/12992.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-26 18:51 <a href="http://www.cppblog.com/qywyh/articles/12992.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku(2761)离散化+线段树</title><link>http://www.cppblog.com/qywyh/articles/12427.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 13 Sep 2006 15:40:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12427.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12427.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12427.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12427.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12427.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Feed the dogs				Time Limit:6000MS  Memory Limit:65536KTotal Submit:1387 Accepted:222 						Description								Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/12427.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/12427.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-13 23:40 <a href="http://www.cppblog.com/qywyh/articles/12427.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku(3003, 枚举高度的dp) </title><link>http://www.cppblog.com/qywyh/articles/12203.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Sat, 09 Sep 2006 12:06:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12203.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12203.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12203.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12203.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12203.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">
				</font>
		</p>
		<p align="center">Spiderman’s workout<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:211 Accepted:63 <font color="red">Special Judged</font></p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">Staying fit is important for every super hero, and Spiderman is no exception. Every day he undertakes a climbing exercise in which he climbs a certain distance, rests for a minute, then climbs again, rests again, and so on. The exercise is described by a sequence of distances d1, d2, . . . , dm telling how many meters he is to climb before the first first break, before the second break, and so on. Froman exercise perspective it does not really matter if he climbs up or down at the i:th climbing stage, but it is practical to sometimes climb up and sometimes climb down so that he both starts and finishes at street level. Obviously, he can never be below street level. Also, he would like to use as low a building as possible (he does not like to admit it, but he is actually afraid of heights). The building must be at least 2 meters higher than the highest point his feet reach during the workout. <br /><br />He wants your help in determining when he should go up and when he should go down. The answer must be legal: it must start and end at street level (0 meters above ground) and it may never go below street level. Among the legal solutions he wants one that minimizes the required building height. When looking for a solution, you may not reorder the distances. <br /><br />If the distances are 20 20 20 20 he can either climb up, up, down, down or up, down, up, down. Both are legal, but the second one is better (in fact optimal) because it only requires a building of height 22, whereas the first one requires a building of height 42. If the distances are 3 2 5 3 1 2, an optimal legal solution is to go up, up, down, up, down, down. Note that for some distance sequences there is no legal solution at all (e.g., for 3 4 2 1 6 4 5). <br /></font>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">The first line of the input contains an integer N giving the number of test scenarios. The following 2N lines specify the test scenarios, two lines per scenario: the first line gives a positive integer M ≤ 40 which is the number of distances, and the following line contains the M positive integer distances. For any scenario, the total distance climbed (the sum of the distances in that scenario) is at most 1000.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">For each input scenario a single line should be output. This line should either be the string "IMPOSSIBLE" if no legal solution exists, or it should be a string of length M containing only the characters "U" and "D", where the i:th character indicates if Spiderman should climb up or down at the i:th stage. If there are several different legal and optimal solutions, output one of them (it does not matter which one as long as it is optimal).</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>3
4
20 20 20 20
6
3 2 5 3 1 2
7
3 4 2 1 6 4 5</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>UDUD
UUDUDD
IMPOSSIBLE</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Svenskt Mästerskap i Programmering 2003<br /><br />ghost_wei说十分钟就能打完， 汗， 牛人。。<br /><br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cstdlib</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2001</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2000000000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> dp[</span>
				<span style="COLOR: #000000">41</span>
				<span style="COLOR: #000000">][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> s[</span>
				<span style="COLOR: #000000">41</span>
				<span style="COLOR: #000000">][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a[</span>
				<span style="COLOR: #000000">41</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> print(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> m)<br /><img id="Codehighlighter1_184_323_Open_Image" onclick="this.style.display='none'; Codehighlighter1_184_323_Open_Text.style.display='none'; Codehighlighter1_184_323_Closed_Image.style.display='inline'; Codehighlighter1_184_323_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_184_323_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_184_323_Closed_Text.style.display='none'; Codehighlighter1_184_323_Open_Image.style.display='inline'; Codehighlighter1_184_323_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_184_323_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_184_323_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (n </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> ;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (s[n][m] </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_232_272_Open_Image" onclick="this.style.display='none'; Codehighlighter1_232_272_Open_Text.style.display='none'; Codehighlighter1_232_272_Closed_Image.style.display='inline'; Codehighlighter1_232_272_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_232_272_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_232_272_Closed_Text.style.display='none'; Codehighlighter1_232_272_Open_Image.style.display='inline'; Codehighlighter1_232_272_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_232_272_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_232_272_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        print(n</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">, m</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">a[n]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">U</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_281_321_Open_Image" onclick="this.style.display='none'; Codehighlighter1_281_321_Open_Text.style.display='none'; Codehighlighter1_281_321_Closed_Image.style.display='inline'; Codehighlighter1_281_321_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_281_321_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_281_321_Closed_Text.style.display='none'; Codehighlighter1_281_321_Open_Image.style.display='inline'; Codehighlighter1_281_321_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_281_321_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_281_321_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        print(n</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">, m</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">a[n]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">D</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> solve()<br /><img id="Codehighlighter1_339_1058_Open_Image" onclick="this.style.display='none'; Codehighlighter1_339_1058_Open_Text.style.display='none'; Codehighlighter1_339_1058_Closed_Image.style.display='inline'; Codehighlighter1_339_1058_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_339_1058_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_339_1058_Closed_Text.style.display='none'; Codehighlighter1_339_1058_Open_Image.style.display='inline'; Codehighlighter1_339_1058_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_339_1058_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_339_1058_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t1, t2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> maxn </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">n);<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_430_471_Open_Image" onclick="this.style.display='none'; Codehighlighter1_430_471_Open_Text.style.display='none'; Codehighlighter1_430_471_Closed_Image.style.display='inline'; Codehighlighter1_430_471_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_430_471_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_430_471_Closed_Text.style.display='none'; Codehighlighter1_430_471_Open_Image.style.display='inline'; Codehighlighter1_430_471_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_430_471_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_430_471_Open_Text">
								<span style="COLOR: #000000">{<br /><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">a[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        maxn </span>
								<span style="COLOR: #000000">+=</span>
								<span style="COLOR: #000000"> a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(dp, </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(dp));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(s, </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(s));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    dp[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][a[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">]] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> a[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    s[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][a[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">]] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">2</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_593_964_Open_Image" onclick="this.style.display='none'; Codehighlighter1_593_964_Open_Text.style.display='none'; Codehighlighter1_593_964_Closed_Image.style.display='inline'; Codehighlighter1_593_964_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_593_964_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_593_964_Closed_Text.style.display='none'; Codehighlighter1_593_964_Open_Image.style.display='inline'; Codehighlighter1_593_964_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_593_964_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_593_964_Open_Text">
								<span style="COLOR: #000000">{<br /><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">maxn; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_622_961_Open_Image" onclick="this.style.display='none'; Codehighlighter1_622_961_Open_Text.style.display='none'; Codehighlighter1_622_961_Closed_Image.style.display='inline'; Codehighlighter1_622_961_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_622_961_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_622_961_Closed_Text.style.display='none'; Codehighlighter1_622_961_Open_Image.style.display='inline'; Codehighlighter1_622_961_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_622_961_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_622_961_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            t1 </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            t2 </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (j</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">a[i] </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> dp[i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][j</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">a[i]] </span>
										<span style="COLOR: #000000">!=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                t1 </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> max(j, dp[i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][j</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">a[i]]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (j</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">a[i] </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> maxn </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> dp[i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][j</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">a[i]] </span>
										<span style="COLOR: #000000">!=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                t2 </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> max(j, dp[i</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">][j</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">a[i]]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (t1 </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> t2)<br /><img id="Codehighlighter1_829_870_Open_Image" onclick="this.style.display='none'; Codehighlighter1_829_870_Open_Text.style.display='none'; Codehighlighter1_829_870_Closed_Image.style.display='inline'; Codehighlighter1_829_870_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_829_870_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_829_870_Closed_Text.style.display='none'; Codehighlighter1_829_870_Open_Image.style.display='inline'; Codehighlighter1_829_870_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_829_870_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_829_870_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t1;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                s[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">0</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">else</span>
										<span style="COLOR: #000000">
												<br />
												<img id="Codehighlighter1_883_957_Open_Image" onclick="this.style.display='none'; Codehighlighter1_883_957_Open_Text.style.display='none'; Codehighlighter1_883_957_Closed_Image.style.display='inline'; Codehighlighter1_883_957_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
												<img id="Codehighlighter1_883_957_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_883_957_Closed_Text.style.display='none'; Codehighlighter1_883_957_Open_Image.style.display='inline'; Codehighlighter1_883_957_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_883_957_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_883_957_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (t2 </span>
												<span style="COLOR: #000000">!=</span>
												<span style="COLOR: #000000"> INF)<br /><img id="Codehighlighter1_908_952_Open_Image" onclick="this.style.display='none'; Codehighlighter1_908_952_Open_Text.style.display='none'; Codehighlighter1_908_952_Closed_Image.style.display='inline'; Codehighlighter1_908_952_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_908_952_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_908_952_Closed_Text.style.display='none'; Codehighlighter1_908_952_Open_Image.style.display='inline'; Codehighlighter1_908_952_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span id="Codehighlighter1_908_952_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_908_952_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    dp[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> t2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    s[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> </span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (dp[n][</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">IMPOSSIBLE\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">else</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1021_1056_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1021_1056_Open_Text.style.display='none'; Codehighlighter1_1021_1056_Closed_Image.style.display='inline'; Codehighlighter1_1021_1056_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1021_1056_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1021_1056_Closed_Text.style.display='none'; Codehighlighter1_1021_1056_Open_Image.style.display='inline'; Codehighlighter1_1021_1056_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1021_1056_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_1021_1056_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        print(n, </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">\n</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_1072_1168_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1072_1168_Open_Text.style.display='none'; Codehighlighter1_1072_1168_Closed_Image.style.display='inline'; Codehighlighter1_1072_1168_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1072_1168_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1072_1168_Closed_Text.style.display='none'; Codehighlighter1_1072_1168_Open_Image.style.display='inline'; Codehighlighter1_1072_1168_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_1072_1168_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_1072_1168_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> caseTime;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">caseTime);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (caseTime</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1141_1155_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1141_1155_Open_Text.style.display='none'; Codehighlighter1_1141_1155_Closed_Image.style.display='inline'; Codehighlighter1_1141_1155_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1141_1155_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1141_1155_Closed_Text.style.display='none'; Codehighlighter1_1141_1155_Open_Image.style.display='inline'; Codehighlighter1_1141_1155_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1141_1155_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_1141_1155_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/12203.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-09 20:06 <a href="http://www.cppblog.com/qywyh/articles/12203.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku1191(noi99的棋盘分割,多维dp)</title><link>http://www.cppblog.com/qywyh/articles/12176.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Fri, 08 Sep 2006 14:57:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12176.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12176.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12176.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12176.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12176.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">棋盘分割</font>
				<br />Time Limit:1000MS  Memory Limit:10000K<br />Total Submit:490 Accepted:194 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">将一个８*８的棋盘进行如下分割：将原棋盘割下一块矩形棋盘并使剩下部分也是矩形，再将剩下的部分继续如此分割，这样割了(n-1)次后，连同最后剩下的矩形棋盘共有n块矩形棋盘。(每次切割都只能沿着棋盘格子的边进行) <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/1191_1.jpg" twffan="done" /></center><br />原棋盘上每一格有一个分值，一块矩形棋盘的总分为其所含各格分值之和。现在需要把棋盘按上述规则分割成n块矩形棋盘，并使各矩形棋盘总分的均方差最小。 <br />均方差<img src="http://acm.pku.edu.cn/JudgeOnline/images/1191_2.jpg" twffan="done" />，其中平均值<img src="http://acm.pku.edu.cn/JudgeOnline/images/1191_3.jpg" twffan="done" />，xi为第i块矩形棋盘的总分。 <br />请编程对给出的棋盘及n，求出O'的最小值。 <br /></font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">第1行为一个整数n(1 &lt; n &lt; 15)。 <br />第2行至第9行每行为8个小于100的非负整数，表示棋盘上相应格子的分值。每行相邻两数之间用一个空格分隔。 <br /></font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">仅一个数，为O'（四舍五入精确到小数点后三位）。</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>3
1 1 1 1 1 1 1 3
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 0
1 1 1 1 1 1 0 3</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>1.633</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Noi 99<br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cstdlib</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cmath</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2000000000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> f[</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">15</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> s[</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> d[</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">9</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> init()<br /><img id="Codehighlighter1_174_501_Open_Image" onclick="this.style.display='none'; Codehighlighter1_174_501_Open_Text.style.display='none'; Codehighlighter1_174_501_Closed_Image.style.display='inline'; Codehighlighter1_174_501_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_174_501_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_174_501_Closed_Text.style.display='none'; Codehighlighter1_174_501_Open_Image.style.display='inline'; Codehighlighter1_174_501_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_174_501_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_174_501_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> x1, y1, x2, y2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> sum;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (x1</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; x1</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; x1</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (y1</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; y1</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; y1</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (x2</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">x1; x2</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; x2</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (y2</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">y1; y2</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; y2</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_330_499_Open_Image" onclick="this.style.display='none'; Codehighlighter1_330_499_Open_Text.style.display='none'; Codehighlighter1_330_499_Closed_Image.style.display='inline'; Codehighlighter1_330_499_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_330_499_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_330_499_Closed_Text.style.display='none'; Codehighlighter1_330_499_Open_Image.style.display='inline'; Codehighlighter1_330_499_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
						<span id="Codehighlighter1_330_499_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_330_499_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    sum </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><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">x1; i</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">x2; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><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">y1; j</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">y2; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            sum </span>
								<span style="COLOR: #000000">+=</span>
								<span style="COLOR: #000000"> d[i][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    s[x1][y1][x2][y2] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> sum;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    f[x1][y1][x2][y2][</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> sum </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000"> sum;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<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 /><img id="Codehighlighter1_514_1531_Open_Image" onclick="this.style.display='none'; Codehighlighter1_514_1531_Open_Text.style.display='none'; Codehighlighter1_514_1531_Closed_Image.style.display='inline'; Codehighlighter1_514_1531_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_514_1531_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_514_1531_Closed_Text.style.display='none'; Codehighlighter1_514_1531_Open_Image.style.display='inline'; Codehighlighter1_514_1531_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_514_1531_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_514_1531_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> x1, y1, x2, y2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> a, b;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t, tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">double</span>
						<span style="COLOR: #000000"> p </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">n);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">1</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_667_714_Open_Image" onclick="this.style.display='none'; Codehighlighter1_667_714_Open_Text.style.display='none'; Codehighlighter1_667_714_Closed_Image.style.display='inline'; Codehighlighter1_667_714_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_667_714_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_667_714_Closed_Text.style.display='none'; Codehighlighter1_667_714_Open_Image.style.display='inline'; Codehighlighter1_667_714_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_667_714_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_667_714_Open_Text">
								<span style="COLOR: #000000">{<br /><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">d[i][j]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            p </span>
								<span style="COLOR: #000000">+=</span>
								<span style="COLOR: #000000"> d[i][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    p </span>
						<span style="COLOR: #000000">/=</span>
						<span style="COLOR: #000000"> n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">    cout &lt;&lt; "?? "&lt;&lt; p &lt;&lt; endl;</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    init();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (k</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; k</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_790_1452_Open_Image" onclick="this.style.display='none'; Codehighlighter1_790_1452_Open_Text.style.display='none'; Codehighlighter1_790_1452_Closed_Image.style.display='inline'; Codehighlighter1_790_1452_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_790_1452_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_790_1452_Closed_Text.style.display='none'; Codehighlighter1_790_1452_Open_Image.style.display='inline'; Codehighlighter1_790_1452_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_790_1452_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_790_1452_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (x1</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">; x1</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">8</span>
								<span style="COLOR: #000000">; x1</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (y1</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">; y1</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">8</span>
								<span style="COLOR: #000000">; y1</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (x2</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">x1; x2</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">8</span>
								<span style="COLOR: #000000">; x2</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (y2</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">y1; y2</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">8</span>
								<span style="COLOR: #000000">; y2</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_909_1449_Open_Image" onclick="this.style.display='none'; Codehighlighter1_909_1449_Open_Text.style.display='none'; Codehighlighter1_909_1449_Closed_Image.style.display='inline'; Codehighlighter1_909_1449_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_909_1449_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_909_1449_Closed_Text.style.display='none'; Codehighlighter1_909_1449_Open_Image.style.display='inline'; Codehighlighter1_909_1449_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span>
								<span id="Codehighlighter1_909_1449_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_909_1449_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        tmp </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> INF;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">竖切</span>
										<span style="COLOR: #008000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">                        </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (a</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">x1; a</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">x2; a</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_973_1164_Open_Image" onclick="this.style.display='none'; Codehighlighter1_973_1164_Open_Text.style.display='none'; Codehighlighter1_973_1164_Closed_Image.style.display='inline'; Codehighlighter1_973_1164_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_973_1164_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_973_1164_Closed_Text.style.display='none'; Codehighlighter1_973_1164_Open_Image.style.display='inline'; Codehighlighter1_973_1164_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        </span>
										<span id="Codehighlighter1_973_1164_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_973_1164_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            t </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> min(f[x1][y1][a][y2][k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">]</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">s[a</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][y1][x2][y2]</span>
												<span style="COLOR: #000000">*</span>
												<span style="COLOR: #000000">s[a</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][y1][x2][y2]<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                                , f[a</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][y1][x2][y2][k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">]</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">s[x1][y1][a][y2]</span>
												<span style="COLOR: #000000">*</span>
												<span style="COLOR: #000000">s[x1][y1][a][y2]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (tmp </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> t) <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                                tmp </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                        }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">横切</span>
										<span style="COLOR: #008000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">                        </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (b</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">y1; b</span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000">y2; b</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1211_1401_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1211_1401_Open_Text.style.display='none'; Codehighlighter1_1211_1401_Closed_Image.style.display='inline'; Codehighlighter1_1211_1401_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1211_1401_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1211_1401_Closed_Text.style.display='none'; Codehighlighter1_1211_1401_Open_Image.style.display='inline'; Codehighlighter1_1211_1401_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                        </span>
										<span id="Codehighlighter1_1211_1401_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_1211_1401_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            t </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> min(f[x1][y1][x2][b][k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">]</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">s[x1][b</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][x2][y2]</span>
												<span style="COLOR: #000000">*</span>
												<span style="COLOR: #000000">s[x1][b</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][x2][y2]<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                                , f[x1][b</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][x2][y2][k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">]</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">s[x1][y1][x2][b]</span>
												<span style="COLOR: #000000">*</span>
												<span style="COLOR: #000000">s[x1][y1][x2][b]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (tmp </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> t)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                                tmp </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                        }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        f[x1][y1][x2][y2][k] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%.3f\n</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, sqrt(</span>
						<span style="COLOR: #0000ff">double</span>
						<span style="COLOR: #000000">(f[</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">][n])</span>
						<span style="COLOR: #000000">/</span>
						<span style="COLOR: #0000ff">double</span>
						<span style="COLOR: #000000">(n)</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">p</span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">p));<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/12176.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-08 22:57 <a href="http://www.cppblog.com/qywyh/articles/12176.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku(2951简单的三维DP)</title><link>http://www.cppblog.com/qywyh/articles/12146.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Thu, 07 Sep 2006 15:43:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12146.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12146.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12146.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12146.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12146.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Cake Cutting</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:528 Accepted:228 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">
						<span lang="en-us" twffan="done">
								<p>You are given a rectangular cake of integral dimensions <i>w</i> × <i>h</i>. Your goal is to divide this cake into <i>m</i> rectangular pieces of integral dimensions such that the area of the largest piece is minimal. Each cut must be a straight line parallel to one of the sides of the original cake and must divide a piece of cake into two new pieces of positive area. Note that since a cut divides only a single piece, exactly <i>m</i> − 1 cuts are needed.</p>
								<p>If <i>w</i> = 4, <i>h</i> = 4, and <i>m</i> = 4, then the following cuts minimize the area of the largest piece:</p>
								<center>
										<img src="http://acm.pku.edu.cn/JudgeOnline/images/2951_1.gif" twffan="done" />
								</center>
								<p>However, if <i>w</i> = 4, <i>h</i> = 4, and <i>m</i> = 3, then the following cuts are optimal:</p>
								<center>
										<img src="http://acm.pku.edu.cn/JudgeOnline/images/2951_2.gif" twffan="done" />
								</center>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<span lang="en-us" twffan="done">
								<p>The input test file will contain multiple test cases, each of which consists of three integers <i>w</i>, <i>h</i>, <i>m</i> separated by a single space, with 1 ≤ <i>w</i>, <i>h</i>, <i>m</i> ≤ 20 and <i>m</i> ≤ <i>wh</i>. The end-of-file is marked by a test case with <i>w</i> = <i>h</i> = <i>m</i> = 0 and should not be processed.</p>
						</span>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<p>For each test case, write a single line with a positive integer indicating the area of the largest piece.</p>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>4 4 4
4 4 3
0 0 0</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>4
6</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Stanford Local 2004<br /><br />用了记忆化搜索, 900多ms才过掉， rp好啊..<br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> f[</span>
				<span style="COLOR: #000000">21</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">21</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">21</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> lookup(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> w, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> h, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> k)<br /><img id="Codehighlighter1_94_788_Open_Image" onclick="this.style.display='none'; Codehighlighter1_94_788_Open_Text.style.display='none'; Codehighlighter1_94_788_Closed_Image.style.display='inline'; Codehighlighter1_94_788_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_94_788_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_94_788_Closed_Text.style.display='none'; Codehighlighter1_94_788_Open_Image.style.display='inline'; Codehighlighter1_94_788_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_94_788_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_94_788_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (f[w][h][k] </span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> f[w][h][k];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (k </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_150_196_Open_Image" onclick="this.style.display='none'; Codehighlighter1_150_196_Open_Text.style.display='none'; Codehighlighter1_150_196_Closed_Image.style.display='inline'; Codehighlighter1_150_196_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_150_196_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_150_196_Closed_Text.style.display='none'; Codehighlighter1_150_196_Open_Image.style.display='inline'; Codehighlighter1_150_196_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_150_196_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_150_196_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        f[w][h][k] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> w </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000"> h;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> f[w][h][k];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> max1 </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2000000000</span>
						<span style="COLOR: #000000">, max2 </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">2000000000</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">t = 0;</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (i</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">w; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_293_491_Open_Image" onclick="this.style.display='none'; Codehighlighter1_293_491_Open_Text.style.display='none'; Codehighlighter1_293_491_Closed_Image.style.display='inline'; Codehighlighter1_293_491_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_293_491_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_293_491_Closed_Text.style.display='none'; Codehighlighter1_293_491_Open_Image.style.display='inline'; Codehighlighter1_293_491_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_293_491_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_293_491_Open_Text">
								<span style="COLOR: #000000">{<br /><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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">k; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_319_488_Open_Image" onclick="this.style.display='none'; Codehighlighter1_319_488_Open_Text.style.display='none'; Codehighlighter1_319_488_Closed_Image.style.display='inline'; Codehighlighter1_319_488_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_319_488_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_319_488_Closed_Text.style.display='none'; Codehighlighter1_319_488_Open_Image.style.display='inline'; Codehighlighter1_319_488_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_319_488_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_319_488_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (i</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">h </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> j </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> (w</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i)</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">h </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> k</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">j)<br /><img id="Codehighlighter1_359_484_Open_Image" onclick="this.style.display='none'; Codehighlighter1_359_484_Open_Text.style.display='none'; Codehighlighter1_359_484_Closed_Image.style.display='inline'; Codehighlighter1_359_484_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_359_484_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_359_484_Closed_Text.style.display='none'; Codehighlighter1_359_484_Open_Image.style.display='inline'; Codehighlighter1_359_484_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_359_484_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_359_484_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                t </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> lookup(i, h, j) </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> lookup(w</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">i, h, k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">j) </span>
												<span style="COLOR: #000000">?</span>
												<span style="COLOR: #000000"> lookup(i, h, j) : lookup(w</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">i, h, k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">j);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (max1 </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> t)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    max1 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000">t = 0;</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
						</span>
						<span style="COLOR: #000000">    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (i</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">h; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_526_724_Open_Image" onclick="this.style.display='none'; Codehighlighter1_526_724_Open_Text.style.display='none'; Codehighlighter1_526_724_Closed_Image.style.display='inline'; Codehighlighter1_526_724_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_526_724_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_526_724_Closed_Text.style.display='none'; Codehighlighter1_526_724_Open_Image.style.display='inline'; Codehighlighter1_526_724_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_526_724_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_526_724_Open_Text">
								<span style="COLOR: #000000">{<br /><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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">k; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_552_721_Open_Image" onclick="this.style.display='none'; Codehighlighter1_552_721_Open_Text.style.display='none'; Codehighlighter1_552_721_Closed_Image.style.display='inline'; Codehighlighter1_552_721_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_552_721_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_552_721_Closed_Text.style.display='none'; Codehighlighter1_552_721_Open_Image.style.display='inline'; Codehighlighter1_552_721_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_552_721_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_552_721_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (w</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">i </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> j </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> w</span>
										<span style="COLOR: #000000">*</span>
										<span style="COLOR: #000000">(h</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">i) </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> k</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">j)<br /><img id="Codehighlighter1_592_717_Open_Image" onclick="this.style.display='none'; Codehighlighter1_592_717_Open_Text.style.display='none'; Codehighlighter1_592_717_Closed_Image.style.display='inline'; Codehighlighter1_592_717_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_592_717_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_592_717_Closed_Text.style.display='none'; Codehighlighter1_592_717_Open_Image.style.display='inline'; Codehighlighter1_592_717_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_592_717_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_592_717_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                t </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> lookup(w, i, j) </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> lookup(w, h</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">i, k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">j) </span>
												<span style="COLOR: #000000">?</span>
												<span style="COLOR: #000000"> lookup(w, i, j) : lookup(w, h</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">i, k</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">j);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (max2 </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> t)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    max2 </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    f[w][h][k] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> max1 </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000"> max2 </span>
						<span style="COLOR: #000000">?</span>
						<span style="COLOR: #000000"> max1 : max2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> f[w][h][k];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> g(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> w, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> h, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> k)<br /><img id="Codehighlighter1_818_871_Open_Image" onclick="this.style.display='none'; Codehighlighter1_818_871_Open_Text.style.display='none'; Codehighlighter1_818_871_Closed_Image.style.display='inline'; Codehighlighter1_818_871_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_818_871_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_818_871_Closed_Text.style.display='none'; Codehighlighter1_818_871_Open_Image.style.display='inline'; Codehighlighter1_818_871_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_818_871_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_818_871_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(f, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(f));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> lookup(w, h, k);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_885_1035_Open_Image" onclick="this.style.display='none'; Codehighlighter1_885_1035_Open_Text.style.display='none'; Codehighlighter1_885_1035_Closed_Image.style.display='inline'; Codehighlighter1_885_1035_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_885_1035_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_885_1035_Closed_Text.style.display='none'; Codehighlighter1_885_1035_Open_Image.style.display='inline'; Codehighlighter1_885_1035_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_885_1035_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_885_1035_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> w, h, m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (scanf(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">%d%d%d</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">w, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">h, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">m) </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> EOF)<br /><img id="Codehighlighter1_947_1022_Open_Image" onclick="this.style.display='none'; Codehighlighter1_947_1022_Open_Text.style.display='none'; Codehighlighter1_947_1022_Closed_Image.style.display='inline'; Codehighlighter1_947_1022_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_947_1022_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_947_1022_Closed_Text.style.display='none'; Codehighlighter1_947_1022_Open_Image.style.display='inline'; Codehighlighter1_947_1022_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_947_1022_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_947_1022_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (w </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> h </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">&amp;&amp;</span>
								<span style="COLOR: #000000"> m </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">) </span>
								<span style="COLOR: #0000ff">break</span>
								<span style="COLOR: #000000">;<br /><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">, g(w, h, m));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/12146.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-07 23:43 <a href="http://www.cppblog.com/qywyh/articles/12146.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pku2985 第一次用两种数据结构解题， 并查集+线段树</title><link>http://www.cppblog.com/qywyh/articles/12084.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Wed, 06 Sep 2006 05:28:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/12084.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/12084.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/12084.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/12084.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/12084.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: The k-th Largest Group				Time Limit:2000MS  Memory Limit:131072KTotal Submit:1222 Accepted:290 						Description																						Newman likes playing with cats. He possesses lots o...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/12084.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/12084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-06 13:28 <a href="http://www.cppblog.com/qywyh/articles/12084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一道不错的动态规划(1160)</title><link>http://www.cppblog.com/qywyh/articles/11937.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Fri, 01 Sep 2006 14:33:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/11937.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/11937.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/11937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/11937.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/11937.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Post Office</font>
				<br />Time Limit:1000MS  Memory Limit:10000K<br />Total Submit:1047 Accepted:456 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in the same position. The distance between two positions is the absolute value of the difference of their integer coordinates. <br /><br />Post offices will be built in some, but not necessarily all of the villages. A village and the post office in it have the same position. For building the post offices, their positions should be chosen so that the total sum of all distances between each village and its nearest post office is minimum. <br /><br />You are to write a program which, given the positions of the villages and the number of post offices, computes the least possible sum of all distances between each village and its nearest post office. <br /></font>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">Your program is to read from standard input. The first line contains two integers: the first is the number of villages V, 1 &lt;= V &lt;= 300, and the second is the number of post offices P, 1 &lt;= P &lt;= 30, P &lt;= V. The second line contains V integers in increasing order. These V integers are the positions of the villages. For each position X it holds that 1 &lt;= X &lt;= 10000.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">The first line contains one integer S, which is the sum of all distances between each village and its nearest post office. </font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>10 5
1 2 3 6 7 9 11 22 44 50</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>9</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">IOI 2000<br /><br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img id="Codehighlighter1_42_262_Open_Image" onclick="this.style.display='none'; Codehighlighter1_42_262_Open_Text.style.display='none'; Codehighlighter1_42_262_Closed_Image.style.display='inline'; Codehighlighter1_42_262_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_42_262_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_42_262_Closed_Text.style.display='none'; Codehighlighter1_42_262_Open_Image.style.display='inline'; Codehighlighter1_42_262_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_42_262_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">/**/</span>
				<span id="Codehighlighter1_42_262_Open_Text">
						<span style="COLOR: #008000">/*</span>
						<span style="COLOR: #008000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />p表示i到j的建一个邮局的最小值<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />q表示前i个地点建j个邮局的最小值 <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />dp方程<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                 p[1][i]               (j == 1)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /> q[i][j] = {                                                    }<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                q[k][j-1] + p[k+1][i]  (j &gt; 1) (k从j-1到i-1)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /></span>
						<span style="COLOR: #008000">*/</span>
				</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> p[</span>
				<span style="COLOR: #000000">301</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">301</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> q[</span>
				<span style="COLOR: #000000">301</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">31</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a[</span>
				<span style="COLOR: #000000">301</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><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 /><img id="Codehighlighter1_323_1498_Open_Image" onclick="this.style.display='none'; Codehighlighter1_323_1498_Open_Text.style.display='none'; Codehighlighter1_323_1498_Closed_Image.style.display='inline'; Codehighlighter1_323_1498_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_323_1498_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_323_1498_Closed_Text.style.display='none'; Codehighlighter1_323_1498_Open_Image.style.display='inline'; Codehighlighter1_323_1498_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_323_1498_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_323_1498_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> V, P;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, k, l;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t[</span>
						<span style="COLOR: #000000">301</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> tmp;<br /><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">V, </span>
						<span style="COLOR: #000000">&amp;</span>
						<span style="COLOR: #000000">P);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">V; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">a[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">V; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">i; j</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">V; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_540_890_Open_Image" onclick="this.style.display='none'; Codehighlighter1_540_890_Open_Text.style.display='none'; Codehighlighter1_540_890_Closed_Image.style.display='inline'; Codehighlighter1_540_890_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_540_890_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_540_890_Closed_Text.style.display='none'; Codehighlighter1_540_890_Open_Image.style.display='inline'; Codehighlighter1_540_890_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_540_890_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_540_890_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (i </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> j)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                p[i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000">
										<br />
										<img id="Codehighlighter1_624_880_Open_Image" onclick="this.style.display='none'; Codehighlighter1_624_880_Open_Text.style.display='none'; Codehighlighter1_624_880_Closed_Image.style.display='inline'; Codehighlighter1_624_880_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_624_880_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_624_880_Closed_Text.style.display='none'; Codehighlighter1_624_880_Open_Image.style.display='inline'; Codehighlighter1_624_880_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_624_880_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_624_880_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                l </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> (i </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> j) </span>
										<span style="COLOR: #000000">/</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">2</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                p[i][j] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (k</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">i; k</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">l; k</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    p[i][j] </span>
										<span style="COLOR: #000000">+=</span>
										<span style="COLOR: #000000"> a[l] </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[k];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">for</span>
										<span style="COLOR: #000000"> (k</span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000">l</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">; k</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">j; k</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    p[i][j] </span>
										<span style="COLOR: #000000">+=</span>
										<span style="COLOR: #000000"> a[k] </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000"> a[l];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />               <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    memset(q, </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">, </span>
						<span style="COLOR: #0000ff">sizeof</span>
						<span style="COLOR: #000000">(q));<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">V; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">1</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">P; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_992_1429_Open_Image" onclick="this.style.display='none'; Codehighlighter1_992_1429_Open_Text.style.display='none'; Codehighlighter1_992_1429_Closed_Image.style.display='inline'; Codehighlighter1_992_1429_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_992_1429_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_992_1429_Closed_Text.style.display='none'; Codehighlighter1_992_1429_Open_Image.style.display='inline'; Codehighlighter1_992_1429_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_992_1429_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_992_1429_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (j </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                q[i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> p[</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000">
										<br />
										<img id="Codehighlighter1_1082_1419_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1082_1419_Open_Text.style.display='none'; Codehighlighter1_1082_1419_Closed_Image.style.display='inline'; Codehighlighter1_1082_1419_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
										<img id="Codehighlighter1_1082_1419_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1082_1419_Closed_Text.style.display='none'; Codehighlighter1_1082_1419_Open_Image.style.display='inline'; Codehighlighter1_1082_1419_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_1082_1419_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_1082_1419_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (i </span>
										<span style="COLOR: #000000">&gt;=</span>
										<span style="COLOR: #000000"> j)<br /><img id="Codehighlighter1_1128_1405_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1128_1405_Open_Text.style.display='none'; Codehighlighter1_1128_1405_Closed_Image.style.display='inline'; Codehighlighter1_1128_1405_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1128_1405_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1128_1405_Closed_Text.style.display='none'; Codehighlighter1_1128_1405_Open_Image.style.display='inline'; Codehighlighter1_1128_1405_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
										<span id="Codehighlighter1_1128_1405_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_1128_1405_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    q[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> q[j</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">][j</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">] </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> p[j][i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
												<span style="COLOR: #0000ff">for</span>
												<span style="COLOR: #000000"> (k</span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000">j; k</span>
												<span style="COLOR: #000000">&lt;</span>
												<span style="COLOR: #000000">i; k</span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1243_1387_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1243_1387_Open_Text.style.display='none'; Codehighlighter1_1243_1387_Closed_Image.style.display='inline'; Codehighlighter1_1243_1387_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1243_1387_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1243_1387_Closed_Text.style.display='none'; Codehighlighter1_1243_1387_Open_Image.style.display='inline'; Codehighlighter1_1243_1387_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                    </span>
												<span id="Codehighlighter1_1243_1387_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_1243_1387_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        </span>
														<span style="COLOR: #0000ff">if</span>
														<span style="COLOR: #000000"> (q[i][j] </span>
														<span style="COLOR: #000000">&gt;</span>
														<span style="COLOR: #000000"> q[k][j</span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">] </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> p[k</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">][i])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                            q[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> q[k][j</span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">] </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> p[k</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">][i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                    }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> q[V][P] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> endl;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">pause</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/11937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-09-01 22:33 <a href="http://www.cppblog.com/qywyh/articles/11937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Floyd-Warshall多源最短路径</title><link>http://www.cppblog.com/qywyh/articles/11819.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Tue, 29 Aug 2006 07:24:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/11819.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/11819.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/11819.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/11819.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/11819.html</trackback:ping><description><![CDATA[
		<p> </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">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">101</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> INF </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1000000</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> g[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> d[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> floyd(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n)<br /><img id="Codehighlighter1_102_449_Open_Image" onclick="this.style.display='none'; Codehighlighter1_102_449_Open_Text.style.display='none'; Codehighlighter1_102_449_Closed_Image.style.display='inline'; Codehighlighter1_102_449_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_102_449_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_102_449_Closed_Text.style.display='none'; Codehighlighter1_102_449_Open_Image.style.display='inline'; Codehighlighter1_102_449_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_102_449_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_102_449_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">  i, j, k;<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">1</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            d[i][j] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> g[i][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (k</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; k</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_236_433_Open_Image" onclick="this.style.display='none'; Codehighlighter1_236_433_Open_Text.style.display='none'; Codehighlighter1_236_433_Closed_Image.style.display='inline'; Codehighlighter1_236_433_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_236_433_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_236_433_Closed_Text.style.display='none'; Codehighlighter1_236_433_Open_Image.style.display='inline'; Codehighlighter1_236_433_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_236_433_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_236_433_Open_Text">
								<span style="COLOR: #000000">{<br /><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">1</span>
								<span style="COLOR: #000000">; i</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_312_429_Open_Image" onclick="this.style.display='none'; Codehighlighter1_312_429_Open_Text.style.display='none'; Codehighlighter1_312_429_Closed_Image.style.display='inline'; Codehighlighter1_312_429_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_312_429_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_312_429_Closed_Text.style.display='none'; Codehighlighter1_312_429_Open_Image.style.display='inline'; Codehighlighter1_312_429_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
								<span id="Codehighlighter1_312_429_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_312_429_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (d[i][k] </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> INF </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> d[k][j] </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> INF<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #000000">&amp;&amp;</span>
										<span style="COLOR: #000000"> d[i][k] </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> d[k][j] </span>
										<span style="COLOR: #000000">&lt;</span>
										<span style="COLOR: #000000"> d[i][j])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    d[i][j] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> d[i][k] </span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000"> d[k][j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/11819.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-08-29 15:24 <a href="http://www.cppblog.com/qywyh/articles/11819.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一道noi的dp题(1189)</title><link>http://www.cppblog.com/qywyh/articles/11817.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Tue, 29 Aug 2006 06:00:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/11817.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/11817.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/11817.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/11817.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/11817.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 钉子和小球				Time Limit:1000MS  Memory Limit:10000KTotal Submit:577 Accepted:168 						Description								有一个三角形木板,竖直立放，上面钉着n(n+1)/2颗钉子，还有(n+1)个格子（当n=5时如图1）。每颗钉子和周围的钉子的距离都等于d，每个格子的宽度也都等于d，且除了最左端...&nbsp;&nbsp;<a href='http://www.cppblog.com/qywyh/articles/11817.html'>阅读全文</a><img src ="http://www.cppblog.com/qywyh/aggbug/11817.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-08-29 14:00 <a href="http://www.cppblog.com/qywyh/articles/11817.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>动态规划(2738 used sicheng's algorithm)</title><link>http://www.cppblog.com/qywyh/articles/11782.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Mon, 28 Aug 2006 08:00:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/11782.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/11782.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/11782.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/11782.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/11782.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Two Ends</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:625 Accepted:271 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">In the two-player game "Two Ends", an even number of cards is laid out in a row. On each card, face up, is written a positive integer. Players take turns removing a card from either end of the row and placing the card in their pile. The player whose cards add up to the highest number wins the game. Now one strategy is to simply pick the card at the end that is the largest -- we'll call this the greedy strategy. However, this is not always optimal, as the following example shows: (The first player would win if she would first pick the 3 instead of the 4.) <br />3 2 10 4 <br />You are to determine exactly how bad the greedy strategy is for different games when the second player uses it but the first player is free to use any strategy she wishes.</font>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">There will be multiple test cases. Each test case will be contained on one line. Each line will start with an even integer n followed by n positive integers. A value of n = 0 indicates end of input. You may assume that n is no more than 1000. Furthermore, you may assume that the sum of the numbers in the list does not exceed 1,000,000.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">For each test case you should print one line of output of the form: <br />In game m, the greedy strategy might lose by as many as p points. <br />where m is the number of the game (starting at game 1) and p is the maximum possible difference between the first player's score and second player's score when the second player uses the greedy strategy. When employing the greedy strategy, always take the larger end. If there is a tie, remove the left end.</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>4 3 2 10 4
8 1 2 3 4 5 6 7 8
8 2 2 1 5 3 8 7 3
0</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>In game 1, the greedy strategy might lose by as many as 7 points.
In game 2, the greedy strategy might lose by as many as 4 points.
In game 3, the greedy strategy might lose by as many as 5 points.</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">East Central North America 2005<br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">cmath</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAXN </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1001</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> dp[MAXN][MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><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 /><img id="Codehighlighter1_114_1510_Open_Image" onclick="this.style.display='none'; Codehighlighter1_114_1510_Open_Text.style.display='none'; Codehighlighter1_114_1510_Closed_Image.style.display='inline'; Codehighlighter1_114_1510_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_114_1510_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_114_1510_Closed_Text.style.display='none'; Codehighlighter1_114_1510_Open_Image.style.display='inline'; Codehighlighter1_114_1510_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_114_1510_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_114_1510_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j, l, n;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> t </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> a[MAXN];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (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">n), n</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_218_1479_Open_Image" onclick="this.style.display='none'; Codehighlighter1_218_1479_Open_Text.style.display='none'; Codehighlighter1_218_1479_Closed_Image.style.display='inline'; Codehighlighter1_218_1479_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_218_1479_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_218_1479_Closed_Text.style.display='none'; Codehighlighter1_218_1479_Open_Image.style.display='inline'; Codehighlighter1_218_1479_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_218_1479_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_218_1479_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        memset(dp, </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #0000ff">sizeof</span>
								<span style="COLOR: #000000">(dp));<br /><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">1</span>
								<span style="COLOR: #000000">; i</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><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">a[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            <br /><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">1</span>
								<span style="COLOR: #000000">; i</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">n; i</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            dp[i][i</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> abs(a[i] </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000"> a[i</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000"> (l</span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">4</span>
								<span style="COLOR: #000000">; l</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">n; l</span>
								<span style="COLOR: #000000">+=</span>
								<span style="COLOR: #000000">2</span>
								<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_440_1368_Open_Image" onclick="this.style.display='none'; Codehighlighter1_440_1368_Open_Text.style.display='none'; Codehighlighter1_440_1368_Closed_Image.style.display='inline'; Codehighlighter1_440_1368_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_440_1368_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_440_1368_Closed_Text.style.display='none'; Codehighlighter1_440_1368_Open_Image.style.display='inline'; Codehighlighter1_440_1368_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span id="Codehighlighter1_440_1368_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_440_1368_Open_Text">
										<span style="COLOR: #000000">{<br /><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">1</span>
										<span style="COLOR: #000000">; i</span>
										<span style="COLOR: #000000">&lt;=</span>
										<span style="COLOR: #000000">n</span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">l</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">; i</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_491_1358_Open_Image" onclick="this.style.display='none'; Codehighlighter1_491_1358_Open_Text.style.display='none'; Codehighlighter1_491_1358_Closed_Image.style.display='inline'; Codehighlighter1_491_1358_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_491_1358_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_491_1358_Closed_Text.style.display='none'; Codehighlighter1_491_1358_Open_Image.style.display='inline'; Codehighlighter1_491_1358_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span id="Codehighlighter1_491_1358_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_491_1358_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                j </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> i </span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000"> l </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (a[j] </span>
												<span style="COLOR: #000000">&lt;=</span>
												<span style="COLOR: #000000"> a[i</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">])<br /><img id="Codehighlighter1_576_728_Open_Image" onclick="this.style.display='none'; Codehighlighter1_576_728_Open_Text.style.display='none'; Codehighlighter1_576_728_Closed_Image.style.display='inline'; Codehighlighter1_576_728_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_576_728_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_576_728_Closed_Text.style.display='none'; Codehighlighter1_576_728_Open_Image.style.display='inline'; Codehighlighter1_576_728_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span id="Codehighlighter1_576_728_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_576_728_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    tmp </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> dp[i</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">2</span>
														<span style="COLOR: #000000">][j] </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> a[i] </span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000"> a[i</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
														<span style="COLOR: #0000ff">if</span>
														<span style="COLOR: #000000"> (dp[i][j] </span>
														<span style="COLOR: #000000">&lt;</span>
														<span style="COLOR: #000000"> tmp)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        dp[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (a[i] </span>
												<span style="COLOR: #000000">&lt;</span>
												<span style="COLOR: #000000"> a[j</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">])<br /><img id="Codehighlighter1_781_933_Open_Image" onclick="this.style.display='none'; Codehighlighter1_781_933_Open_Text.style.display='none'; Codehighlighter1_781_933_Closed_Image.style.display='inline'; Codehighlighter1_781_933_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_781_933_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_781_933_Closed_Text.style.display='none'; Codehighlighter1_781_933_Open_Image.style.display='inline'; Codehighlighter1_781_933_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span id="Codehighlighter1_781_933_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_781_933_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    tmp </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> dp[i][j</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"> a[j] </span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000"> a[j</span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
														<span style="COLOR: #0000ff">if</span>
														<span style="COLOR: #000000"> (dp[i][j] </span>
														<span style="COLOR: #000000">&lt;</span>
														<span style="COLOR: #000000"> tmp)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        dp[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (a[i] </span>
												<span style="COLOR: #000000">&gt;=</span>
												<span style="COLOR: #000000"> a[j</span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">])<br /><img id="Codehighlighter1_987_1139_Open_Image" onclick="this.style.display='none'; Codehighlighter1_987_1139_Open_Text.style.display='none'; Codehighlighter1_987_1139_Closed_Image.style.display='inline'; Codehighlighter1_987_1139_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_987_1139_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_987_1139_Closed_Text.style.display='none'; Codehighlighter1_987_1139_Open_Image.style.display='inline'; Codehighlighter1_987_1139_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span id="Codehighlighter1_987_1139_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_987_1139_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    tmp </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> dp[i</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">][j</span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">] </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> a[j] </span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000"> a[i];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
														<span style="COLOR: #0000ff">if</span>
														<span style="COLOR: #000000"> (dp[i][j] </span>
														<span style="COLOR: #000000">&lt;</span>
														<span style="COLOR: #000000"> tmp)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        dp[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
												<span style="COLOR: #0000ff">if</span>
												<span style="COLOR: #000000"> (a[j] </span>
												<span style="COLOR: #000000">&gt;</span>
												<span style="COLOR: #000000"> a[i</span>
												<span style="COLOR: #000000">+</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">])<br /><img id="Codehighlighter1_1192_1344_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1192_1344_Open_Text.style.display='none'; Codehighlighter1_1192_1344_Closed_Image.style.display='inline'; Codehighlighter1_1192_1344_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1192_1344_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1192_1344_Closed_Text.style.display='none'; Codehighlighter1_1192_1344_Open_Image.style.display='inline'; Codehighlighter1_1192_1344_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />                </span>
												<span id="Codehighlighter1_1192_1344_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_1192_1344_Open_Text">
														<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    tmp </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> dp[i</span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">][j</span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000">1</span>
														<span style="COLOR: #000000">] </span>
														<span style="COLOR: #000000">+</span>
														<span style="COLOR: #000000"> a[i] </span>
														<span style="COLOR: #000000">-</span>
														<span style="COLOR: #000000"> a[j];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                    </span>
														<span style="COLOR: #0000ff">if</span>
														<span style="COLOR: #000000"> (dp[i][j] </span>
														<span style="COLOR: #000000">&lt;</span>
														<span style="COLOR: #000000"> tmp)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                        dp[i][j] </span>
														<span style="COLOR: #000000">=</span>
														<span style="COLOR: #000000"> tmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />                }</span>
												</span>
												<span style="COLOR: #000000">
														<br />
														<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        printf(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">In game %d, the greedy strategy might lose by as many as %d points.\n</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, t</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">, dp[</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][n]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    system(</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">pause</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/11782.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-08-28 16:00 <a href="http://www.cppblog.com/qywyh/articles/11782.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>动态规划, 别人看来可能很简单, 但是我还是认为值得把它记录下来(pku1080)</title><link>http://www.cppblog.com/qywyh/articles/11528.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Mon, 21 Aug 2006 07:47:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/11528.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/11528.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/11528.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/11528.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/11528.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Human Gene Functions</font>
				<br />Time Limit:1000MS  Memory Limit:10000K<br />Total Submit:866 Accepted:507 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose human diseases and to design new drugs for them. <br /><br />A human gene can be identified through a series of time-consuming biological experiments, often with the help of computer programs. Once a sequence of a gene is obtained, the next job is to determine its function. <br />One of the methods for biologists to use in determining the function of a new gene sequence that they have just identified is to search a database with the new gene as a query. The database to be searched stores many gene sequences and their functions – many researchers have been submitting their genes and functions to the database and the database is freely accessible through the Internet. <br /><br />A database search will return a list of gene sequences from the database that are similar to the query gene. <br />Biologists assume that sequence similarity often implies functional similarity. So, the function of the new gene might be one of the functions that the genes from the list have. To exactly determine which one is the right one another series of biological experiments will be needed. <br /><br />Your job is to make a program that compares two genes and determines their similarity as explained below. Your program may be used as a part of the database search if you can provide an efficient one. <br />Given two genes AGTGATG and GTTAG, how similar are they? One of the methods to measure the similarity <br />of two genes is called alignment. In an alignment, spaces are inserted, if necessary, in appropriate positions of <br />the genes to make them equally long and score the resulting genes according to a scoring matrix. <br /><br />For example, one space is inserted into AGTGATG to result in AGTGAT-G, and three spaces are inserted into GTTAG to result in –GT--TAG. A space is denoted by a minus sign (-). The two genes are now of equal <br />length. These two strings are aligned: <br /><br />AGTGAT-G <br />-GT--TAG <br /><br />In this alignment, there are four matches, namely, G in the second position, T in the third, T in the sixth, and G in the eighth. Each pair of aligned characters is assigned a score according to the following scoring matrix. <br /><center><img src="http://acm.pku.edu.cn/JudgeOnline/images/1080/1080_1.gif" twffan="done" /></center><br />denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9. <br /><br />Of course, many other alignments are possible. One is shown below (a different number of spaces are inserted into different positions): <br /><br />AGTGATG <br />-GTTA-G <br /><br />This alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is better than the previous one. As a matter of fact, this one is optimal since no other alignment can have a higher score. So, it is said that the <br />similarity of the two genes is 14. </font>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">The input consists of T test cases. The number of test cases ) (T is given in the first line of the input file. Each test case consists of two lines: each line contains an integer, the length of a gene, followed by a gene sequence. The length of each gene sequence is at least one and does not exceed 100. </font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">The output should print the similarity of each test case, one per line. </font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>2 
7 AGTGATG 
5 GTTAG 
7 AGCTATT 
9 AGCTTTAAA </pre>
				</font>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>14
21 </pre>
				</font>
		</p>
		<p>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">Taejon 2001</font>
				<br />
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> map[</span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">][</span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> initMap()<br /><img id="Codehighlighter1_82_560_Open_Image" onclick="this.style.display='none'; Codehighlighter1_82_560_Open_Text.style.display='none'; Codehighlighter1_82_560_Closed_Image.style.display='inline'; Codehighlighter1_82_560_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_82_560_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_82_560_Closed_Text.style.display='none'; Codehighlighter1_82_560_Open_Image.style.display='inline'; Codehighlighter1_82_560_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_82_560_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_82_560_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">3</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">3</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">4</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">2</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">A</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">T</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">G</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">C</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">5</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">128</span>
						<span style="COLOR: #000000">;<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> solve()<br /><img id="Codehighlighter1_575_1167_Open_Image" onclick="this.style.display='none'; Codehighlighter1_575_1167_Open_Text.style.display='none'; Codehighlighter1_575_1167_Closed_Image.style.display='inline'; Codehighlighter1_575_1167_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_575_1167_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_575_1167_Closed_Text.style.display='none'; Codehighlighter1_575_1167_Open_Image.style.display='inline'; Codehighlighter1_575_1167_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_575_1167_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_575_1167_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> s1[</span>
						<span style="COLOR: #000000">105</span>
						<span style="COLOR: #000000">], s2[</span>
						<span style="COLOR: #000000">105</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> dp[</span>
						<span style="COLOR: #000000">105</span>
						<span style="COLOR: #000000">][</span>
						<span style="COLOR: #000000">105</span>
						<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> l1, l2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cin </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> l1 </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> s1 </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> l2 </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> s2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    dp[</span>
						<span style="COLOR: #000000">0</span>
						<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"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">l1; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        dp[i][</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> dp[i</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 style="COLOR: #000000">+</span>
						<span style="COLOR: #000000"> map[s1[i</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">]][</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">];<br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">l2; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        dp[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">][i] </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> dp[</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">][i</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">] </span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000"> map[</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">'</span>
						<span style="COLOR: #000000">][s2[i</span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">]];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">l1; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><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">1</span>
						<span style="COLOR: #000000">; j</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">l2; j</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_875_1125_Open_Image" onclick="this.style.display='none'; Codehighlighter1_875_1125_Open_Text.style.display='none'; Codehighlighter1_875_1125_Closed_Image.style.display='inline'; Codehighlighter1_875_1125_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_875_1125_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_875_1125_Closed_Text.style.display='none'; Codehighlighter1_875_1125_Open_Image.style.display='inline'; Codehighlighter1_875_1125_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
						<span id="Codehighlighter1_875_1125_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_875_1125_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            dp[i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> dp[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> map[s1[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]][s2[j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (dp[i][j] </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> dp[i][j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> map[</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">][s2[j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> dp[i][j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> map[</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">][s2[j</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (dp[i][j] </span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000"> dp[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][j] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> map[s1[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]][</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                dp[i][j] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> dp[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][j] </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> map[s1[i</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">]][</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">'</span>
								<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> dp[l1][l2] </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> endl;<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<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 /><img id="Codehighlighter1_1180_1281_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1180_1281_Open_Text.style.display='none'; Codehighlighter1_1180_1281_Closed_Image.style.display='inline'; Codehighlighter1_1180_1281_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1180_1281_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1180_1281_Closed_Text.style.display='none'; Codehighlighter1_1180_1281_Open_Image.style.display='inline'; Codehighlighter1_1180_1281_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_1180_1281_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_1180_1281_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    initMap();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> caseTime;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cin </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> caseTime;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (caseTime</span>
						<span style="COLOR: #000000">--</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">!=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br /><img id="Codehighlighter1_1254_1268_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1254_1268_Open_Text.style.display='none'; Codehighlighter1_1254_1268_Closed_Image.style.display='inline'; Codehighlighter1_1254_1268_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1254_1268_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1254_1268_Closed_Text.style.display='none'; Codehighlighter1_1254_1268_Open_Image.style.display='inline'; Codehighlighter1_1254_1268_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_1254_1268_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_1254_1268_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        solve();<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/11528.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-08-21 15:47 <a href="http://www.cppblog.com/qywyh/articles/11528.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PKU2386--Lake Counting</title><link>http://www.cppblog.com/qywyh/articles/6525.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Mon, 01 May 2006 10:48:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/6525.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/6525.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/6525.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/6525.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/6525.html</trackback:ping><description><![CDATA[
		<p align="center">
				<font color="blue" size="5">Lake Counting</font>
				<br />Time Limit:1000MS  Memory Limit:65536K<br />Total Submit:1360 Accepted:629 </p>
		<p>
				<font color="blue" size="5">Description</font>
				<br />
				<font face="Times New Roman" size="3">Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 &lt;= N &lt;= 100; 1 &lt;= M &lt;= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John would like to figure out how many ponds have formed in his field. A pond is a connected set of squares with water in them, where a square is considered adjacent to all eight of its neighbors. <br /><br />Given a diagram of Farmer John's field, determine how many ponds he has.</font>
		</p>
		<p>
				<font color="blue" size="5">Input</font>
				<br />
				<font face="Times New Roman" size="3">* Line 1: Two space-separated integers: N and M <br /><br />* Lines 2..N+1: M characters per line representing one row of Farmer John's field. Each character is either 'W' or '.'. The characters do not have spaces between them.</font>
		</p>
		<p>
				<font color="blue" size="5">Output</font>
				<br />
				<font face="Times New Roman" size="3">* Line 1: The number of ponds in Farmer John's field.</font>
		</p>
		<p>
				<font color="blue" size="5">Sample Input</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Sample Output</font>
				<br />
				<font face="Times New Roman" size="3">
						<pre>3</pre>
				</font>
		</p>
		<p>
		</p>
		<p>
				<font color="blue" size="5">Hint</font>
				<br />
				<font face="Times New Roman" size="3">OUTPUT DETAILS: <br /><br />There are three ponds: one in the upper left, one in the lower left,and one along the right side.</font>
		</p>
		<p>
				<font color="blue" size="5">Source</font>
				<br />
				<font face="Times New Roman" size="3">USACO 2004 November<br /></font>
		</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">
				<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">iostream</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">using</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">namespace</span>
				<span style="COLOR: #000000"> std;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.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"> MAX </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">102</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> g[MAX][MAX];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> travel(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> j)<br /><img id="Codehighlighter1_107_370_Open_Image" onclick="this.style.display='none'; Codehighlighter1_107_370_Open_Text.style.display='none'; Codehighlighter1_107_370_Closed_Image.style.display='inline'; Codehighlighter1_107_370_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_107_370_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_107_370_Closed_Text.style.display='none'; Codehighlighter1_107_370_Open_Image.style.display='inline'; Codehighlighter1_107_370_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_107_370_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_107_370_Open_Text">
						<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_127_188_Open_Image" onclick="this.style.display='none'; Codehighlighter1_127_188_Open_Text.style.display='none'; Codehighlighter1_127_188_Closed_Image.style.display='inline'; Codehighlighter1_127_188_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_127_188_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_127_188_Closed_Text.style.display='none'; Codehighlighter1_127_188_Open_Image.style.display='inline'; Codehighlighter1_127_188_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> incr[</span>
						<span style="COLOR: #000000">8</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_127_188_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_127_188_Open_Text">
								<span style="COLOR: #000000">{</span>
								<span id="Codehighlighter1_128_133_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_128_133_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_136_141_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_136_141_Open_Text">
										<span style="COLOR: #000000">{</span>
										<span style="COLOR: #000000">1</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_144_148_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_144_148_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_151_155_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_151_155_Open_Text">
										<span style="COLOR: #000000">{</span>
										<span style="COLOR: #000000">1</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_158_162_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_158_162_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_165_170_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_165_170_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">1</span>
										<span style="COLOR: #000000">}</span>
								</span>
								<span style="COLOR: #000000">, </span>
								<span id="Codehighlighter1_173_178_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_173_178_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 id="Codehighlighter1_181_187_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_181_187_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">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">}</span>
								</span>
								<span style="COLOR: #000000">}</span>
						</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> k;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> tmpI, tmpJ;<br /><img id="Codehighlighter1_237_368_Open_Image" onclick="this.style.display='none'; Codehighlighter1_237_368_Open_Text.style.display='none'; Codehighlighter1_237_368_Closed_Image.style.display='inline'; Codehighlighter1_237_368_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_237_368_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_237_368_Closed_Text.style.display='none'; Codehighlighter1_237_368_Open_Image.style.display='inline'; Codehighlighter1_237_368_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">for</span>
						<span style="COLOR: #000000"> (k</span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">8</span>
						<span style="COLOR: #000000">; k</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_237_368_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_237_368_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        tmpI </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> i </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> incr[k][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        tmpJ </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> j </span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000"> incr[k][</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">];<br /><img id="Codehighlighter1_315_365_Open_Image" onclick="this.style.display='none'; Codehighlighter1_315_365_Open_Text.style.display='none'; Codehighlighter1_315_365_Closed_Image.style.display='inline'; Codehighlighter1_315_365_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_315_365_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_315_365_Closed_Text.style.display='none'; Codehighlighter1_315_365_Open_Image.style.display='inline'; Codehighlighter1_315_365_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (g[tmpI][tmpJ] </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_315_365_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_315_365_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            g[tmpI][tmpJ] </span>
										<span style="COLOR: #000000">=</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            travel(tmpI, tmpJ);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<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 /><img id="Codehighlighter1_384_876_Open_Image" onclick="this.style.display='none'; Codehighlighter1_384_876_Open_Text.style.display='none'; Codehighlighter1_384_876_Closed_Image.style.display='inline'; Codehighlighter1_384_876_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_384_876_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_384_876_Closed_Text.style.display='none'; Codehighlighter1_384_876_Open_Image.style.display='inline'; Codehighlighter1_384_876_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_384_876_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_384_876_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> n, m;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000"> i, j;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">int</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 /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> t;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cin </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> n </span>
						<span style="COLOR: #000000">&gt;&gt;</span>
						<span style="COLOR: #000000"> m;<br /><img id="Codehighlighter1_471_508_Open_Image" onclick="this.style.display='none'; Codehighlighter1_471_508_Open_Text.style.display='none'; Codehighlighter1_471_508_Closed_Image.style.display='inline'; Codehighlighter1_471_508_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_471_508_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_471_508_Closed_Text.style.display='none'; Codehighlighter1_471_508_Open_Image.style.display='inline'; Codehighlighter1_471_508_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">m</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_471_508_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_471_508_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        g[</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">][i] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        g[n</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">][i] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_534_571_Open_Image" onclick="this.style.display='none'; Codehighlighter1_534_571_Open_Text.style.display='none'; Codehighlighter1_534_571_Closed_Image.style.display='inline'; Codehighlighter1_534_571_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_534_571_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_534_571_Closed_Text.style.display='none'; Codehighlighter1_534_571_Open_Image.style.display='inline'; Codehighlighter1_534_571_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">n</span>
						<span style="COLOR: #000000">+</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_534_571_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_534_571_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        g[i][</span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        g[i][m</span>
								<span style="COLOR: #000000">+</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">] </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_595_710_Open_Image" onclick="this.style.display='none'; Codehighlighter1_595_710_Open_Text.style.display='none'; Codehighlighter1_595_710_Closed_Image.style.display='inline'; Codehighlighter1_595_710_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_595_710_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_595_710_Closed_Text.style.display='none'; Codehighlighter1_595_710_Open_Image.style.display='inline'; Codehighlighter1_595_710_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_595_710_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_595_710_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_620_707_Open_Image" onclick="this.style.display='none'; Codehighlighter1_620_707_Open_Text.style.display='none'; Codehighlighter1_620_707_Closed_Image.style.display='inline'; Codehighlighter1_620_707_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_620_707_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_620_707_Closed_Text.style.display='none'; Codehighlighter1_620_707_Open_Image.style.display='inline'; Codehighlighter1_620_707_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">m; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_620_707_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_620_707_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />            cin </span>
										<span style="COLOR: #000000">&gt;&gt;</span>
										<span style="COLOR: #000000"> t;<br /><img id="Codehighlighter1_652_674_Open_Image" onclick="this.style.display='none'; Codehighlighter1_652_674_Open_Text.style.display='none'; Codehighlighter1_652_674_Closed_Image.style.display='inline'; Codehighlighter1_652_674_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_652_674_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_652_674_Closed_Text.style.display='none'; Codehighlighter1_652_674_Open_Image.style.display='inline'; Codehighlighter1_652_674_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (t </span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">'</span>
										<span style="COLOR: #000000">W</span>
										<span style="COLOR: #000000">'</span>
										<span style="COLOR: #000000">) </span>
										<span id="Codehighlighter1_652_674_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_652_674_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                g[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_681_703_Open_Image" onclick="this.style.display='none'; Codehighlighter1_681_703_Open_Text.style.display='none'; Codehighlighter1_681_703_Closed_Image.style.display='inline'; Codehighlighter1_681_703_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_681_703_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_681_703_Closed_Text.style.display='none'; Codehighlighter1_681_703_Open_Image.style.display='inline'; Codehighlighter1_681_703_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">else</span>
										<span style="COLOR: #000000"> </span>
										<span id="Codehighlighter1_681_703_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_681_703_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                g[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">0</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_734_841_Open_Image" onclick="this.style.display='none'; Codehighlighter1_734_841_Open_Text.style.display='none'; Codehighlighter1_734_841_Closed_Image.style.display='inline'; Codehighlighter1_734_841_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_734_841_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_734_841_Closed_Text.style.display='none'; Codehighlighter1_734_841_Open_Image.style.display='inline'; Codehighlighter1_734_841_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
						<span style="COLOR: #000000">; i</span>
						<span style="COLOR: #000000">&lt;=</span>
						<span style="COLOR: #000000">n; i</span>
						<span style="COLOR: #000000">++</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_734_841_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_734_841_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_759_838_Open_Image" onclick="this.style.display='none'; Codehighlighter1_759_838_Open_Text.style.display='none'; Codehighlighter1_759_838_Closed_Image.style.display='inline'; Codehighlighter1_759_838_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_759_838_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_759_838_Closed_Text.style.display='none'; Codehighlighter1_759_838_Open_Image.style.display='inline'; Codehighlighter1_759_838_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.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">1</span>
								<span style="COLOR: #000000">; j</span>
								<span style="COLOR: #000000">&lt;=</span>
								<span style="COLOR: #000000">m; j</span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">) </span>
								<span id="Codehighlighter1_759_838_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_759_838_Open_Text">
										<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_782_834_Open_Image" onclick="this.style.display='none'; Codehighlighter1_782_834_Open_Text.style.display='none'; Codehighlighter1_782_834_Closed_Image.style.display='inline'; Codehighlighter1_782_834_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_782_834_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_782_834_Closed_Text.style.display='none'; Codehighlighter1_782_834_Open_Image.style.display='inline'; Codehighlighter1_782_834_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (g[i][j] </span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">) </span>
										<span id="Codehighlighter1_782_834_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_782_834_Open_Text">
												<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                ans</span>
												<span style="COLOR: #000000">++</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                g[i][j] </span>
												<span style="COLOR: #000000">=</span>
												<span style="COLOR: #000000"> </span>
												<span style="COLOR: #000000">-</span>
												<span style="COLOR: #000000">1</span>
												<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                travel(i, j);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span>
										</span>
										<span style="COLOR: #000000">
												<br />
												<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    cout </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> ans </span>
						<span style="COLOR: #000000">&lt;&lt;</span>
						<span style="COLOR: #000000"> endl;<br /><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 /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>感受递归的神奇!<img src ="http://www.cppblog.com/qywyh/aggbug/6525.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2006-05-01 18:48 <a href="http://www.cppblog.com/qywyh/articles/6525.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>