Cow and Exercise

2020 VietMX 98

Farmer John is obsessed with making Bessie exercise more! Bessie is out grazing on the farm, which consists of $n$ fields connected by $m$ directed […]

Cow and Vacation

2020 VietMX 92

Bessie is planning a vacation! In Cow-lifornia, there are $n$ cities, with $n-1$ bidirectional roads connecting them. It is guaranteed that one can reach any […]

Two Regular Polygons

2020 VietMX 0

You are given two integers $n$ and $m$ ($m < n$). Consider a convex regular polygon of $n$ vertices. Recall that a regular polygon is a polygon […]


2020 VietMX 2

You are given an array $a_1, a_2, \dots , a_n$. Array is good if for each pair of indexes $i < j$ the condition $j […]

Adding Powers

2020 VietMX 0

Suppose you are performing the following algorithm. There is an array $v_1, v_2, \dots, v_n$ filled with zeroes at start. The following operation is applied […]

Count the Arrays

2020 VietMX 0

Your task is to calculate the number of arrays such that: each array contains $n$ elements; each element is an integer from $1$ to $m$; […]

Array Shrinking

2020 VietMX 1

You are given an array $a_1, a_2, \dots, a_n$. You can perform the following operation any number of times: Choose a pair of two neighboring […]

Auto completion

2020 VietMX 0

You are given a set of strings $S$. Each string consists of lowercase Latin letters. For each string in this set, you want to calculate […]

Ehab the Xorcist

2020 VietMX 1

Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$. Input […]

Sum of Odd Integers

2020 VietMX 0

You are given two integers $n$ and $k$. Your task is to find if $n$ can be represented as a sum of $k$ distinct positive odd (not […]

Infinite Path

2020 VietMX 0

You are given a colored permutation $p_1, p_2, \dots, p_n$. The $i$-th element of the permutation has color $c_i$. Let’s define an infinite path as infinite sequence […]

Game with Chips

2020 VietMX 0

Petya has a rectangular Board of size $n \times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell […]

Count The Blocks

2020 VietMX 1

You wrote down all integers from $0$ to $10^n – 1$, padding them with leading zeroes so their lengths are exactly $n$. For example, if […]

Princesses and Princes

2020 VietMX 96

The King of Berland Polycarp LXXXIV has $n$ daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the […]

AND Segments

2020 VietMX 0

You are given three integers $n$, $k$, $m$ and $m$ conditions $(l_1, r_1, x_1), (l_2, r_2, x_2), \dots, (l_m, r_m, x_m)$. Calculate the number of […]