原创 HDU 1548(A strange lift)
廣搜題,每次搜索上下兩個方向即可。 #include <iostream> #include <cstring> #include <queue> using namespace std; const int MAXN = 205;
原创 HDU 1555(How many days?)
基礎題。 #include <iostream> using namespace std; int main() { int M, k; while (cin >> M >> k) { if (M == 0 && k ==
原创 HDU 1543(Paint the Wall)
由於數據量很小,直接將每個矩形離散化,即拆分成小正方形,並記錄每個小正方形的顏色,最後掃描一遍全圖即可。 #include <iostream> #include <algorithm> #include <cstring> using
原创 HDU 1560(DNA sequence)
深搜題。 #include <iostream> #include <cstring> #include <algorithm> using namespace std; struct Sequence //DNA序列 { char
原创 HDU 1545(01-K Code)
動態規劃題,設 dp[i][j][k] 表示長爲 i 的子序列中,0 比 1 最多多 j 個,1 比 0 最多多 k 個。 如果第 i+1 位填0,則 dp[i + 1][j + 1][max(k - 1, 0)] += dp[i][j]
原创 HDU 1547(Bubble Shooter)
#include <iostream> #include <cstring> #include <queue> using namespace std; const int MAXN = 105; int R, C; char mp[
原创 HDU 1554(Pairs of integers)
#include <iostream> #include <map> #include <iomanip> using namespace std; int N; int H, S, L; int X; map<int, int> r
原创 HDU 1546(Idiomatic Phrases Game)
使用 Dijkstra算法,首先建立有向圖,將每個單詞作爲一個結點,和能直接接在其後的單詞連線,然後計算起點到終點的最短距離即可。 #include <iostream> #include <cstring> using namespa
原创 HDU 1558(Segment set)
使用並查集,每輸入一條線段,從頭掃描已輸入的所有線段,找到與新輸入線段相交的線段,合併兩者。 #include <iostream> #include <cstring> using namespace std; const int M
原创 HDU 1557(權利指數)
二進制狀態壓縮,然後暴力破解即可。 #include <iostream> #include <cstring> using namespace std; const int MAXN = 25; int num[MAXN],
原创 HDU 1540(Tunnel Warfare)
#include <iostream> #include <stack> using namespace std; const int MAXN = 50005; int L[4 * MAXN], R[4 * MAXN]; int f
原创 HDU 1539(Shredding Company)
深搜題。 #include <iostream> #include <cstring> using namespace std; const int MAXN = 25; int n; //目標數字 char str[MAXN]; /
原创 HDU 1536(S-Nim)
SG函數題,套用標準模板即可。 #include <iostream> #include <cstring> using namespace std; int sg[10005], num[105]; int k; //計算sg[x
原创 HDU 1538(A Puzzle for Pirates)
#include <iostream> using namespace std; //2的冪 int fac[15] = { 2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,3
原创 HDU 1534(Schedule Problem)
#include <iostream> #include <cstring> #include <string> #include <queue> using namespace std; const int MAXN = 1005;