BZOJ2007

# 题解

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define mp(a,b) make_pair<LL,int>(a,b)
#define cls(s) memset(s,0,sizeof(s))
#define cp pair<LL,int>
#define LL long long int
#define id(x,y) (n * (x - 1) + y)
using namespace std;
const int maxn = 300005,maxm = 10000005;
const LL INF = 1000000000000000ll;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = -1; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 3) + (out << 1) + c - 48; c = getchar();}
return out * flag;
}
int h[maxn],ne;
struct EDGE{int to,nxt,w;}ed[maxm];
inline void build(int u,int v,int w){
ed[++ne] = (EDGE){v,h[u],w}; h[u] = ne;
}
int n,N,S,T,vis[maxn];
LL d[maxn];
priority_queue<cp,vector<cp>,greater<cp> > q;
void dijkstra(){
for (int i = 1; i <= N; i++) d[i] = INF; d[S] = 0;
q.push(mp(d[S],S));
int u;
while (!q.empty()){
u = q.top().second; q.pop();
if (vis[u]) continue;
vis[u] = true;
Redge(u) if (!vis[to = ed[k].to] && d[to] > d[u] + ed[k].w){
d[to] = d[u] + ed[k].w;
q.push(mp(d[to],to));
}
}
}
for (int i = 1; i <= n; i++) build(S,id(1,i),read());
for (int i = 1; i < n; i++){
for (int j = 1; j <= n; j++)
}
for (int i = 1; i <= n; i++) build(id(n,i),T,read());

for (int i = 1; i <= n; i++){
for (int j = 1; j < n; j++)
}

for (int i = 1; i <= n; i++) build(id(1,i),S,read());
for (int i = 1; i < n; i++){
for (int j = 1; j <= n; j++)
}
for (int i = 1; i <= n; i++) build(T,id(n,i),read());

for (int i = 1; i <= n; i++){
for (int j = 1; j < n; j++)