锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久成人精品电影,国产精品久久久久久久久搜平片 ,嫩草影视亚洲http://www.shnenglu.com/Icyflame/category/10975.html瀛︿範綆楁硶zh-cnSun, 05 Jul 2009 14:05:13 GMTSun, 05 Jul 2009 14:05:13 GMT60POJ 3352 妗?/title><link>http://www.shnenglu.com/Icyflame/archive/2009/07/05/89289.html</link><dc:creator>Icyflame</dc:creator><author>Icyflame</author><pubDate>Sun, 05 Jul 2009 08:08:00 GMT</pubDate><guid>http://www.shnenglu.com/Icyflame/archive/2009/07/05/89289.html</guid><wfw:comment>http://www.shnenglu.com/Icyflame/comments/89289.html</wfw:comment><comments>http://www.shnenglu.com/Icyflame/archive/2009/07/05/89289.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icyflame/comments/commentRss/89289.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icyflame/services/trackbacks/89289.html</trackback:ping><description><![CDATA[<p>涓銆侀鐩弿榪?br></p> <p class=pst>Description</p> <div id="hvzpftn" class=ptx lang=en-US> <div> <p>It's almost summer time, and that means that it's almost summer construction time! This year, the good people who are in charge of the roads on the tropical island paradise of Remote Island would like to repair and upgrade the various roads that lead between the various tourist attractions on the island.</p> <p>The roads themselves are also rather interesting. Due to the strange customs of the island, the roads are arranged so that they never meet at intersections, but rather pass over or under each other using bridges and tunnels. In this way, each road runs between two specific tourist attractions, so that the tourists do not become irreparably lost.</p> <p>Unfortunately, given the nature of the repairs and upgrades needed on each road, when the construction company works on a particular road, it is unusable in either direction. This could cause a problem if it becomes impossible to travel between two tourist attractions, even if the construction company works on only one road at any particular time.</p> <p>So, the Road Department of Remote Island has decided to call upon your consulting services to help remedy this problem. It has been decided that new roads will have to be built between the various attractions in such a way that in the final configuration, if any one road is undergoing construction, it would still be possible to travel between any two tourist attractions using the remaining roads. Your task is to find the minimum number of new roads necessary.</p> </div> </div> <p class=pst>Input</p> <div id="hvzpftn" class=ptx lang=en-US> <p>The first line of input will consist of positive integers <em>n</em> and <em>r</em>, separated by a space, where 3 ≤ <em>n</em> ≤ 1000 is the number of tourist attractions on the island, and 2 ≤ <em>r</em> ≤ 1000 is the number of roads. The tourist attractions are conveniently labelled from 1 to <em>n</em>. Each of the following <em>r</em> lines will consist of two integers, <em>v</em> and <em>w</em>, separated by a space, indicating that a road exists between the attractions labelled <em>v</em> and <em>w</em>. Note that you may travel in either direction down each road, and any pair of tourist attractions will have at most one road directly between them. Also, you are assured that in the current configuration, it is possible to travel between any two tourist attractions.</p> </div> <p class=pst>Output</p> <div id="hvzpftn" class=ptx lang=en-US> <p>One line, consisting of an integer, which gives the minimum number of roads that we need to add.</p> </div> <p class=pst>Sample Input</p> <pre class=sio>Sample Input 1 10 12 1 2 1 3 1 4 2 5 2 6 5 6 3 7 3 8 7 8 4 9 4 10 9 10 Sample Input 2 3 3 1 2 2 3 1 3</pre> <p class=pst>Sample Output</p> <pre class=sio>Output for Sample Input 1 2 Output for Sample Input 2 0 </pre> <p><br>浜屻佸垎鏋?br><span style="FONT-SIZE: 10pt">      鐢―FS瑙e喅闂錛岃緇嗙畻娉曪細<a title=鍓茬偣銆佹ˉ涓庡弻榪為氬垎鏀?href="http://www.shnenglu.com/Icyflame/archive/2009/07/04/89227.html">鍓茬偣涓庢ˉ</a>銆?/span><br>涓夈佷唬鐮?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"><span style="COLOR: #008080"> 1</span><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">list</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> n, r;<br></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>list</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> g[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num, lab[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">], low[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>list</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">pair</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> edge;<br></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> degree[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> parent[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">], rank[</span><span style="COLOR: #000000">1001</span><span style="COLOR: #000000">];<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> init_set()<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img id=Codehighlighter1_207_274_Open_Image onclick="this.style.display='none'; Codehighlighter1_207_274_Open_Text.style.display='none'; Codehighlighter1_207_274_Closed_Image.style.display='inline'; Codehighlighter1_207_274_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_207_274_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_207_274_Closed_Text.style.display='none'; Codehighlighter1_207_274_Open_Image.style.display='inline'; Codehighlighter1_207_274_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_207_274_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_207_274_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</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">1001</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img id=Codehighlighter1_237_272_Open_Image onclick="this.style.display='none'; Codehighlighter1_237_272_Open_Text.style.display='none'; Codehighlighter1_237_272_Closed_Image.style.display='inline'; Codehighlighter1_237_272_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_237_272_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_237_272_Closed_Text.style.display='none'; Codehighlighter1_237_272_Open_Image.style.display='inline'; Codehighlighter1_237_272_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_237_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_237_272_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        parent[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> i;<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        rank[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> find(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> k)<br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img id=Codehighlighter1_292_371_Open_Image onclick="this.style.display='none'; Codehighlighter1_292_371_Open_Text.style.display='none'; Codehighlighter1_292_371_Closed_Image.style.display='inline'; Codehighlighter1_292_371_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_292_371_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_292_371_Closed_Text.style.display='none'; Codehighlighter1_292_371_Open_Image.style.display='inline'; Codehighlighter1_292_371_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_292_371_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_292_371_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">20</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(parent[k] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> k) <br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> k;<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> parent[k] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> find(parent[k]);<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> union_set(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> u, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> v)<br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img id=Codehighlighter1_402_555_Open_Image onclick="this.style.display='none'; Codehighlighter1_402_555_Open_Text.style.display='none'; Codehighlighter1_402_555_Closed_Image.style.display='inline'; Codehighlighter1_402_555_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_402_555_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_402_555_Closed_Text.style.display='none'; Codehighlighter1_402_555_Open_Image.style.display='inline'; Codehighlighter1_402_555_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_402_555_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_402_555_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> pu </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> find(u), pv </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> find(v);<br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(rank[pu] </span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000"> rank[pv])<br></span><span style="COLOR: #008080">29</span><span style="COLOR: #000000"><img id=Codehighlighter1_464_504_Open_Image onclick="this.style.display='none'; Codehighlighter1_464_504_Open_Text.style.display='none'; Codehighlighter1_464_504_Closed_Image.style.display='inline'; Codehighlighter1_464_504_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_464_504_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_464_504_Closed_Text.style.display='none'; Codehighlighter1_464_504_Open_Image.style.display='inline'; Codehighlighter1_464_504_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_464_504_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_464_504_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">30</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        parent[pu] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pv;<br></span><span style="COLOR: #008080">31</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        rank[pv] </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pu;<br></span><span style="COLOR: #008080">32</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">33</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">34</span><span style="COLOR: #000000"><img id=Codehighlighter1_513_553_Open_Image onclick="this.style.display='none'; Codehighlighter1_513_553_Open_Text.style.display='none'; Codehighlighter1_513_553_Closed_Image.style.display='inline'; Codehighlighter1_513_553_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_513_553_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_513_553_Closed_Text.style.display='none'; Codehighlighter1_513_553_Open_Image.style.display='inline'; Codehighlighter1_513_553_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_513_553_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_513_553_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">35</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        parent[pv] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pu;<br></span><span style="COLOR: #008080">36</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        rank[pu] </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> pv;<br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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"> u, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> p)<br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img id=Codehighlighter1_580_926_Open_Image onclick="this.style.display='none'; Codehighlighter1_580_926_Open_Text.style.display='none'; Codehighlighter1_580_926_Closed_Image.style.display='inline'; Codehighlighter1_580_926_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_580_926_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_580_926_Closed_Text.style.display='none'; Codehighlighter1_580_926_Open_Image.style.display='inline'; Codehighlighter1_580_926_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_580_926_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_580_926_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    lab[u] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> low[u] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> num</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">42</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    list</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::iterator it;<br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(it </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> g[u].begin(); it </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> g[u].end(); it</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img id=Codehighlighter1_682_924_Open_Image onclick="this.style.display='none'; Codehighlighter1_682_924_Open_Text.style.display='none'; Codehighlighter1_682_924_Closed_Image.style.display='inline'; Codehighlighter1_682_924_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_682_924_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_682_924_Closed_Text.style.display='none'; Codehighlighter1_682_924_Open_Image.style.display='inline'; Codehighlighter1_682_924_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_682_924_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_682_924_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">int</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">it;<br></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(lab[v] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img id=Codehighlighter1_719_870_Open_Image onclick="this.style.display='none'; Codehighlighter1_719_870_Open_Text.style.display='none'; Codehighlighter1_719_870_Closed_Image.style.display='inline'; Codehighlighter1_719_870_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_719_870_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_719_870_Closed_Text.style.display='none'; Codehighlighter1_719_870_Open_Image.style.display='inline'; Codehighlighter1_719_870_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </span><span id=Codehighlighter1_719_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_719_870_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">48</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            dfs(v, u);<br></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            low[u] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> min(low[u], low[v]);<br></span><span style="COLOR: #008080">50</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(low[v] </span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> lab[u])<br></span><span style="COLOR: #008080">51</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                edge.push_back(make_pair(u, v));<br></span><span style="COLOR: #008080">52</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            </span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">53</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                union_set(u, v); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">u涓巚鑳借繘琛岀緝鐐?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">54</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></span><span style="COLOR: #000000">        }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">55</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.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">(v </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> p)<br></span><span style="COLOR: #008080">56</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            low[u] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> min(low[u], lab[v]);<br></span><span style="COLOR: #008080">57</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">58</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">59</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br></span><span style="COLOR: #008080">60</span><span style="COLOR: #000000"><img id=Codehighlighter1_939_1628_Open_Image onclick="this.style.display='none'; Codehighlighter1_939_1628_Open_Text.style.display='none'; Codehighlighter1_939_1628_Closed_Image.style.display='inline'; Codehighlighter1_939_1628_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_939_1628_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_939_1628_Closed_Text.style.display='none'; Codehighlighter1_939_1628_Open_Image.style.display='inline'; Codehighlighter1_939_1628_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_939_1628_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_939_1628_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">61</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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">&</span><span style="COLOR: #000000">n, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">r);<br></span><span style="COLOR: #008080">62</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</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">n; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">63</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        g[i].clear();<br></span><span style="COLOR: #008080">64</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</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">r; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">65</span><span style="COLOR: #000000"><img id=Codehighlighter1_1032_1122_Open_Image onclick="this.style.display='none'; Codehighlighter1_1032_1122_Open_Text.style.display='none'; Codehighlighter1_1032_1122_Closed_Image.style.display='inline'; Codehighlighter1_1032_1122_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1032_1122_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1032_1122_Closed_Text.style.display='none'; Codehighlighter1_1032_1122_Open_Image.style.display='inline'; Codehighlighter1_1032_1122_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1032_1122_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1032_1122_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">66</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> v1, v2;<br></span><span style="COLOR: #008080">67</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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">&</span><span style="COLOR: #000000">v1, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">v2);<br></span><span style="COLOR: #008080">68</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        g[v1].push_back(v2);<br></span><span style="COLOR: #008080">69</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        g[v2].push_back(v1);<br></span><span style="COLOR: #008080">70</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">71</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    memset(lab, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> lab);<br></span><span style="COLOR: #008080">72</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    memset(low, </span><span style="COLOR: #000000">0x7f</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> low);<br></span><span style="COLOR: #008080">73</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">74</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    init_set();<br></span><span style="COLOR: #008080">75</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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></span><span style="COLOR: #008080">76</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    memset(degree, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000"> degree);<br></span><span style="COLOR: #008080">77</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    list</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">pair</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">></span><span style="COLOR: #000000">::iterator it;<br></span><span style="COLOR: #008080">78</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> res </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">79</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(it </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> edge.begin(); it </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> edge.end(); it</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">80</span><span style="COLOR: #000000"><img id=Codehighlighter1_1355_1595_Open_Image onclick="this.style.display='none'; Codehighlighter1_1355_1595_Open_Text.style.display='none'; Codehighlighter1_1355_1595_Closed_Image.style.display='inline'; Codehighlighter1_1355_1595_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1355_1595_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1355_1595_Closed_Text.style.display='none'; Codehighlighter1_1355_1595_Open_Image.style.display='inline'; Codehighlighter1_1355_1595_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1355_1595_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.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1355_1595_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">81</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> u </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> it</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">first, v </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> it</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">second;<br></span><span style="COLOR: #008080">82</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        degree[find(u)]</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">83</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(degree[find(u)] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">84</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            res</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">85</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.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">(degree[find(u)] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">86</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            res</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">87</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        degree[find(v)]</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">88</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(degree[find(v)] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">89</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            res</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">90</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.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">(degree[find(v)] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #008080">91</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            res</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">92</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">93</span><span style="COLOR: #000000"><img src="http://www.shnenglu.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">, (res</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">2</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">94</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div> <img src ="http://www.shnenglu.com/Icyflame/aggbug/89289.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icyflame/" target="_blank">Icyflame</a> 2009-07-05 16:08 <a href="http://www.shnenglu.com/Icyflame/archive/2009/07/05/89289.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>POJ 1523 鍓茬偣http://www.shnenglu.com/Icyflame/archive/2009/07/04/89231.htmlIcyflameIcyflameSat, 04 Jul 2009 08:12:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/07/04/89231.htmlhttp://www.shnenglu.com/Icyflame/comments/89231.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/07/04/89231.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/89231.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/89231.html涓銆侀鐩弿榪?span style="FONT-SIZE: 10pt">

