原创 【分治 求最近點對】hdu 1007 Quoit Design

Link:http://acm.split.hdu.edu.cn/showproblem.php?pid=1007 #include <bits/stdc++.h> using namespace std; /* hdu 1007 題意

原创 【Ac自動機 查詢是否存在一個字典中的字符串】hihocoder 1036 Trie圖

Link:http://hihocoder.com/problemset/problem/1036?sid=1157591 // 需要優化 #include <bits/stdc++.h> using namespace std; co

原创 【Tire 求字典出現的前綴個數】hihocoder 1014 Trie樹

Link:http://hihocoder.com/problemset/problem/1014 #include<bits/stdc++.h> using namespace std; typedef long long LL;

原创 【Ac自動機+矩陣加速】poj 2778 DNA Sequence

Link:http://poj.org/problem?id=2778 字典樹的每個節點作爲一個狀態,矩陣記錄i點走一步的可行的狀態轉移的方法數,用矩陣快速冪計算所有可行的方法數。 //#include <bits/stdc++.h>

原创 【樹狀數組 區間更新區間查詢】code

Link:http://codevs.cn/problem/1082/ #include<cstdio> #include<cstring> #i

原创 【樹狀數組 單點修改,區間求值】hdu 1166 敵兵佈陣

Link:http://acm.hdu.edu.cn/showproblem.php?pid=1166 #include <bits/stdc++.h> using namespace std; const int N = 5e4+5

原创 【dp】codeforces 837D Round Subset

Link:http://codeforces.com/problemset/problem/837/D #include <bits/stdc++.h> using namespace std; typedef long long LL

原创 【二維樹狀數組】poj 2155 Matrix

Link:http://poj.org/problem?id=2155 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typede

原创 【樹狀數組 求比其小的個數】poj 2353 Stars

Link:http://poj.org/problem?id=2352 注意:x,y的範圍是0-32000,樹狀數組是無法處理0的,將處理的所有數加1放入樹狀數組。 #include<cstdio> #include<cstring>

原创 【樹形dp】poj 1947 Rebuilding Roads

Link:http://poj.org/problem?id=1947 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using

原创 【dfs】poj 1020 Anniversary Cake

Link:http://poj.org/problem?id=1020 #include <cstdio> #include <cstring> using namespace std; /* poj 1020 題意:問是否能將n個小

原创 【dp+離散化+線段樹優化】Paint

題意: 求不相交的區間集合,沒有覆蓋到的範圍最小 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 4e5+10; co

原创 【樹狀數組 區間修改,單點求值】1556 Color the ball

Link:http://acm.split.hdu.edu.cn/showproblem.php?pid=1556 #include<cstdio> #include<cstring> #include<algorithm> using

原创 【數位dp 求滿足的值和】hihocoder 1033 交錯和

Link:http://hihocoder.com/problemset/problem/1033 #include<bits/stdc++.h> using namespace std; typedef long long LL; c

原创 【尺取】hdu 6103 Kirinriki

Link:http://acm.split.hdu.edu.cn/showproblem.php?pid=6103 #include <bits/stdc++.h> using namespace std; const int N =