diff --git a/HDOJ/2066.cpp b/HDOJ/2066.cpp new file mode 100644 index 0000000..245ff20 --- /dev/null +++ b/HDOJ/2066.cpp @@ -0,0 +1,82 @@ +#include +#include +#include +#include +using namespace std; + +#define INF 0x3f3f3f3f + +namespace SPFA +{ +const int MAXN = 1005; +int d[MAXN];/// distance [ From S to ... ] +int v[MAXN];/// visit +int q[MAXN];/// ???????(???queue?...) +int mp[MAXN][MAXN]; /// mp[i][j] ???<--> j ?? ?1?? +int n; + +int spfa(int s,int t) +{ + memset(d,0x3f,sizeof(d)); + memset(v,0,sizeof(v)); + /* + for(int i=1;i0) + { + int c=q[--cnt]; + v[c]=0; + for(int i=1;i<=n;i++) + { + if(mp[c][i]!=-1&&d[i]>d[c]+mp[c][i]) + { + d[i]=d[c]+mp[c][i]; + if(!v[i]) v[i]=1,q[cnt++]=i; + } + } + } + return d[t]; +} + +}/// End of NameSpace SPFA + +bool labled[SPFA::MAXN]; + +int main() +{ + using namespace SPFA; + int T,S,D; + while(scanf("%d %d %d",&T,&S,&D)==3) + { + memset(mp,0x3f,sizeof(mp)); + memset(labled,false,sizeof(labled)); + n=0; + for(int i=0;i