Description

Consider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis, a failure of a single node, 3, in the network on the left would prevent some of the still available nodes from communicating with each other. Nodes 1 and 2 could still communicate with each other as could nodes 4 and 5, but communication between any other pairs of nodes would no longer be possible.

Node 3 is therefore a Single Point of Failure (SPF) for this network. Strictly, an SPF will be defined as any node that, if unavailable, would prevent at least one pair of available nodes from being able to communicate on what was previously a fully connected network. Note that the network on the right has no such node; there is no SPF in the network. At least two machines must fail before there are any pairs of available nodes which cannot communicate.

Input

The input will contain the description of several networks. A network description will consist of pairs of integers, one pair per line, that identify connected nodes. Ordering of the pairs is irrelevant; 1 2 and 2 1 specify the same connection. All node numbers will range from 1 to 1000. A line containing a single zero ends the list of connected nodes. An empty network description flags the end of the input. Blank lines in the input file should be ignored.

Output

For each network in the input, you will output its number in the file, followed by a list of any SPF nodes that exist.

The first network in the file should be identified as "Network #1", the second as "Network #2", etc. For each SPF node, output a line, formatted as shown in the examples below, that identifies the node and the number of fully connected subnets that remain when that node fails. If the network has no SPF nodes, simply output the text "No SPF nodes" instead of a list of SPF nodes.

