Technology Sharing

Code Thoughts Day76 (Graph Theory Part 11)

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

97. Xiao Ming visits the park (Floyd)

topic:97. Xiao Ming visits the park (kamacoder.com)

Ideas:

Answer
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();  // 顶点数
        int m = scanner.nextInt();  // 边数

        int[][] grid = new int[n   1][n   1];
        final int INF = 10005; // 因为边的最大距离是10^4

        // 初始化图的邻接矩阵
        for (int i = 1; i