题目链接:uva 10917 - Walk Through the Forest
做一遍最短路,记录下所有点到终点的距离,然后重新建图,如果d[u] < d[v]那么就在u和v之间建立一条有向边,最后记忆化搜索。
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn = 1005;
const int inf = 0x3f3f3f3f;
int N, M, D[maxn], P[maxn], V[maxn], C[maxn];
ll dp[maxn];
vector<int> T[maxn];
vector<pii> G[maxn];
struct State {
int dis, idx;
State (int dis = 0,