Sample Input

1 2
5 4
3 1
3 2
3 4
3 5
0
1 2
2 3
3 4
4 5
5 1
0
1 2
2 3
3 4
4 6
6 3
2 5
5 1
0
0

Sample Output

Network #1
SPF node 3 leaves 2 subnets
Network #2
No SPF nodes
Network #3
SPF node 2 leaves 2 subnets
SPF node 3 leaves 2 subnets


浜屻佸垎鏋?br>      鐢―FS瑙e喅闂錛岃緇嗙畻娉曪細鍓茬偣涓庢ˉ銆?/span>
涓夈佷唬鐮?br>

 1#include<iostream>
 2#include<list>
 3using namespace std;
 4int t;
 5int v1, v2;
 6list<int> g[1001];
 7bool flag;
 8int root;
 9int counter;
10bool spf[1001];
11int low[1001], lab[1001];
12bool visit[1001];
13void dfs(int u, int fa)
14{
15    low[u] = lab[u] = counter++;
16    list<int>::iterator it;
17    int counter = 0;
18    for(it = g[u].begin(); it != g[u].end(); it++)
19    {
20        int v = *it;
21        if(!lab[v])
22        {
23            counter++;
24            dfs(v, u);
25            low[u] = min(low[u], low[v]);
26            if((u==root && counter>=2|| (u!=root && low[v]>=lab[u]))
27                spf[u] = flag = true;
28        }

29        else if(v != fa)
30            low[u] = min(low[u], lab[v]);
31    }

32}

33void find(int u)
34{
35    visit[u] = true;
36    list<int>::iterator it;
37    for(it = g[u].begin(); it != g[u].end(); it++)
38        if(!visit[*it])
39            find(*it);
40}

41int main()
42{
43    t = 1;
44    while(1)
45    {
46        scanf("%d"&v1);
47        if(v1 == 0break;
48        for(int i=1; i<=1000; i++)
49            g[i].clear();
50        memset(spf, 0sizeof spf);
51        memset(low, 0sizeof low);
52        memset(lab, 0sizeof lab);
53        while(v1 != 0)
54        {
55            scanf("%d"&v2);
56            g[v1].push_back(v2);
57            g[v2].push_back(v1);
58            root = v1;
59            scanf("%d"&v1);
60        }

61        counter = 1;
62        flag = false;
63        dfs(root, -1);
64        printf("Network #%d\n", t++);
65        if(flag)
66        {
67            for(int i=1; i<=1000; i++)
68            {
69                if(!spf[i]) continue;
70                int cnt = 0;
71                memset(visit, 0sizeof visit);
72                visit[i] = true;
73                list<int>::iterator it;
74                for(it = g[i].begin(); it != g[i].end(); it++)
75                    if(!visit[*it])
76                    {
77                        cnt++;
78                        find(*it);
79                    }

80                    printf("  SPF node %d leaves %d subnets\n", i, cnt);
81            }

82        }

83        else
84            printf("  No SPF nodes\n");
85        printf("\n");
86    }

87}


Icyflame 2009-07-04 16:12 鍙戣〃璇勮
]]>
HDOJ 2586 LCA:Tarjanhttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89118.htmlIcyflameIcyflameThu, 02 Jul 2009 14:39:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89118.htmlhttp://www.shnenglu.com/Icyflame/comments/89118.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89118.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/89118.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/89118.html涓銆侀鐩弿榪?br>

