Technology sharing

Code Random Record Day76 (Graph Theoria Parte 11)

2024-07-08

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

97.Xiao Ming ad hortis publicis accedit (Floyd)

Argumentum:97. Xiao Ming ad hortis accedit (kamacoder.com)

Idea:

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