文章

14

粉丝

0

获赞

3

访问

939

头像
最短路径问题 题解:有多个目标的单元最短路径,在while循环里面判断即可
P1344 浙江大学机试题
发布于2025年8月17日 14:35
阅读数 79

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <list>
#include <string>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#include <queue>

using namespace std;

struct edge {
    int target;
    int length;
    int cost;
};

vector<int>dist;
vector<int>cost;

struct compare_dist {
    bool operator()(int& a, int& b) {
        return dist[a] > dist[b];
    }
};

int main() {

    int n, m;
    while (cin >> n >> m) {
        if (n == 0)break;
        map<int, vector<edge>>graph;
        dist.resize(n + 1); cost.resize(n + 1);
  ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发