Problem Description
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to answer. But luckily int this village the answer is always unique, since the roads are built in the way that there is a unique simple path("simple" means you can't visit a place twice) between every two houses. Yout task is to answer all these curious people.
 


 

Input
First line is a single integer T(T<=10), indicating the number of test cases.
  For each test case,in the first line there are two numbers n(2<=n<=40000) and m (1<=m<=200),the number of houses and the number of queries. The following n-1 lines each consisting three numbers i,j,k, separated bu a single space, meaning that there is a road connecting house i and house j,with length k(0<k<=40000).The houses are labeled from 1 to n.
  Next m lines each has distinct integers i and j, you areato answer the distance between house i and house j.
 


 

Output
For each test case,output m lines. Each line represents the answer of the query. Output a bland line after each test case.
 


 

Sample Input
2
3 2
1 2 10
3 1 15
1 2
2 3
2 2
1 2 100
1 2
2 1
 


 

Sample Output
10
25
100
100


浜屻佸垎鏋?br>      鐢═arjan瑙e喅鐨凩CA闂錛岃緇嗙畻娉曪細LCA闂銆?/span>
涓夈佷唬鐮?/p>

 1#include<iostream>
 2#include<list>
 3using namespace std;
 4struct node
 5{
 6    int v, d;
 7    void init(int vv, int dd) {v = vv; d = dd;}
 8}
;
 9int t, n, m, v1, v2, len;
10list<node> g[40001];
11list<node> query[40001];
12int dis[40001];
13int res[201][3];
14int parent[40001];
15bool visit[40001];
16int find(int k)
17{
18    if(parent[k] == k)
19        return k;
20    return parent[k] = find(parent[k]);
21}

22void tarjan(int u)
23{
24    if(visit[u]) return;
25    visit[u] = true;
26    parent[u] = u;
27    list<node>::iterator it = query[u].begin();
28    while(it != query[u].end())
29    {
30        if(visit[it->v])
31            res[it->d][2= find(it->v);
32        it++;
33    }

34    it = g[u].begin();
35    while(it != g[u].end())
36    {
37        if(!visit[it->v])
38        {
39            dis[it->v] = min(dis[it->v], dis[u] + it->d);
40            tarjan(it->v);
41            parent[it->v] = u;
42        }

43        it++;
44    }

45}

46int main()
47{
48    scanf("%d"&t);
49    while(t--)
50    {
51        scanf("%d%d"&n, &m);
52        for(int i=1; i<=n; i++)
53            g[i].clear();
54        for(int i=1; i<=m; i++)
55            query[i].clear();
56        for(int i=1; i<n; i++)
57        {
58            scanf("%d%d%d"&v1, &v2, &len);
59            node n1; n1.init(v2, len);
60            g[v1].push_back(n1);
61            node n2; n2.init(v1, len);
62            g[v2].push_back(n2);
63        }

64        for(int i=1; i<=m; i++)
65        {
66            scanf("%d%d"&v1, &v2);
67            res[i][0= v1;
68            res[i][1= v2;
69            node n1; n1.init(v2, i);
70            query[v1].push_back(n1);
71            node n2; n2.init(v1, i);
72            query[v2].push_back(n2);
73        }

74        memset(visit, 0sizeof(visit));
75        memset(dis, 0x7fsizeof(dis));
76        dis[1= 0;
77        tarjan(1);
78        for(int i=1; i<=m; i++)
79            printf("%d\n", dis[res[i][0]] + dis[res[i][1]] - 2*dis[res[i][2]]);
80    }

81}


Icyflame 2009-07-02 22:39 鍙戣〃璇勮
]]>
ZOJ 3195 LCA:RMQhttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89107.htmlIcyflameIcyflameThu, 02 Jul 2009 12:55:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89107.htmlhttp://www.shnenglu.com/Icyflame/comments/89107.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/07/02/89107.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/89107.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/89107.html闃呰鍏ㄦ枃

Icyflame 2009-07-02 20:55 鍙戣〃璇勮
]]>
POJ 3368 RMQhttp://www.shnenglu.com/Icyflame/archive/2009/07/01/88999.htmlIcyflameIcyflameWed, 01 Jul 2009 08:24:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/07/01/88999.htmlhttp://www.shnenglu.com/Icyflame/comments/88999.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/07/01/88999.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/88999.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/88999.html闃呰鍏ㄦ枃

Icyflame 2009-07-01 16:24 鍙戣〃璇勮
]]>
POJ 2516 鏈灝忚垂鐢ㄦ渶澶ф祦http://www.shnenglu.com/Icyflame/archive/2009/06/30/88941.htmlIcyflameIcyflameTue, 30 Jun 2009 14:09:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/06/30/88941.htmlhttp://www.shnenglu.com/Icyflame/comments/88941.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/06/30/88941.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/88941.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/88941.html闃呰鍏ㄦ枃

