示例#1
0
    static object Solve()
    {
        var(n, m) = Read2();
        var map = GraphConsole.ReadWeightedMap(n + 1, m, false);

        var r1 = map.Dijkstra(1);
        var r2 = map.Dijkstra(n);

        return(string.Join("\n", Enumerable.Range(1, n).Select(v => r1[v] + r2[v])));
    }
示例#2
0
    static void Main()
    {
        var(n, m) = Read2();
        var map = GraphConsole.ReadWeightedMap(n + 1, m, true);

        var r = new long[n + 1];

        for (int ev = 1; ev <= n; ev++)
        {
            var result = ShortestPathCore.Dijkstra(n + 1, v => v == 0 ? map[ev] : map[v], 0, ev);
            r[ev] = result.GetCost(ev);
        }
        Console.WriteLine(string.Join("\n", r[1..]));