Cut Tree

Cerinta completa Given a tree T with n nodes, how many subtrees (T’) of T have at most K edges connected to (T – T’)? Input Format The first line contains two integers n and K followed by n-1 lines

DAG Queries

Cerinta completa You are given a Directed Acyclic Graph (DAG) with vertices and edges. Each vertex has an integer, , associated with it and the initial value of is for all vertices. You must perform queries on the DAG, where

Covering the stains

Cerinta completa There is a huge blanket on your bed but unfortunately it has N stains. You cover them using a single, rectangular silk cloth. The silk is expensive, which is why the rectangular piece needs to have the least

Cut the sticks

Cerinta completa You are given a number of sticks of varying lengths. You will iteratively cut the sticks into smaller sticks, discarding the shortest pieces until there are none left. At each iteration you will determine the length of the

Counting Sort 2

Cerinta completa Often, when a list is sorted, the elements being sorted are just keys to other values. For example, if you are sorting files by their size, the sizes need to stay connected to their respective files. You cannot

Counting the Ways

Cerinta completa Little Walter likes playing with his toy scales. He has types of weights. The weight type has weight . There are infinitely many weights of each type. Recently, Walter defined a function, , denoting the number of different

Counting Valleys

Cerinta completa An avid hiker keeps meticulous records of their hikes. During the last hike that took exactly steps, for every step it was noted if it was an uphill, , or a downhill, step. Hikes always start and end