原创 POJ 3071 Football [概率DP]

Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, …, 2n. In each rou

原创 ZOJ 3329 One Person Game [概率DP]

Description There is a very simple and interesting one-person game. You have 3 dice, namely Die1, Die2 and Die3. Di

原创 CodeForces 148D Bag of mice [概率DP]

Description The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flyi

原创 HDU 4035 Maze [概率DP]

Description When wake up, lxhgww find himself in a huge maze.  The maze consisted by N rooms and tunnels connecting

原创 HDU 逆襲指數 [暴力]

Problem Description   這依然是關於高富帥小明曾經的故事——   儘管身處逆境,但小明一直沒有放棄努力,除了搬磚,小明還研究過東方的八卦以及西方的星座,一直試圖在命理上找到自己能夠逆襲的依據。   當這些都失敗以

原创 HDU 3565 Bi-peak Number [數位DP]

Description A peak number is defined as continuous digits {D0, D1 … Dn-1} (D0 > 0 and n >= 3), which exist Dm (0 < m

原创 ZOJ 2112 Dynamic Rankings [樹狀數組套主席樹]

Description The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the q

原创 HDU 5293 Tree chain problem [樹鏈剖分+線段樹+樹形DP]

Description Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n.  There are m chain on the tree, Eac

原创 HDU 3943 K-th Nya Number [數位DP]

Description Arcueid likes nya number very much.  A nya number is the number which has exactly X fours and Y sevens(I

原创 FZU 2113 Jason的特殊愛好 [數位DP]

題意:輸出a到b之間的整數包含多少個1。 解法:數位DP,滿足區間減法,所以可以考慮getsum(R)-getsum(L-1)。 因爲直接DP想法不是很直接,所以一般用dfs+記憶化來寫比較舒服,板子一般是這樣的: pos代表搜索到第幾

原创 BZOJ 8843 染色 [樹鏈剖分+區間線段樹]

Description 給定一棵有n個節點的無根樹和m個操作,操作有2類: 1、將節點a到節點b路徑上所有點都染成顏色c; 2、詢問節點a到節點b路徑上的顏色段數量(連續相同顏色被認爲是同一段),如“112221”由3段組成:“1

原创 HDU 4348 / SPOJ TTM To the moon [主席樹]

Description You‘ve been given N integers A[1], A[2],..., A[N]. On these integers, you need to implement the followi

原创 SPOJ D-query 區間不同數的個數 [在線主席樹 or 離線樹狀數組]

題意:給出N個數,M個詢問,每次詢問給出區間內不同數的個數。 解法:很經典的題目,可以將每一個數依次插入主席樹,插入時,將這個位置+1,並將最近的一個等值的位置-1即可。然後對於詢問區間L,R,只要在第R顆樹上詢問區間L,R的和就是答案。

原创 POJ 1655 Balancing Act [求樹的重心]

Description Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yield

原创 對於一類離散的概率DP問題的總結(第一次)

最近做了一些比較經典的概率DP的題(簡單題),在此對於這部分題先進行總結:(一些題沒有放在這裏,博客中都有) 對於這一類問題,需要注意: 不是所有離散的期望概率問題都需要概率DP,有時候需要對問題進行分析,再確定具體方法。   例如,如