[SHOI2012]回家的路
分层图,每个转弯定义为一个操作,所以建立一个上层全是x轴,下层全是y轴,两层之间连一条权值为1的边代表转弯的代价。。挺简单的其实 https://www.luogu.com.cn/problem/P3831 #include<iostream> #include<cstring> #include<queue> #include<algorithm> #include<cstdio> #include<vector> using namespace std; typedef long long ll; const int INF = 1e17 + 11; const int maxn = 3e5 + 333; const int N = 1e5 + 11; ll dis[maxn]; int vis[maxn]; struct Node { int p; ll len; int nxt; }G[maxn * 2]; int z; int head[maxn]; void add(int be, int en, ll len) { G[++z].p = en; G[z].nxt = head[be]; G[z].len = len; head[be] = z; } bool operator <(const Node a, const Node b) { return a.len >