Icyflame 2009-06-30 22:09 鍙戣〃璇勮
]]>
POJ 2195 鏈浼樺尮閰?/title><link>http://www.shnenglu.com/Icyflame/archive/2009/06/29/88773.html</link><dc:creator>Icyflame</dc:creator><author>Icyflame</author><pubDate>Mon, 29 Jun 2009 06:42:00 GMT</pubDate><guid>http://www.shnenglu.com/Icyflame/archive/2009/06/29/88773.html</guid><wfw:comment>http://www.shnenglu.com/Icyflame/comments/88773.html</wfw:comment><comments>http://www.shnenglu.com/Icyflame/archive/2009/06/29/88773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icyflame/comments/commentRss/88773.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icyflame/services/trackbacks/88773.html</trackback:ping><description><![CDATA[     鎽樿: 涓銆侀鐩弿榪?Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each l...  <a href='http://www.shnenglu.com/Icyflame/archive/2009/06/29/88773.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Icyflame/aggbug/88773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icyflame/" target="_blank">Icyflame</a> 2009-06-29 14:42 <a href="http://www.shnenglu.com/Icyflame/archive/2009/06/29/88773.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>POJ 1149 鏈澶ф祦http://www.shnenglu.com/Icyflame/archive/2009/06/26/88584.htmlIcyflameIcyflameFri, 26 Jun 2009 08:15:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/06/26/88584.htmlhttp://www.shnenglu.com/Icyflame/comments/88584.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/06/26/88584.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/88584.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/88584.html闃呰鍏ㄦ枃

Icyflame 2009-06-26 16:15 鍙戣〃璇勮
]]>
POJ 1459 鏈澶ф祦http://www.shnenglu.com/Icyflame/archive/2009/06/24/88448.htmlIcyflameIcyflameWed, 24 Jun 2009 11:38:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/06/24/88448.htmlhttp://www.shnenglu.com/Icyflame/comments/88448.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/06/24/88448.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/88448.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/88448.html涓銆侀鐩弿榪?br>

Description

A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amount 0 <= p(u) <= pmax(u) of power, may consume an amount 0 <= c(u) <= min(s(u),cmax(u)) of power, and may deliver an amount d(u)=s(u)+p(u)-c(u) of power. The following restrictions apply: c(u)=0 for any power station, p(u)=0 for any consumer, and p(u)=c(u)=0 for any dispatcher. There is at most one power transport line (u,v) from a node u to a node v in the net; it transports an amount 0 <= l(u,v) <= lmax(u,v) of power delivered by u to v. Let Con=Σuc(u) be the power consumed in the net. The problem is to compute the maximum value of Con.

An example is in figure 1. The label x/y of power station u shows that p(u)=x and pmax(u)=y. The label x/y of consumer u shows that c(u)=x and cmax(u)=y. The label x/y of power transport line (u,v) shows that l(u,v)=x and lmax(u,v)=y. The power consumed is Con=6. Notice that there are other possible states of the network but the value of Con cannot exceed 6.

Input

