Starfleet

Cerinta completa In a galaxy far away, there is a constant battle between the republic and the droid army. The droid army decided to launch their final attack on the republic. They have N space-fighters. Initially the ith fighter is

Sum of the Maximums

Cerinta completa Alexey is playing with an array, , of integers. His friend, Ivan, asks him to calculate the sum of the maximum values for all subsegments of . More formally, he wants Alexey to find . Alexey solved Ivan’s

Unique Colors

Cerinta completa You are given an unrooted tree of nodes numbered from to . Each node has a color, . Let be the number of different colors in the path between node and node . For each node , calculate

Square-Ten Tree

Cerinta completa The square-ten tree decomposition of an array is defined as follows: The lowest () level of the square-ten tree consists of single array elements in their natural order. The level (starting from ) of the square-ten tree consists

Self-Driving Bus

Cerinta completa Treeland is a country with cities and roads. There is exactly one path between any two cities. The ruler of Treeland wants to implement a self-driving bus system and asks tree-loving Alex to plan the bus routes. Alex

Self Balancing Tree

Cerinta completa An AVL tree (Georgy Adelson-Velsky and Landis’ tree, named after the inventors) is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if