文件目录

#include <bits/stdc++.h>
using namespace std;
int n, v, w[100][100];
string s;
int main()
{
    memset(w, 0x3f, sizeof(w));
    cin >> n >> v;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cin >> s;
            if (s == "-")
                w[i][j] = w[0][0];
            else
                w[i][j] = stoi(s);
        }
    }
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (w[i][j] > w[i][k] + w[k][j])
                    w[i][j] = w[i][k] + w[k][j];
    for (int i = 1; i <= n; i++)
    {
        if (i == v)
            continue;
        printf("(%d -> %d) = %d\n", v, i, w[v][i]);
    }
    return 0;
}