ZOJ 3172 Extend 7-day Vacation

來源:互聯網
上載者:User

#include "iostream"<br />#include "vector"</p><p>using namespace std;<br />typedef struct{<br /> vector <int> v;<br />}Node;</p><p>Node List[1000];<br />int a,b,m,n,max_country,country;<br />bool visit[1000];</p><p>void Dfs(int country,int c)<br />{<br /> cout<<c<<" "<<country<<endl;<br /> // int flag=0;<br /> if(max_country<country)<br /> max_country=country;<br /> for(int i=0;i<(List[c].v).size();i++)<br /> {<br /> if(!visit[List[c].v[i]])<br /> {<br /> visit[c]=true;<br /> Dfs(country+1,List[c].v[i]);<br /> // flag=1;<br /> visit[c]=false;<br /> }<br /> }<br />} </p><p>int main()<br />{</p><p> //freopen("data.in","r",stdin);<br /> while(scanf("%d%d",&n,&m)!=EOF)<br /> {</p><p> memset(visit,false,sizeof(visit));<br /> for(int i=0;i<n;i++)<br /> (List[i].v).clear();<br /> for(int i=1;i<=m;i++)<br /> {<br /> scanf("%d%d",&a,&b);<br /> (List[a].v).push_back(b);<br /> (List[b].v).push_back(a);<br /> }<br /> /* for(int j=0;j<n;j++)<br /> {<br /> for(int i=0;i<(List[j].v).size();i++)<br /> printf(" %d",List[j].v[i]);<br /> printf("/n");<br /> } */<br /> max_country=0;<br /> for(int i=0;i<n;i++)<br /> {</p><p> if((List[i].v).size()==1)<br /> {<br /> printf("/n");<br /> Dfs(1,i);<br /> }</p><p> }<br /> if(max_country>6)<br /> printf("%d/n",max_country);<br /> else<br /> printf("Impossible/n");<br /> } </p><p> //while(1);<br /> return 0;<br />}<br />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.