原创 poj2533

#include <iostream> #include <cstdio> #include <cstring> #include <climits> using namespace std; int n,a[1001],dp[1001

原创 poj3624

#include <iostream> #include <cstdio> #include <cstring> using namespace std; int n,m; int w[4000],d[4000],dp[13000];

原创 poj1797

承接 上一道的dij最短路  這次 雖然一次就有了正確的思路 寫出來了大部分正確的代碼 但還是 敗在了一個地方 輸入路的時候  路是無向的  所以map[x][y]=map[y][x] ..........................

原创 我的不知道對不對的dij模板

慢慢改吧 誰看到bug還希望好心指出來 #include <iostream> #include <cstdio> #include <cstring> #include <climits> #include <queue> #defin

原创 poj1258

#include <iostream> #include <cstdio> #include <cstring> #include <climits> #include <algorithm> using namespace std;

原创 poj2349

思路 :最小生成樹 將 所需路 的 長度 記錄下來  s個衛星 則 去掉 s -1個最長的路 輸出剩下的最長的路 #include <iostream> #include <cstdio> #include <cstring> #inc

原创 poj2965

剪枝十分重要  visi數組 記錄 已經在樹中的值 避免重複 #include <iostream> #include <cstdio> #include <climits> #include <cstring> #include <cs

原创 poj1062

也是看了別人的講解才懂得  之前 將1 作爲源點 有點蠢  然後枚舉路線也沒想出來  之前總是想 在算的時候維持一條正確的路線 但是好難啊  以後要換換思路  將可能的源點列出來 把不合適的路線當作訪問過

原创 poj3254

#include <iostream> #include <cstdio> #include <climits> #include <cstring> #include <cstdlib> using namespace std; int

原创 入門經典 無根樹轉化爲有根樹

無根樹 轉化爲有根 vector[] 記錄節點的子節點 int[] ->p p[i]=a 表示 i的父節點爲a #include <iostream> #include <vector> using namespace std; in

原创 poj1159

short int #include <iostream> #include <cstdio> #include <cstring> #include <climits> #include <algorithm> using names

原创 poj1050

最大子矩陣 遍歷 每一行 以低爲界 遍歷 改行與界之間的每一行 每一行 到 該行之間的每一列 分別相加 成爲一個數組  求數組最大連續子序列 #include<iostream> #include<cstdio> #include <c

原创 poj1088

羞恥的wa了很多次 因爲 沒讀好題  讓求的是經過 的 點 的個數的最大值  我一直算的 起點 終點 差值最大值  受教了。。 #include <iostream> #include <cstdio> #include <cstring

原创 poj 2385

1 從零開始dp 2 每一個dp的單元 要有邏輯  先根據當前狀態處理dp的值 或賦值 或爲初始值 再進行轉移(這一步正確的前提 是從0開始) #include <iostream> #include <cstdio> #include

原创 入門經典-最淳樸的dijkstra

之前有懷疑它的正確性 是因爲把他想成了一棵樹 求出來的不是最短的 然而學長講了後 我懂了 他是每找到最近的一個點 就優化所有的點 最近的潛力一定是最高的 之前寫的 把 邊 00 11.。。。寫成了INT_MAX 出來的都是負數 後來發現