原创 HDU 1874 暢通工程續 最短路 Dijkstra 優先隊列優化

/* * 模板題 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; const int MAXM = 2e3 + 10; cons

原创 HDU 1535 Invitation Cards 最短路 SPFA

/* * 解題總結 : * 1 : 可以用鏈式前向星存圖,避免爆內存。 * 2 : 需要正向跑一遍最短路,然後方向建邊再跑一遍最短路。 * 3 : 由於要跑兩遍最短路,所以初始化要特別注意。 *

原创 HDU 1548 A strange lift SPFA

/* * 可以將由當前點能一步到達的點連上一條邊,然後跑最短路模板就行了。 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; co

原创 HDU 2112 Today Dijkstra 優先隊列優化

/* * 主要是用一個map和一個時間戳變量來分配id,其他都是模板 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; const

原创 HDU 3790 最短路徑問題 Dijkstra 優先隊列優化

/* * 注意題目要求的是先要滿足最短路的條件下,然後再是看能不能減小花費 * 具體可以看代碼註釋 */ #include <bits/stdc++.h> using namespace std; const int MAXN =

原创 HDU 2544 最短路 Dijkstra 優先隊列優化

/* * 模板題 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 1e2 + 10; const int MAXM = 2e4 + 10; cons

原创 HDU 3790 最短路徑問題 SPFA

/* * 注意題目要求的是先要滿足最短路的條件下,然後再是看能不能減小花費 * 具體可以看代碼註釋 */ #include <bits/stdc++.h> using namespace std; const int MAXN =

原创 HDU 2544 最短路 Floyed

/* * 模板題 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 1e2 + 10; const int MAXM = 1e5 + 10; cons

原创 HDU 1548 A strange lift dijkstra 優先隊列優化

/* * 可以將由當前點能一步到達的點連上一條邊,然後跑最短路模板就行了。 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; co

原创 HDU 2066 一個人的旅行 轉化爲單源最短路 Dijkstra 優先隊列優化

/* * 建立超級源點1010,將所有與草兒相連的城市與超級源點建立一條長度爲0的雙向邊。 * 然後就轉化爲單源最短路,跑模板就行了。 */ #include <bits/stdc++.h> using namespace std

原创 HDU 1047 Integer Inquiry 大數相加

import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args)

原创 HDU 1715 大菲波數 大數相加

import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args)

原创 HDU 2112 Today 最短路 SPFA

/* * 主要是用一個map和一個時間戳變量來分配id,其他都是模板 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; const

原创 HDU 1316 How Many Fibs? 大數相加

import java.math.BigInteger; import java.util.Scanner; public class Main{ public static void main(String[] args)

原创 HDU 1874 暢通工程續 最短路 Floyed

/* * 模板題 */ #include <bits/stdc++.h> using namespace std; const int MAXN = 2e2 + 10; const int MAXM = 2e3 + 10; cons