diff --git a/HDOJ/5876_yuanjunlai141.cpp b/HDOJ/5876_yuanjunlai141.cpp new file mode 100644 index 0000000..12ee4eb --- /dev/null +++ b/HDOJ/5876_yuanjunlai141.cpp @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +using namespace std; +const int maxn=200000*5,inf=0x3f3f3f3f; +struct Edge +{ + int v,next,cap; + +} edge[maxn]; +int tot,head[maxn]; +int vis[maxn],du[maxn],dis[maxn]; +void init() +{ + tot=0; + memset(head,-1,sizeof(head)); +} +void add_edge(int u,int v,int cap) +{ + edge[tot].v=v; + edge[tot].cap=cap; + edge[tot].next=head[u]; + head[u]=tot++; +} +void bfs(int start,int n) +{ + sets1; + sets2; + set::iterator it; + for(int i=1;i<=n;i++) + { + if(i!=start) + s1.insert(i); + } + + queueque; + que.push(start); + dis[start]=0; + while(!que.empty()) + { + int u=que.front(); + que.pop(); + for(int i=head[u];i!=-1;i=edge[i].next) + { + int v=edge[i].v; + if(!s1.count(v)) + continue; + s1.erase(v); + s2.insert(v); + + } + for(it=s1.begin();it!=s1.end();it++) + { + que.push(*it); + dis[*it]=dis[u]+1; + } + s1.swap(s2); + s2.clear(); + } +} +int main() +{ + int s,n,t,m; + int u,v; + scanf("%d",&t); + while(t--) + { + scanf("%d%d",&n,&m); + init(); + memset(du,0,sizeof(du)); + for(int i=0; i