usaco 月赛 2005 january watchcow
2013-11-20 14:24
423 查看
2013-09-18 08:13
//By BLADEVIL var n, m :longint; pre, other :array[0..50010] of longint; last :array[0..10010] of longint; flag :array[0..50010] of boolean; tot :longint; ans :array[0..10010] of longint; i :longint; l :longint; procedure connect(x,y:longint); begin inc(l); pre[l]:=last[x]; last[x]:=l; other[l]:=y; end; procedure init; var i :longint; x, y :longint; begin read(n,m); for i:=1 to m do begin read(x,y); connect(x,y); connect(y,x); end; end; procedure dfs(x:longint); var p, q :longint; begin q:=last[x]; while q<>0 do begin p:=other[q]; if not flag[q] then begin flag[q]:=true; dfs(p); end; q:=pre[q]; end; inc(tot); ans[tot]:=x; end; begin assign(input,'watch.in'); reset(input); assign(output,'watch.out'); rewrite(output); init; dfs(1); for i:=tot downto 1 do writeln(ans[i]); close(input); close(output); end.
相关文章推荐
- usaco 月赛 2008 January Best Cow Line 贝茜的晨练计划 题解
- POJ 2230 Watchcow && USACO Watchcow 2005 January Silver (欧拉回路)
- USACO 2005 January Gold The Wedding Juicer
- poj 2018 Best Cow Fences USACO历年月赛 (分数规划+DP)
- USACO 2005 Nov Cow Acrobats 奶牛杂技
- USACO月赛2005 january volume
- bzoj 1629 & Usaco 月赛 2007 DemoCow Acrobats 题解
- usaco 月赛 2005 january sumset
- BZOJ 1694 & 1742 [Usaco 2005 nov] 区间DP 解题报告
- [BZOJ1688][Usaco2005 Open]Disease Manangement 疾病管理(状压dp)
- 1750: [Usaco2005 qua]Apple Catching (动态规划)
- 【BZOJ】1666 [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏
- bzoj1671 [Usaco2005 Dec]Knights of Ni 骑士
- [BZOJ1654] [Usaco2006 Jan]The Cow Prom 奶牛舞会
- [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 记忆化搜索
- bzoj1688 [Usaco2005 Open]Disease Manangement 疾病管理
- bzoj:1654 [Usaco2006 Jan]The Cow Prom 奶牛舞会
- bzoj1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚
- BZOJ1674: [Usaco2005]Part Acquisition
- 【BZOJ】1731: [Usaco2005 dec]Layout 排队布局