# bzoj1880: [Sdoi2009]Elaxia的路線

## 代碼：

/*************************************************************
Problem: bzoj 1880 [Sdoi2009]Elaxia的路線
User: fengyuan
Language: C++
Result: Accepted
Time: 1148 ms
Memory: 54796 kb
Submit_Time: 2018-01-24 17:07:19
*************************************************************/

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cctype>
#include<cstdlib>
#include<cmath>
#include<queue>
using namespace std;
typedef long long ll;

char ch = getchar(); ll x = 0; int op = 1;
for(; !isdigit(ch); ch = getchar()) if(ch == '-') op = -1;
for(; isdigit(ch); ch = getchar()) x = x*10+ch-'0';
return x*op;
}
inline void write(ll a) {
if(a < 0) putchar('-'), a = -a;
if(a >= 10) write(a/10); putchar('0'+a%10);
}

const int N = 1510;
int n, m, ans, cnt, s1, s2, t1, t2;
bool vis[N];
struct edge {
int to, nxt, v;
edge() {}
edge(int x, int y, int z) { to = x, nxt = y, v = z; }
}e[N*N<<1];

inline void addedge(int x, int y, int z) { e[++ cnt] = edge(y, head[x], z); head[x] = cnt; }
inline void addedge2(int x, int y, int z) { e[++ cnt] = edge(y, head2[x], z); head2[x] = cnt; }
inline void spfa(int p, int s) {
queue<int> q; q.push(s); dis[p][s] = 0; memset(vis, 0, sizeof vis); vis[s] = 1;
while(!q.empty()) {
int u = q.front(); q.pop(); vis[u] = 0;
for(int i = head[u]; i; i = e[i].nxt) {
int v = e[i].to;
if(dis[p][v] > dis[p][u]+e[i].v) {
dis[p][v] = dis[p][u]+e[i].v;
if(!vis[v]) { vis[v] = 1; q.push(v); }
}
}
}
}
inline void tp() {
queue<int> q; memset(dp, 0, sizeof dp);
for(int i = 1; i <= n; i ++) if(!in[i]) q.push(i);
while(!q.empty()) {
int u = q.front(); q.pop(); ans = max(ans, dp[u]);
for(int i = head2[u]; i; i = e[i].nxt) {
int v = e[i].to; in[v] --;
dp[v] = max(dp[v], dp[u]+e[i].v);
if(!in[v]) q.push(v);
}
}
}
int main() {
for(int i = 1; i <= m; i ++) {
} memset(dis, 0x3f, sizeof dis);
spfa(0, s1); spfa(1, t1); spfa(2, s2); spfa(3, t2);
for(int i = 1; i <= n; i ++)
for(int j = head[i]; j; j = e[j].nxt) {
int k = e[j].to;
if(dis[0][i]+dis[1][k]+e[j].v == dis[0][t1] && dis[2][i]+dis[3][k]+e[j].v == dis[2][t2]) {
}
}
tp();
for(int i = 1; i <= n; i ++)
for(int j = head[i]; j; j = e[j].nxt) {
int k = e[j].to;
if(dis[0][i]+dis[1][k]+e[j].v == dis[0][t1] && dis[2][i]+dis[3][k]+e[j].v == dis[2][s2]) {
}