原创 線性dp+倒序思想 Codeforces P859C Pie Rules

Pie Rules You may have heard of the pie rule before. It states that if two people wish to fairly share a slice of p

原创 權值線段樹+思維 牛客練習賽66 E題 騷區間

騷區間 這種貢獻題可以發現,固定一個右邊界 i ,然後在 1–i-1 找出所有符合條件的左邊界 j ; 所以可以預處理出在 (1–i-1) 中大於 a[i] 的第一個元素位置p1,和第二個元素位置p2, 那麼(p2+1,p1)就是

原创 二維前綴和思想 Codeforces Good Bye 2015 C題 New Year and Domino

New Year and Domino They say “years are like dominoes, tumbling one after the other”. But would a year fit into a g

原创 線性dp+數學思維 Codeforces Round #533 (Div. 2) C題 Ayoub and Lost Array

Ayoub and Lost Array Ayoub had an array a of integers of size n and this array had two interesting properties: All

原创 線性dp Codeforces Round #260 (Div. 1) A題 Boredom

Boredom Alex doesn’t like boredom. That’s why whenever he gets bored, he comes up with games. One long winter eveni

原创 雙指針+思維 Codeforces Round #354 (Div. 2) C題 Vasya and String

Vasya and String High school student Vasya got a string of length n as a birthday present. This string consists of

原创 樹形dp Codeforces Round #168 (Div. 2) D題 Zero Tree

Zero Tree A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition

原创 並查集判環+思維 Codeforces Round #363 (Div. 2) D題 Fix a Tree

Fix a Tree A tree is an undirected connected graph without cycles. Let’s consider a rooted undirected tree with n v

原创 線段樹+思維 Codeforces Round #197 (Div. 2) D題 Xenia and Bit Operations

Xenia and Bit Operations Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1

原创 樹形結構+拓撲思維 Codeforces Round #285 (Div. 2) C題 Misha and Forest

Misha and Forest Let’s define a forest as a non-directed acyclic graph (also without loops and parallel edges). One

原创 構造思維+樹形結構 Codeforces Round #612 (Div. 2) D題 Numbers on Tree

Numbers on Tree Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its v

原创 樹形結構+dp思維 Codeforces Round #247 (Div. 2) C題 k-Tree

k-Tree Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and cam

原创 01字典樹+貪心 Codeforces Round #613 (Div. 2) D題 Dr. Evil Underscores

Dr. Evil Underscores Today, as a friendship gift, Bakry gave Badawy n integers a1,a2,…,an and challenged him to cho

原创 並查集判兩點是否連接 [HAOI2006]旅行(洛谷 P2502)

題目描述: n 個點 m 條邊,每條邊都有一個權值,問 s 到 t 路徑上 mx/mi 的最小值,mx,mi分別爲路徑上的最大邊和最小邊; 直接貪心把所有邊由大到小排序,然後依次枚舉每條邊作爲最大邊,然後再枚舉邊作爲加邊,直到

原创 數學+線性dp 不等數列(洛谷 P2401)

不等數列 題目描述 將1到n任意排列,然後在排列的每兩個數之間根據他們的大小關係插入“>”和“<”。問在所有排列中,有多少個排列恰好有k個“<”。答案對2015取模。 注:1 ~ n的排列指的是1~n這n個數各出現且僅出現一次的數