摘要: http://poj.org/problem?id=3256 对N个牧场用邻接表存储路径,记录下每个牧场初始牛的数目,沿路径dfs求连通牧场的牛数和。code:#include<cstdio>#include<cstring>usingnamespacestd;intnum[1001];intsum[1001];inthead[1001];boolvis[1001];intx;structpast{intv,nex;}edge[10001];voidaddedge(intu,intv){edge[x].v=v;edge[x].nex=head[u];head[u]=x; 阅读全文
posted @ 2012-03-14 20:53 追逐. 阅读(251) 评论(0) 推荐(0) 编辑