There are several data sets in the input. Each data set encodes a power network. It starts with four integers: 0 <= n <= 100 (nodes), 0 <= np <= n (power stations), 0 <= nc <= n (consumers), and 0 <= m <= n^2 (power transport lines). Follow m data triplets (u,v)z, where u and v are node identifiers (starting from 0) and 0 <= z <= 1000 is the value of lmax(u,v). Follow np doublets (u)z, where u is the identifier of a power station and 0 <= z <= 10000 is the value of pmax(u). The data set ends with nc doublets (u)z, where u is the identifier of a consumer and 0 <= z <= 10000 is the value of cmax(u). All input numbers are integers. Except the (u,v)z triplets and the (u)z doublets, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct.

Output

For each data set from the input, the program prints on the standard output the maximum amount of power that can be consumed in the corresponding network. Each result has an integral value and is printed from the beginning of a separate line.

Sample Input

2 1 1 2 (0,1)20 (1,0)10 (0)15 (1)20
7 2 3 13 (0,0)1 (0,1)2 (0,2)5 (1,0)1 (1,2)8 (2,3)1 (2,4)7
(3,5)2 (3,6)5 (4,2)7 (4,3)5 (4,5)1 (6,0)5
(0)5 (1)2 (3)2 (4)1 (5)4

Sample Output

15
6


浜屻佸垎鏋?br>      澧炲姞鐐筺涓簊錛岀偣n+1涓簍錛屾眰鏈澶ф祦錛屼嬌鐢≒ush-Relabel綆楁硶錛屽叿浣撶畻娉曪細鏈澶ф祦闂
涓夈佷唬鐮?/strong>

 1#include<iostream>
 2using namespace std;
 3#define MAXN 202
 4int s, t;
 5int n, np, nc, m;
 6char str[50];
 7int c[MAXN][MAXN];
 8int f[MAXN][MAXN];
 9int e[MAXN];
10int h[MAXN];
11void push(int u, int v)
12{
13    int d = min(e[u], c[u][v] - f[u][v]);
14    f[u][v] += d;
15    f[v][u] = -f[u][v];
16    e[u] -= d;
17    e[v] += d;
18}

19bool relabel(int u)
20{
21    int mh = INT_MAX;
22    for(int i=0; i<n+2; i++)
23    {
24        if(c[u][i] > f[u][i])
25            mh = min(mh, h[i]);
26    }

27    if(mh == INT_MAX)
28        return false//孌嬬暀緗戠粶涓棤浠巙鍑哄彂鐨勮礬
29    h[u] = mh + 1;
30    for(int i=0; i<n+2; i++)
31    {
32        if(e[u] == 0//宸叉棤浣欐祦錛屼笉闇鍐嶆push
33            break;
34        if(h[i] == mh && c[u][i] > f[u][i]) //push鐨勬潯浠?/span>
35            push(u, i);
36    }

37    return true;
38}

39void init_preflow()
40{
41    memset(h, 0sizeof(h));
42    memset(e, 0sizeof(e));
43    h[s] = n+2;
44    for(int i=0; i<n+2; i++)
45    {
46        if(c[s][i] == 0)
47            continue;
48        f[s][i] = c[s][i];
49        f[i][s] = -f[s][i];
50        e[i] = c[s][i];
51        e[s] -= c[s][i];
52    }

53}

54void push_relabel()
55{
56    init_preflow();
57    bool flag = true//琛ㄧず鏄惁榪樻湁relabel鎿嶄綔
58    while(flag)
59    {
60        flag = false;
61        for(int i=0; i<n; i++)
62            if(e[i] > 0)
63                flag = flag || relabel(i);
64    }

65}

66int main()
67{
68    while(scanf("%d%d%d%d"&n, &np, &nc, &m) != EOF)
69    {
70        s = n; t = n+1;
71        memset(c, 0sizeof(c));
72        memset(f, 0sizeof(f));
73        while(m--)
74        {
75            scanf("%s"&str);
76            int u=0, v=0, z=0;
77            sscanf(str, "(%d,%d)%d"&u, &v, &z);
78            c[u][v] = z;
79        }

80        for(int i=0; i<np+nc; i++)
81        {
82            scanf("%s"&str);
83            int u=0, z=0;
84            sscanf(str, "(%d)%d"&u, &z);
85            if(i < np)
86                c[s][u] = z;
87            else if(i >= np && i < np + nc)
88                c[u][t] = z;
89        }

90        push_relabel();
91        printf("%d\n", e[t]);
92    }

93}


Icyflame 2009-06-24 19:38 鍙戣〃璇勮
]]>
POJ 1273 鏈澶ф祦http://www.shnenglu.com/Icyflame/archive/2009/06/23/88383.htmlIcyflameIcyflameTue, 23 Jun 2009 11:38:00 GMThttp://www.shnenglu.com/Icyflame/archive/2009/06/23/88383.htmlhttp://www.shnenglu.com/Icyflame/comments/88383.htmlhttp://www.shnenglu.com/Icyflame/archive/2009/06/23/88383.html#Feedback0http://www.shnenglu.com/Icyflame/comments/commentRss/88383.htmlhttp://www.shnenglu.com/Icyflame/services/trackbacks/88383.html涓銆侀鐩弿榪?/strong>

