{"id":201,"date":"2010-04-02T19:53:00","date_gmt":"2010-04-02T11:53:00","guid":{"rendered":"http:\/\/localhost\/?p=201"},"modified":"2010-04-02T19:53:00","modified_gmt":"2010-04-02T11:53:00","slug":"usaco2009_dec_dizzy_dizziness_cows","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=201","title":{"rendered":"[Usaco2009 Dec]Dizzy \u5934\u6655\u7684\u5976\u725b"},"content":{"rendered":"<p> Current Contest<br \/> <a href=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/pastcontests\">Past Contests<\/a><br \/> <a href=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/contests\">Scheduled  Contests<\/a>            Welcome<br \/> <strong>WJMZBMR<\/strong> <a href=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/login?action=logout&amp;url=\/JudgeOnline\/showproblem?problem_id=1773\">Log  Out<\/a><br \/> <a target=\"_parent\" href=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/mail\">Mail:0(<strong>0<\/strong>)<\/a> <\/p>\n<p>[Usaco2009 Dec]Dizzy \u5934\u6655\u7684\u5976\u725b<\/p>\n<p>Time Limit:10000MS&#160; Memory Limit:65536K<br \/>Total Submit:10 Accepted:0 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> <img decoding=\"async\" src=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/images\/1773.jpg\" \/><\/p>\n<p><strong>Input <\/strong><\/p>\n<p> * \u7b2c1\u884c: \u4e09\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6b63\u6570: N, M1\u548cM2 <\/p>\n<p>* \u7b2c2\u52301+M1\u884c: \u7b2ci+1\u884c\u8868\u793a\u7b2ci\u6761\u5355\u5411\u9053\u8def\uff0c\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570: A_i\u548cB_i <\/p>\n<p>* \u7b2c2+M1\u5230\u7b2c1+M1+M2\u884c: \u7b2ci+M1+1\u884c\u8868\u793a\u7b2ci\u6761\u5355\u5411\u9053\u8def\uff0c\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570 <br \/>X_i\u548cY_i <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> * \u7b2c1\u5230M2\u884c: \u7b2ci\u884c\u5e94\u8be5\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570: \u6839\u636e\u4f60\u7ed9\u7b2ci\u6761\u53cc\u5411\u9053\u8def\u5b9a\u4e49\u7684\u7684\u65b9 <br \/>\u5411\uff0c\u53ef\u80fd\u662fX_i, Y_i\uff0c\u4e5f\u53ef\u80fd\u662fY_i, X_i\u3002\u8fd9\u4e9b\u53cc\u5411\u9053\u8def\u5fc5\u987b\u6309\u7167\u8f93\u5165\u7684\u987a\u5e8f <br \/>\u8f93\u51fa\u3002\u5982\u679c\u65e0\u89e3\uff0c\u5728\u5355\u72ec\u7684\u4e00\u884c\u5185\u8f93\u51fa&quot;-1&quot;\u3002 <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>4 2 3<br \/>1 2<br \/>4 3<br \/>1 3<br \/>4 2<br \/>3 2<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>1 3<br \/>2 4<br \/>2 3<\/p>\n<p><strong>Source <\/strong><\/p>\n<p> Gold<br \/>\u56e7\u3002\u3002\u6709\u610f\u601d\u7684\u9898\u76ee\u3002\u3002\u6211\u4e00\u5f00\u59cb\u60f3\u7684\u662f\u968f\u4fbf\u627e\u4e2a\u70b9dfs\uff0c\u7136\u540e\u6309\u6df1\u5ea6\u8fde\u8fb9\uff0c\u660e\u663e\u9519\u7684\u56e7\u3002\u3002\u7136\u540e\u60f3\u5bf9\u6bcf\u4e2a\u70b9dfs\u4e00\u904d\u6c42\u51fa\u80fd\u901a\u8fc7\u6709\u5411\u8fb9\u5230\u8fbe\u54ea\u4e9b\u70b9\uff0c\u90a3\u4e48\u8fd9\u4e9b\u70b9\u4e0e\u8fd9\u4e2a\u70b9\u8fde\u7684\u65e0\u5411\u8fb9\u80af\u5b9a\u8981\u6b63\u5411\uff0c\u7ed3\u679c\u5f88\u660e\u663eTLE\u56e7\u3002\u3002\u8981\u662f\u6bd4\u8d5b\u7684\u8bdd\u53ea\u80fd\u6309\u8fd9\u4e2a\u9a97\u70b9\u5206\u4e86\u3002\u3002<br \/>\u5f53\u6211\u82e6\u601d\u65e0\u679c\u5934\u75db\u4e07\u5206\u7684\u65f6\u5019\u3002\u3002\u6211\u611f\u89c9\u4f3c\u4e4e\u5e94\u8be5\u662f\u627e\u67d0\u79cd\u89c4\u5219\u6765\u8fde\u8fb9\u7684\uff0c\u4ec0\u4e48\u89c4\u5219\u624d\u80fd\u6ca1\u6709\u5708\u5462\uff1fDAG\u3002\u3002\u62d3\u6251\u6392\u5e8f\uff01\u56e7\u3002\u3002\u6211\u4eec\u5b66\u6821\u6625\u6e38\u7684\u65f6\u5019\u6211\u5c31\u5728\u60f3\u8fd9\u4e2a\uff0c\u6625\u6e38\u90fd\u6ca1\u73a9\u597d\u56e7\u3002\u3002<br \/>Code\uff1a<\/p>\n<p>\/*<br \/>    ID: Tom Chen<br \/>    LANG: C++<br \/>    TASK: dizzy<br \/>*\/<br \/>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;queue&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>using namespace std;<br \/>const int inf=~0U&gt;&gt;1,maxn=100000;<br \/>vector&lt;int&gt; E[maxn];<br \/>int In[maxn]={0},ord[maxn],n,m1,m2;<br \/>int main()<br \/>{<br \/>    freopen(&quot;dizzy.in&quot;,&quot;r&quot;,stdin);<br \/>    freopen(&quot;dizzy.out&quot;,&quot;w&quot;,stdout);<br \/>    cin&gt;&gt;n&gt;&gt;m1&gt;&gt;m2;int s,t,cnt=0;<br \/>    rep(i,m1)scanf(&quot;%d %d&quot;,&amp;s,&amp;t),&#8211;s,&#8211;t,E[s].pb(t),In[t]++;<br \/>    queue&lt;int&gt; Q;rep(i,n)if(!In[i]) Q.push(i);<br \/>    while(Q.size())<br \/>    {<br \/>        int t=Q.front();Q.pop();ord[t]=cnt++;<br \/>        for(vector&lt;int&gt;::iterator i=E[t].begin();i!=E[t].end();i++)<br \/>            if(!&#8211;In[*i]) Q.push(*i);<br \/>    }<br \/>    rep(i,m2)<br \/>    {<br \/>        scanf(&quot;%d %d&quot;,&amp;s,&amp;t),&#8211;s,&#8211;t;<br \/>        if(ord[s]&gt;ord[t])swap(s,t);<br \/>        printf(&quot;%d %dn&quot;,s+1,t+1);<br \/>    }<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Current Contest Past Contests Scheduled Contests Welcome WJMZBMR Log Out Mail:0(0) [Usaco2009 Dec]Dizzy \u5934\u6655\u7684\u5976\u725b Time Limit:10000MS&#160; Memory Limit:65536KTotal Submit:10 Accepted:0 Case Time Limit:1000MS Description Input * \u7b2c1\u884c: \u4e09\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6b63\u6570: N, M1\u548cM2 * \u7b2c2\u52301+M1\u884c: \u7b2ci+1\u884c\u8868\u793a\u7b2ci\u6761\u5355\u5411\u9053\u8def\uff0c\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570: A_i\u548cB_i * \u7b2c2+M1\u5230\u7b2c1+M1+M2\u884c: \u7b2ci+M1+1\u884c\u8868\u793a\u7b2ci\u6761\u5355\u5411\u9053\u8def\uff0c\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570 X_i\u548cY_i Output * \u7b2c1\u5230M2\u884c: \u7b2ci\u884c\u5e94\u8be5\u5305\u542b\u4e24\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570: \u6839\u636e\u4f60\u7ed9\u7b2ci\u6761\u53cc\u5411\u9053\u8def\u5b9a\u4e49\u7684\u7684\u65b9 \u5411\uff0c\u53ef\u80fd\u662fX_i, Y_i\uff0c\u4e5f\u53ef\u80fd\u662fY_i, X_i\u3002\u8fd9\u4e9b\u53cc\u5411\u9053\u8def\u5fc5\u987b\u6309\u7167\u8f93\u5165\u7684\u987a\u5e8f \u8f93\u51fa\u3002\u5982\u679c\u65e0\u89e3\uff0c\u5728\u5355\u72ec\u7684\u4e00\u884c\u5185\u8f93\u51fa&quot;-1&quot;\u3002 Sample Input 4 2 31 24 31 34 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/201"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}