原创 【NTT】 ZOJ 3874 Permutation Graph

推出公式以後分治ntt優化即可。。。 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 100005; const

原创 矩陣快速冪 CodeForces - 582B Once Again...

建出轉移矩陣...然後做矩陣快速冪就行了.... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 105; con

原创 [DP] HDOJ 5456 Matches Puzzle Game

數位DP... #include <bits/stdc++.h> using namespace std; typedef long long LL; LL dp[505][2][2][2]; int cnt[] = {6, 2, 5,

原创 HDOJ 5458 Stability

由於沒有看到圖在任意時刻都是連通的..這一條件..於是只好打了動態樹.. #include <bits/stdc++.h> using namespace std; typedef long long LL; const int max

原创 HDOJ 5469 Antonidas 樹分治

經典的樹分治,找字符串用hash找就行了.... #include <bits/stdc++.h> using namespace std; typedef long long LL; #define mp(x, y) make_pai

原创 [半平面交] HDOJ 5462 Manors

很容易就能看出半平面交的公式...但是比賽的時候這題看都來不及看... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn

原创 【NTT】 HDOJ 5279 YJC plays Minecraft

推出公式以後就可以ntt了。。。 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int mod = 998244353; const

原创 hihocoder #1236 : Scores

高維bitset.... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 50005; struct node

原创 [網絡流] HDOJ 5457 Hold Your Hand

建出字典樹,然後做最小割就行了... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 5005; const in

原创 DP HDOJ 5471 Count the Grid

先轉化成了離散網格圖,然後狀態dp即可.... #include <bits/stdc++.h> using namespace std; typedef long long LL; #define mp(x, y) make_pair

原创 【矩陣快速冪】 HDOJ 5434 Peace small elephant

對每一列狀態壓縮,然後矩陣加速即可。。。 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int mod = 1e9+7; const

原创 樹鏈剖分 JAG Summer 2012 Day 4 D Do use segment tree

樹鏈剖分裸題.... #include <bits/stdc++.h> using namespace std; typedef long long LL; #define lson o << 1, L, mid #define rso

原创 HDOJ 5483 Nux Walpurgis

先做出最小生成樹,然後對每個點dfs判斷樹邊是否可刪..... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 3

原创 [線段樹] HDOJ Excited Database

把一個矩陣化成3個三角形容斥,然後用等差線段樹就可以做了... #include <bits/stdc++.h> using namespace std; typedef long long LL; #define now o, L,

原创 DP HDOJ 5492 Find a path

化簡公式然後遞推.... #include <bits/stdc++.h> using namespace std; typedef long long LL; const int INF = 0x3f3f3f3f; int dp[3