Description

Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover patch is never covered in water. Instead, the water is drained to a nearby stream. Being an ace engineer, Farmer John has also installed regulators at the beginning of each ditch, so he can control at what rate water flows into that ditch.
Farmer John knows not only how many gallons of water each ditch can transport per minute but also the exact layout of the ditches, which feed out of the pond and into each other and stream in a potentially complex network.
Given all this information, determine the maximum rate at which water can be transported out of the pond and into the stream. For any given ditch, water flows in only one direction, but there might be a way that water can flow in a circle.

Input

The input includes several cases. For each case, the first line contains two space-separated integers, N (0 <= N <= 200) and M (2 <= M <= 200). N is the number of ditches that Farmer John has dug. M is the number of intersections points for those ditches. Intersection 1 is the pond. Intersection point M is the stream. Each of the following N lines contains three integers, Si, Ei, and Ci. Si and Ei (1 <= Si, Ei <= M) designate the intersections between which this ditch flows. Water will flow through this ditch from Si to Ei. Ci (0 <= Ci <= 10,000,000) is the maximum rate at which water will flow through the ditch.

Output

For each case, output a single integer, the maximum rate at which water may emptied from the pond.

Sample Input

5 4
1 2 40
1 4 20
2 4 20
2 3 30
3 4 10

Sample Output

50

浜屻佸垎鏋?br>   鍏跺疄灝辨槸浠ョ偣1涓簊錛屼互鐐筸涓簍錛屾眰鏈澶ф祦錛屼絾鏄娉ㄦ剰杈撳叆鐨勮礬寰勫彲浠ラ噸澶?瑙佷唬鐮?0琛?錛屼嬌鐢‥dmonds-Karp綆楁硶錛屽叿浣撶畻娉曪細鏈澶ф祦闂
涓夈佷唬鐮?br>
 1#include<iostream>
 2#include<queue>
 3using namespace std;
 4#define MAXM 201
 5int m, n;
 6int si, ei, ci;
 7int c[MAXM][MAXM];
 8int f[MAXM][MAXM];
 9int cf[MAXM][MAXM];
