原创 LCT練習
————學習LCT的同學建議去研究楊哲大神的《QTREE解法的一些研究》,自覺講得十分詳細。 LCT的核心算法也就是幾個過程:access.makeroot,link,cut…… 搞出這幾個過程LCT也不是啥難寫的東西啦。 在最近做了幾
原创 [bzoj 1049] HAOI2006數字序列
這題放了很久了,這次終於下定決心切掉他! 第一問很好處理,把值減去標作爲新值,求最長不下降序列即可。 第二問,有一個很好的性質。 還是處理第一問中的新值,發現最優解中兩個不變點i,j之間的數都是小於a[i]或大於a[j],並且修改之後存在
原创 除草(3.30~4.4)
1、travel 基本把樹剖忘光了。。。 注意到b樹上的點至多對應a樹上的一個點,詢問要求b樹上的一條路徑對應a樹上幾條路徑。 簡單的說就是把樹上的路徑剖成logn段,每段我們都可以利用主席樹對每段查詢即可。 #include #in
原创 POJ1811 Prime Test
Miller_Rabin+Pollard_rho 算導上都有,貼模板啦 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typ
原创 省選模版複習——FFT
hdu1402 大整數乘法, 裸FFT #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; co
原创 [ural 1960] Palindromes and Super Abilities
繼續練習模版。 迴文樹。。。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int Maxn=100005; c
原创 記些東西
1、寫FFT時需要對N位二進制翻轉,我一直都是開一個rev數組預處理來搞的,如下 for (N=2, M=1;N<(n+m);N<<=1, M++); for (i=0;i<N;i++){ int len=0; for
原创 除草(4.6~4.11)
1、 加特技 水題,樹上揹包dp。 #include #include #include using namespace std; int w[105],v[105],d[105],fa[105],f[105][505]; i
原创 [bzoj 2565] 最長雙迴文串
似乎把這題些頹了。 Manacher預處理,得到g[]數組。 之後蒟蒻就開始無腦的用數據結構大法了。。。 慢得飛起 #include <map> #include <cstdio> #include <cstring> #include
原创 省選模版複習——主席樹
bzoj3653 談笑風生 dfs序,主席樹水過去吧 #include <vector> #include <cstdio> #include <cstring> #include <algorithm> using namespace
原创 省選模版複習——後綴數組
bzoj3238 後綴數組水 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int Maxn=500005;
原创 2015年國家集訓隊測試 矩陣變換
居然給想出解法了。。。。 從題目中我們可以看出,每個數一定是儘量取列靠後的。 如果這樣一行中出現了多個數怎麼辦?拿紙出來畫一畫可以發現我們因該保留靠前的那一個而把靠後的一個再向前一列取一下。 #include <vector> #incl
原创 省選模版複習——線性篩法
bzoj 3944 sum 求phi和mu的前綴和,n<2^31 首先orz叉院lyp大神的講義。 以下爲lyp大神講義的公式推導過程(我不生產公式,我只是大神的搬運工~~) 假設我們需要求f(x)的前綴和 令g(n)=sigma f(d
原创 hdu 4344 Mark the Rope
依然是pollard_rho和Miller_Rabin的模版。。。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const
原创 [bzoj 3563&3569]DZY Loves Chinese I&II
3263是道sb題,隨便水過去吧。。。。。 3569纔是正真的神題! 用dfs搞出一棵生成樹,把邊分爲樹邊和非樹邊。 對於非樹邊我們隨機分配一個數值給他,而樹邊上的值爲覆蓋其所有非樹邊權值的異或和。 我們來看一看刪邊的情況: 1、僅刪除非