Berbagi teknologi

Catatan Acak Kode Day76 (Teori Grafik Bagian 11)

2024-07-08

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

97.Xiao Ming pergi ke taman (Floyd)

tema:97. Xiao Ming pergi ke taman (kamacoder.com)

Ide:

Menjawab
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