10bool visit[MAXM];
11int p[MAXM];
12struct node
13{
14    int v, cf;
15    void set(int vv, int ccf)
16    {
17        v = vv; cf = ccf;
18    }

19}
;
20int main()
21{
22    while(scanf("%d%d"&n, &m) != EOF)
23    {
24        memset(c, 0sizeof(c));
25        memset(f, 0sizeof(f));
26        memset(cf, 0sizeof(cf));
27        while(n--)
28        {
29            scanf("%d%d%d"&si, &ei, &ci);
30            c[si][ei] += ci;
31            cf[si][ei] = c[si][ei];
32        }

33        bool flag = true//鐢ㄤ簬琛ㄧず鏄惁鎵懼埌澧炲箍璺?/span>
34        while(flag)
35        {
36            flag = false;
37            memset(visit, 0sizeof(visit));
38            queue<node> q;
39            node temp;
40            temp.set(1, INT_MAX);
41            p[1= 0;
42            q.push(temp); visit[1= true;
43            while(!q.empty()) //騫垮害浼樺厛鎼滅儲
44            {
45                node temp = q.front(); q.pop();
46                for(int i=1; i<=m; i++)
47                {
48                    if(temp.v == i || visit[i] || cf[temp.v][i] == 0)
49                        continue;
50                    node newNode; 
51                    newNode.set(i, min(temp.cf, cf[temp.v][i]));
52                    p[i] = temp.v;
53                    q.push(newNode);
54                    visit[i] = true;
55                    if(i == m)
56                    {
57                        flag = true//鎵懼埌澧炲箍璺?/span>
58                        break;
59                    }

60                }

61                if(flag)
62                    break;
63            }

64            if(flag)
65            {
66                int mincf = q.back().cf;
67                int v1 = p[m], v2 = m;
68                while(v1 != 0)
69                {
70                    f[v1][v2] += mincf; //淇敼嫻?/span>
71                    f[v2][v1] = -f[v1][v2];
72                    cf[v1][v2] = c[v1][v2] - f[v1][v2]; //淇敼孌嬬暀瀹歸噺
73                    cf[v2][v1] = c[v2][v1] - f[v2][v1];
74                    v2 = v1;
75                    v1 = p[v1];
76                }

77            }

78        }

79        int res = 0;
80        for(int i=2; i<=m; i++//璁$畻鏈澶ф祦
81            res += f[1][i];
82        printf("%d\n", res);
83    }

84}


Icyflame 2009-06-23 19:38 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久人人爽爽爽人久久久| 一区二区精品在线| 国产精品久久久对白| 玖玖精品视频| 欧美亚洲一级| 宅男噜噜噜66一区二区66| 亚洲国产一区二区a毛片| 久久午夜电影网| 久久xxxx| 午夜电影亚洲| 亚洲自拍高清| 亚洲午夜久久久| 日韩视频―中文字幕| 亚洲黑丝一区二区| 影音先锋亚洲一区| 激情亚洲网站| 激情五月综合色婷婷一区二区| 国产精品久久久久久久一区探花| 欧美日韩p片| 欧美日韩xxxxx| 欧美日韩精品免费观看视频| 欧美顶级少妇做爰| 欧美成人精品不卡视频在线观看| 久久蜜臀精品av| 久久久久久9999| 久久久久久一区二区三区| 欧美在线亚洲| 久久精品亚洲一区二区| 欧美主播一区二区三区美女 久久精品人 | 亚洲午夜在线视频| 亚洲图中文字幕| 亚洲在线日韩| 欧美一区二区三区免费在线看| 亚洲欧美国产制服动漫| 亚洲欧美一区二区在线观看| 亚洲欧美国产另类| 欧美一区二区日韩| 欧美在线视频免费播放| 久久岛国电影| 美女网站久久| 欧美日韩国产色视频| 欧美视频一区二区三区…| 国产精品毛片a∨一区二区三区| 国产精品久久久久久久久久久久久 | 欧美久久精品午夜青青大伊人| 你懂的视频一区二区| 欧美精品一区二区三| 欧美日韩一区在线| 国产欧美日韩在线播放| 激情婷婷欧美| 亚洲蜜桃精久久久久久久| 在线亚洲+欧美+日本专区| 新67194成人永久网站| 久久狠狠亚洲综合| 欧美高清视频一区二区三区在线观看| 亚洲国产专区校园欧美| 一区二区三区波多野结衣在线观看| 亚洲伊人久久综合| 久久久国产亚洲精品| 欧美精品午夜视频| 国产精品久久久久av| 精品动漫一区| 一本色道久久综合亚洲精品不卡 | 欧美色偷偷大香| 国产日韩在线一区| 亚洲国内自拍| 亚洲一区网站| 欧美 日韩 国产在线| 日韩一级精品| 久久免费黄色| 欧美午夜宅男影院在线观看| 红桃视频国产一区| 亚洲午夜av| 免费观看久久久4p| 一区二区日韩免费看| 久久免费黄色| 国产精品网站在线观看| 亚洲日本欧美| 久久精品国产一区二区三区| 亚洲激情第一页| 欧美在线亚洲综合一区| 欧美视频福利| 亚洲国产女人aaa毛片在线| 午夜欧美精品| 亚洲精品一区二区在线| 久久久久一区二区| 国产伦精品一区二区三区视频黑人 | 亚洲一区三区视频在线观看| 欧美成人tv| 国产一区二区三区四区hd| 在线一区二区三区做爰视频网站 | 亚洲成色999久久网站| 亚洲专区欧美专区| 欧美大片免费观看| 欧美一区二区在线视频| 欧美性大战xxxxx久久久| 亚洲欧洲精品成人久久奇米网| 久久av免费一区| 在线一区二区日韩| 欧美激情国产高清| 亚洲国产精选| 久久青草欧美一区二区三区| 亚洲在线黄色| 国产精品成人午夜| 亚洲网站在线播放| 亚洲欧洲一区二区三区久久| 久久深夜福利免费观看| 国产亚洲精品高潮| 欧美亚洲色图校园春色| 亚洲视频在线观看视频| 欧美日韩在线精品| 一区二区免费看| 亚洲韩日在线| 欧美大尺度在线观看| 亚洲国产专区校园欧美| 免费成人在线观看视频| 久久九九99视频| 国产综合欧美| 久久亚洲风情| 久久久久久**毛片大全| 伊人久久噜噜噜躁狠狠躁| 久久综合久久久久88| 久久国产精品久久久久久| 国产一区清纯| 老司机久久99久久精品播放免费| 久久爱另类一区二区小说| 韩国成人福利片在线播放| 久久人人爽人人爽爽久久| 久久久久免费观看| 亚洲国产精品va| 亚洲韩国青草视频| 欧美日韩精品欧美日韩精品| 一区二区日韩欧美| 一区二区三区精品| 国产精品日韩欧美大师| 欧美一区二区三区四区高清| 性欧美精品高清| 精品成人久久| 亚洲国产精品免费| 欧美日韩日本国产亚洲在线| 亚洲女人天堂成人av在线| 亚洲欧美激情四射在线日| 国产一区二区三区四区五区美女 | 永久555www成人免费| 欧美国产另类| 欧美日本三区| 亚洲欧美日韩综合aⅴ视频| 欧美亚洲免费高清在线观看| 在线日本成人| 亚洲精品资源| 国产麻豆精品视频| 牛牛影视久久网| 欧美日韩国产三区| 久久精品导航| 欧美大片一区二区三区| 亚洲欧美精品在线| 久久久国产视频91| 一区二区三区免费在线观看| 亚洲欧美日韩精品久久久| 在线电影国产精品| 日韩午夜在线播放| 国产日韩精品在线观看| 亚洲国产91色在线| 国产精品视频久久久| 男人天堂欧美日韩| 欧美片在线播放| 久久久91精品国产一区二区三区 | 国产主播喷水一区二区| 亚洲第一色中文字幕| 国产精品美女久久久久久久| 蜜乳av另类精品一区二区| 欧美日韩中文字幕精品| 久久中文字幕一区| 欧美日韩综合久久| 乱人伦精品视频在线观看| 欧美三级电影精品| 免费不卡视频| 国产精品一区二区三区久久久| 欧美激情第三页| 国产亚洲a∨片在线观看| 亚洲人成高清| 伊人成人开心激情综合网| 一本色道综合亚洲| 91久久国产自产拍夜夜嗨| 午夜精品久久久| 一本大道久久a久久精二百| 久久久久久久久久看片| 亚洲欧美综合v| 欧美华人在线视频| 美国十次成人| 国产日韩视频| 一区二区三区色| 日韩一级黄色av| 久久青青草原一区二区| 欧美一区二视频| 欧美丝袜一区二区| 亚洲国产精品va| 亚洲第一成人在线| 久久国产精品电影| 欧美在线日韩在线|