﻿<?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++博客-powerwater-文章分类-竞赛题解_Zerojudge</title><link>http://www.cppblog.com/powerwater/category/17978.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 25 Jun 2012 00:35:51 GMT</lastBuildDate><pubDate>Mon, 25 Jun 2012 00:35:51 GMT</pubDate><ttl>60</ttl><item><title>zerojudge a065</title><link>http://www.cppblog.com/powerwater/articles/178586.html</link><dc:creator>龙在江湖</dc:creator><author>龙在江湖</author><pubDate>Tue, 12 Jun 2012 15:58:00 GMT</pubDate><guid>http://www.cppblog.com/powerwater/articles/178586.html</guid><wfw:comment>http://www.cppblog.com/powerwater/comments/178586.html</wfw:comment><comments>http://www.cppblog.com/powerwater/articles/178586.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/powerwater/comments/commentRss/178586.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/powerwater/services/trackbacks/178586.html</trackback:ping><description><![CDATA[<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_235704" onclick="this.style.display='none'; Code_Closed_Text_235704.style.display='none'; Code_Open_Image_235704.style.display='inline'; Code_Open_Text_235704.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_235704" onclick="this.style.display='none'; Code_Open_Text_235704.style.display='none'; Code_Closed_Image_235704.style.display='inline'; Code_Closed_Text_235704.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_235704"></span><span style="display: none" id="Code_Open_Text_235704"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><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 align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">string</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cctype</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#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 align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_101_225_Open_Image" onclick="this.style.display='none'; Codehighlighter1_101_225_Open_Text.style.display='none'; Codehighlighter1_101_225_Closed_Image.style.display='inline'; Codehighlighter1_101_225_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_101_225_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_101_225_Closed_Text.style.display='none'; Codehighlighter1_101_225_Open_Image.style.display='inline'; Codehighlighter1_101_225_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_101_225_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_101_225_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">string</span><span style="color: #000000">&nbsp;s;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">&nbsp;(cin</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">s)<br /><img id="Codehighlighter1_131_212_Open_Image" onclick="this.style.display='none'; Codehighlighter1_131_212_Open_Text.style.display='none'; Codehighlighter1_131_212_Closed_Image.style.display='inline'; Codehighlighter1_131_212_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_131_212_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_131_212_Closed_Text.style.display='none'; Codehighlighter1_131_212_Open_Image.style.display='inline'; Codehighlighter1_131_212_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_131_212_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_131_212_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;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">s.size();i</span><span style="color: #000000">++</span><span style="color: #000000">)<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">abs(s.at(i)</span><span style="color: #000000">-</span><span style="color: #000000">s.at(i</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">));<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></span></div><br /><img src ="http://www.cppblog.com/powerwater/aggbug/178586.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/powerwater/" target="_blank">龙在江湖</a> 2012-06-12 23:58 <a href="http://www.cppblog.com/powerwater/articles/178586.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Zerojudge_b201国家</title><link>http://www.cppblog.com/powerwater/articles/158941.html</link><dc:creator>龙在江湖</dc:creator><author>龙在江湖</author><pubDate>Sun, 23 Oct 2011 13:48:00 GMT</pubDate><guid>http://www.cppblog.com/powerwater/articles/158941.html</guid><wfw:comment>http://www.cppblog.com/powerwater/comments/158941.html</wfw:comment><comments>http://www.cppblog.com/powerwater/articles/158941.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/powerwater/comments/commentRss/158941.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/powerwater/services/trackbacks/158941.html</trackback:ping><description><![CDATA[<p align="left"><strong><a href="http://zerojudge.tw/ShowProblem?problemid=b201">http://zerojudge.tw/ShowProblem?problemid=b201</a><br />内容 ：</strong> </p>
<div id="problem_content" class="problembox">傳說在遙遠的古代，整個地球的大陸是一整塊，整塊大陸上有n 個城市。這些城市間有共有m 條道路相連接，不過有趣的是這些道路只能夠單向通行。有一天上帝決定把整塊大陸切成幾塊形成各自的國家。分割的策略就是把原本就可以互相聯絡的幾個城市當成一個國家（如果有一條路徑從城市i 到城市j 且有一條路徑從城市j 到城市i，則城市i 和城市j 就在同一個國家）。上帝想請你幫一個忙，他想知道每個國家的大小。也就是每個國家到底包含了幾個城市。<br />以下是一個簡單的例子：<br />如果有一條單行道從城市 i 接到城市j 用(i,j)表示如果一開始有 3 個城市，然後有3 條單行道(1, 2), (2, 1), (2, 3) 則可以分成兩個國家，分別包含了2 個城市(1, 2)和1 個城市(3)。 </div>
<p align="left"><strong>输入说明 ：</strong><br /></p>
<div id="problem_theinput" class="problembox">輸入檔中會有多筆資料，每一組資料的第一行第一行包含了城市數量 n(1&lt;=n&lt;=100000)和單行道的數量m(1&lt;=m&lt;=2100000)，接下來m 行，每一行中都包含兩個數字i, j 代表有一條單行道從城市i 連到城市j(注意兩個城市間可能有不只兩條的單行道)。</div>
<p align="left"><strong>输出说明 ：</strong><br /></p>
<div id="problem_theoutput" class="problembox">對於每一組資料輸出一行，內容是排序過後每個國家的大小。</div>
<p style="font-family: 'Courier New', Courier, monospace" align="left"><strong>范例输入 ：</strong><span><img alt="help" src="http://zerojudge.tw/images/help.png" /></span> </p>
<div id="sampleinputhint" class="hint">若題目沒有特別說明，則應該以多測資的方式讀取，若不知如何讀取請參考 a001 的範例程式。</div>
<div class="problembox"><pre>3 3
1 2
2 1
2 3
2 2
1 2
2 1</pre></div>
<p>&nbsp;</p>
<p style="font-family: 'Courier New', Courier, monospace" align="left"><strong>范例输出 ：</strong></p>
<div class="problembox"><pre>1 2
2</pre></div>
<div class="problembox">
<form style="display: inline" method="post" name="reference_form" action="Problems"><input value="2008 NPSC 高中組初賽" type="hidden" name="searchword" /> <span id="search_reference" class="FakeLink" jquery1319376205437="28">2008 NPSC 高中組初賽<br /><br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Code_Closed_Image_214737" onclick="this.style.display='none'; Code_Closed_Text_214737.style.display='none'; Code_Open_Image_214737.style.display='inline'; Code_Open_Text_214737.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" width="11" height="16"><img style="display: none" id="Code_Open_Image_214737" onclick="this.style.display='none'; Code_Open_Text_214737.style.display='none'; Code_Closed_Image_214737.style.display='inline'; Code_Closed_Text_214737.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Code_Closed_Text_214737">c++代码</span><span style="display: none" id="Code_Open_Text_214737"><br /><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">&nbsp;1</span><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><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 /></span><span style="color: #008080">&nbsp;2</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstring</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;3</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">#include&lt;fstream&gt;</span><span style="color: #008000"><br /></span><span style="color: #008080">&nbsp;4</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000">#include</span><span style="color: #000000">&lt;</span><span style="color: #000000">stack</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /></span><span style="color: #008080">&nbsp;5</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />#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 /></span><span style="color: #008080">&nbsp;6</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /></span><span style="color: #008080">&nbsp;7</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;N(</span><span style="color: #000000">100008</span><span style="color: #000000">);<br /></span><span style="color: #008080">&nbsp;8</span><span style="color: #000000"><img id="Codehighlighter1_147_186_Open_Image" onclick="this.style.display='none'; Codehighlighter1_147_186_Open_Text.style.display='none'; Codehighlighter1_147_186_Closed_Image.style.display='inline'; Codehighlighter1_147_186_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_147_186_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_147_186_Closed_Text.style.display='none'; Codehighlighter1_147_186_Open_Image.style.display='inline'; Codehighlighter1_147_186_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;edgeT</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_147_186_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_147_186_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">&nbsp;9</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;adj;<br /></span><span style="color: #008080">10</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;edgeT&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">next;<br /></span><span style="color: #008080">11</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">;<br /></span><span style="color: #008080">12</span><span style="color: #000000"><img id="Codehighlighter1_200_250_Open_Image" onclick="this.style.display='none'; Codehighlighter1_200_250_Open_Text.style.display='none'; Codehighlighter1_200_250_Closed_Image.style.display='inline'; Codehighlighter1_200_250_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_200_250_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_200_250_Closed_Text.style.display='none'; Codehighlighter1_200_250_Open_Image.style.display='inline'; Codehighlighter1_200_250_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;node</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_200_250_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_200_250_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">13</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;dfn,low,belong;<br /></span><span style="color: #008080">14</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;edgeT&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">head;<br /></span><span style="color: #008080">15</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">;<br /></span><span style="color: #008080">16</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n,m,scc_n,idx,country[N];&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">scc_n:强连通分量个数&nbsp;idx:时间戳&nbsp;country[]:国家人数&nbsp;</span><span style="color: #008000"><br /></span><span style="color: #008080">17</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #000000"><br /></span><span style="color: #008080">18</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />node&nbsp;g[N];<br /></span><span style="color: #008080">19</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">bool</span><span style="color: #000000">&nbsp;instack[N];<br /></span><span style="color: #008080">20</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" />stack</span><span style="color: #000000">&lt;</span><span style="color: #0000ff">int</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;s;<br /></span><span style="color: #008080">21</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">ifstream&nbsp;cin("b201.in");<br /></span><span style="color: #008080">22</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">ofstream&nbsp;cout("b201.out");</span><span style="color: #008000"><br /></span><span style="color: #008080">23</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;tarjan(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;u)<br /></span><span style="color: #008080">24</span><span style="color: #000000"><img id="Codehighlighter1_441_1004_Open_Image" onclick="this.style.display='none'; Codehighlighter1_441_1004_Open_Text.style.display='none'; Codehighlighter1_441_1004_Closed_Image.style.display='inline'; Codehighlighter1_441_1004_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_441_1004_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_441_1004_Closed_Text.style.display='none'; Codehighlighter1_441_1004_Open_Image.style.display='inline'; Codehighlighter1_441_1004_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_441_1004_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_441_1004_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">25</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;v;<br /></span><span style="color: #008080">26</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;g[u].dfn</span><span style="color: #000000">=</span><span style="color: #000000">g[u].low</span><span style="color: #000000">=++</span><span style="color: #000000">idx;<br /></span><span style="color: #008080">27</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;s.push(u);<br /></span><span style="color: #008080">28</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;instack[u]</span><span style="color: #000000">=</span><span style="color: #0000ff">true</span><span style="color: #000000">;<br /></span><span style="color: #008080">29</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;edgeT&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">p;<br /></span><span style="color: #008080">30</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000">=</span><span style="color: #000000">g[u].head;<br /></span><span style="color: #008080">31</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">&nbsp;(p)<br /></span><span style="color: #008080">32</span><span style="color: #000000"><img id="Codehighlighter1_568_775_Open_Image" onclick="this.style.display='none'; Codehighlighter1_568_775_Open_Text.style.display='none'; Codehighlighter1_568_775_Closed_Image.style.display='inline'; Codehighlighter1_568_775_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_568_775_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_568_775_Closed_Text.style.display='none'; Codehighlighter1_568_775_Open_Image.style.display='inline'; Codehighlighter1_568_775_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_568_775_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_568_775_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">33</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v</span><span style="color: #000000">=</span><span style="color: #000000">p</span><span style="color: #000000">-&gt;</span><span style="color: #000000">adj;<br /></span><span style="color: #008080">34</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(</span><span style="color: #000000">!</span><span style="color: #000000">g[v].dfn)<br /></span><span style="color: #008080">35</span><span style="color: #000000"><img id="Codehighlighter1_619_697_Open_Image" onclick="this.style.display='none'; Codehighlighter1_619_697_Open_Text.style.display='none'; Codehighlighter1_619_697_Closed_Image.style.display='inline'; Codehighlighter1_619_697_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_619_697_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_619_697_Closed_Text.style.display='none'; Codehighlighter1_619_697_Open_Image.style.display='inline'; Codehighlighter1_619_697_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_619_697_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_619_697_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">36</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tarjan(v);<br /></span><span style="color: #008080">37</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g[u].low</span><span style="color: #000000">=</span><span style="color: #000000">min(g[u].low,g[v].low);<br /></span><span style="color: #008080">38</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(instack[v])&nbsp;g[u].low</span><span style="color: #000000">=</span><span style="color: #000000">min(g[u].low,g[v].dfn);<br /></span><span style="color: #008080">39</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000">=</span><span style="color: #000000">p</span><span style="color: #000000">-&gt;</span><span style="color: #000000">next;<br /></span><span style="color: #008080">40</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">41</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(g[u].dfn</span><span style="color: #000000">==</span><span style="color: #000000">g[u].low)<br /></span><span style="color: #008080">42</span><span style="color: #000000"><img id="Codehighlighter1_809_1002_Open_Image" onclick="this.style.display='none'; Codehighlighter1_809_1002_Open_Text.style.display='none'; Codehighlighter1_809_1002_Closed_Image.style.display='inline'; Codehighlighter1_809_1002_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_809_1002_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_809_1002_Closed_Text.style.display='none'; Codehighlighter1_809_1002_Open_Image.style.display='inline'; Codehighlighter1_809_1002_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_809_1002_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_809_1002_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">43</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scc_n</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_838_983_Open_Image" onclick="this.style.display='none'; Codehighlighter1_838_983_Open_Text.style.display='none'; Codehighlighter1_838_983_Closed_Image.style.display='inline'; Codehighlighter1_838_983_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_838_983_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_838_983_Closed_Text.style.display='none'; Codehighlighter1_838_983_Open_Image.style.display='inline'; Codehighlighter1_838_983_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">do</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_838_983_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_838_983_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">45</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v</span><span style="color: #000000">=</span><span style="color: #000000">s.top();<br /></span><span style="color: #008080">46</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g[v].belong</span><span style="color: #000000">=</span><span style="color: #000000">scc_n;<br /></span><span style="color: #008080">47</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.pop();<br /></span><span style="color: #008080">48</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;country[scc_n]</span><span style="color: #000000">++</span><span style="color: #000000">;<br /></span><span style="color: #008080">49</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;instack[v]</span><span style="color: #000000">=</span><span style="color: #0000ff">false</span><span style="color: #000000">;<br /></span><span style="color: #008080">50</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #0000ff">while</span><span style="color: #000000">&nbsp;(v</span><span style="color: #000000">!=</span><span style="color: #000000">u);<br /></span><span style="color: #008080">51</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">52</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #008080">53</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /><br /></span><span style="color: #008080">54</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /></span><span style="color: #008080">55</span><span style="color: #000000"><img id="Codehighlighter1_1027_1685_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1027_1685_Open_Text.style.display='none'; Codehighlighter1_1027_1685_Closed_Image.style.display='inline'; Codehighlighter1_1027_1685_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_1027_1685_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1027_1685_Closed_Text.style.display='none'; Codehighlighter1_1027_1685_Open_Image.style.display='inline'; Codehighlighter1_1027_1685_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1027_1685_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1027_1685_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;<br /></span><span style="color: #008080">56</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;x,y;<br /></span><span style="color: #008080">57</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;edgeT&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">p;<br /></span><span style="color: #008080">58</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;std::ios::sync_with_stdio(</span><span style="color: #0000ff">false</span><span style="color: #000000">);<br /></span><span style="color: #008080">59</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">&nbsp;(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 /></span><span style="color: #008080">60</span><span style="color: #000000"><img id="Codehighlighter1_1122_1646_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1122_1646_Open_Text.style.display='none'; Codehighlighter1_1122_1646_Closed_Image.style.display='inline'; Codehighlighter1_1122_1646_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1122_1646_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1122_1646_Closed_Text.style.display='none'; Codehighlighter1_1122_1646_Open_Image.style.display='inline'; Codehighlighter1_1122_1646_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1122_1646_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1122_1646_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">61</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(g,</span><span style="color: #000000">0</span><span style="color: #000000">,(n</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: #0000ff">sizeof</span><span style="color: #000000">(node));<br /></span><span style="color: #008080">62</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;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 /></span><span style="color: #008080">63</span><span style="color: #000000"><img id="Codehighlighter1_1203_1339_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1203_1339_Open_Text.style.display='none'; Codehighlighter1_1203_1339_Closed_Image.style.display='inline'; Codehighlighter1_1203_1339_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1203_1339_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1203_1339_Closed_Text.style.display='none'; Codehighlighter1_1203_1339_Open_Image.style.display='inline'; Codehighlighter1_1203_1339_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1203_1339_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1203_1339_Open_Text"><span style="color: #000000">{<br /></span><span style="color: #008080">64</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">x</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">y;<br /></span><span style="color: #008080">65</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;edgeT;<br /></span><span style="color: #008080">66</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000">-&gt;</span><span style="color: #000000">adj</span><span style="color: #000000">=</span><span style="color: #000000">y;<br /></span><span style="color: #008080">67</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p</span><span style="color: #000000">-&gt;</span><span style="color: #000000">next</span><span style="color: #000000">=</span><span style="color: #000000">g[x].head;<br /></span><span style="color: #008080">68</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g[x].head</span><span style="color: #000000">=</span><span style="color: #000000">p;<br /></span><span style="color: #008080">69</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">70</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scc_n</span><span style="color: #000000">=</span><span style="color: #000000">idx</span><span style="color: #000000">=</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;<br /></span><span style="color: #008080">71</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(country,</span><span style="color: #000000">0</span><span style="color: #000000">,(n</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: #0000ff">sizeof</span><span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000">));<br /></span><span style="color: #008080">72</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(instack,</span><span style="color: #000000">0</span><span style="color: #000000">,(n</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: #0000ff">sizeof</span><span style="color: #000000">(</span><span style="color: #0000ff">bool</span><span style="color: #000000">));<br /></span><span style="color: #008080">73</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;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 /></span><span style="color: #008080">74</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(</span><span style="color: #000000">!</span><span style="color: #000000">g[i].dfn)&nbsp;tarjan(i);<br /></span><span style="color: #008080">75</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sort(country</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">,country</span><span style="color: #000000">+</span><span style="color: #000000">scc_n</span><span style="color: #000000">+</span><span style="color: #000000">1</span><span style="color: #000000">);<br /></span><span style="color: #008080">76</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;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">scc_n;i</span><span style="color: #000000">++</span><span style="color: #000000">)&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">country[i]</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">;<br /></span><span style="color: #008080">77</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">endl;<br /></span><span style="color: #008080">78</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /></span><span style="color: #008080">79</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">system("pause");</span><span style="color: #008000"><br /></span><span style="color: #008080">80</span><span style="color: #008000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /></span><span style="color: #008080">81</span><span style="color: #000000"><img align="top" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></span></div><br /></span></form></div> <img src ="http://www.cppblog.com/powerwater/aggbug/158941.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/powerwater/" target="_blank">龙在江湖</a> 2011-10-23 21:48 <a href="http://www.cppblog.com/powerwater/articles/158941.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>