原创 Hdu-6035 Colorful Tree(dfs)

  Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 375    Acc

原创 VK Cup 2017 - Round 3 D. Perishable Roads(最短路)

In the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road

原创 Xiangtan Invitation Contest 2017 - C Similar Subsequence(高斯消元)

Intersection Bobo has two sets of integers A={a1,a2,…,an} and B={b1,b2,…,bn}. He says that x∈span(A) (or span(B)) i

原创 Codeforces Round #416 (Div. 2) E. Vladik and Entertaining Flags(線段樹+並查集)

In his spare time Vladik estimates beauty of the flags. Every flag could be represented as the matrix n × m which co

原创 UESTC-1633 去年春恨卻來時,落花人獨立,微雨燕雙飛(取模最短路)

給你一個大小爲n的集合S,集合裏有n個互不相同正整數.有q個詢問,每次詢問是否能選擇S中的一些數字 ( 同一個數字可以選擇多次,也可以任何數字都不選),使它們相加的和爲m.Input第一行一個數n(1≤n≤2000),表示集合S的大小.第

原创 Hdu-6086 Rikka with String(AC自動機+DP)

As we know, Rikka is poor at math. Yuta is worrying about this situation,

原创 Codeforces Round #170 (Div. 1) E. Binary Tree on Plane(費用流)

A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to a

原创 Hdu-6052 To my boyfriend(單調棧)

Dear Liao  I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you

原创 Hdu-4661 Message Passing(樹形DP)

There are n people numbered from 1 to n. Each people have a unique message. Some pairs of people can send messages dire

原创 Hdu-5519 Kykneion asma(狀壓DP+容斥)

On the last day before the famous mathematician Swan's death, he left a problem to the world: Given integers nn and aia

原创 Codeforces Round #614 (Div. 1) D. Chaotic V.

"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect. The time right n

原创 Codeforces Round #182 (Div. 1) Yaroslav and Divisors(離線+樹狀數組)

Yaroslav has an array p = p1, p2, ..., pn (1 ≤ pi ≤ n), consisting of n distinct integers. Also, he has m quer

原创 Hdu-6053 TrickGCD(莫比烏斯函數)

You are given an array A, and Zhu wants to know there are how many different array B satisfy the following condition

原创 Poj-3696 The Luckiest number(數論)

Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. No

原创 Bzoj-3991 尋寶遊戲(dfs序)

 小B最近正在玩一個尋寶遊戲,這個遊戲的地圖中有N個村莊和N-1條道路,並且任何兩個村莊之間有且僅有一條路徑可達。遊戲開始時,玩家可以任意選擇一個村莊,瞬間轉移到這個村莊,然後可以任意在地圖的道路上行走,若走到某個村莊中有寶物,則視爲找到