Counting Kangaroos is Fun

2020 VietMX 0

There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo’s pocket if and only if the size […]

Counting Rectangles is Fun

2020 VietMX 0

There is an n × m rectangular grid, each cell of the grid contains a single integer: zero or one. Let’s call the cell on the i-th row and the j-th […]

Watching Fireworks is Fun

2020 VietMX 0

A festival will be held in a town’s main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance […]

Choosing Subtree is Fun

2020 VietMX 0

There is a tree consisting of n vertices. The vertices are numbered from 1 to n. Let’s define the length of an interval [l, r] as the value r - l + 1. The score of a subtree […]

Serega and Fun

2020 VietMX 0

Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up with such […]