随笔分类 - 差分约束
摘要:http://poj.org/problem?id=1275 1 #include 2 #include 3 #include 4 #define maxn 2000 5 using namespace std; 6 const int inf=1dis[p[j].u]+p[j].w) 31 { 32 dis[p[j].v]=dis[p[j].u]+p[j].w; 33 flag=true; 34 } 35 } 36 if(!flag...
阅读全文
摘要:http://poj.org/problem?id=2983 1 #include 2 #include 3 #include 4 #define maxm 5000100 5 #define maxn 3010 6 using namespace std; 7 int head[maxn],next[maxn],dis[maxn]; 8 bool vis[maxn]; 9 int e,n,m;10 const int inf=1dis[p[j].u]+p[j].c)59 {60 dis[p[j].v]=dis[p[j].u]+p[j]....
阅读全文
摘要:http://poj.org/problem?id=1201 1 #include 2 #include 3 #include 4 #define maxn 500100 5 using namespace std; 6 7 int head[maxn],next[maxn],dis[maxn]; 8 bool vis[maxn]; 9 const int inf=1-1)68 {69 int pre=a[top--];70 vis[pre]=false;71 for(int i=head[pre]; i+1; i=next[i])72...
阅读全文
摘要:http://poj.org/problem?id=1364 1 #include 2 #include 3 #include 4 #include 5 #define maxn 51000 6 using namespace std; 7 8 const int inf=1dis[u]+c)29 {30 dis[v]=dis[u]+c;31 return true;32 }33 return false;34 }35 36 void inti()37 {38 memset(head,-1,sizeof(head));39 ...
阅读全文
摘要:http://poj.org/problem?id=3159 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define max1 30005 7 #define max2 150005 8 using namespace std; 9 int head[max1],next[max2];10 int dis[max1];11 bool vis[max1];12 const int inf=1a.c;29 }30 };31 int e,n,m;32 void addnode(int u,int v,int c)33 ...
阅读全文

浙公网安备 33010602011771号