Frog Jumping

2020 VietMX 0

A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it […]

Hot is Cold

2020 VietMX 0

You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. You will perform $q$ operations. In the $i$-th operation, you have a symbol […]

Leaf Partition

2020 VietMX 0

You are given a rooted tree with $n$ nodes, labeled from $1$ to $n$. The tree is rooted at node $1$. The parent of the […]

Satanic Panic

2020 VietMX 1

You are given a set of $n$ points in a 2D plane. No three points are collinear. A pentagram is a set of $5$ points […]

Three Integers Again

2020 VietMX 0

We have three positive integers $a$, $b$ and $c$. You don’t know their values, but you know some information about them. Consider all three pairwise sums, i.e. […]

Bad Days

2020 VietMX 0

Every day Kotlin heroes analyze the statistics of their website. For $n$ days, they wrote out $n$ numbers $a_1, a_2, \dots, a_n$, where $a_i$ is […]

Minus and Minus Give Plus

2020 VietMX 0

Everyone knows that two consecutive (adjacent) “minus” signs can be replaced with a single “plus” sign. You are given the string $s$, consisting of “plus” […]

Wheels

2020 VietMX 0

Polycarp has $n$ wheels and a car with $m$ slots for wheels. The initial pressure in the $i$-th wheel is $a_i$. Polycarp’s goal is to […]

Sliding Doors

2020 VietMX 0

Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress […]

Longest Saw

2020 VietMX 0

You are given the sequence $a_1, a_2, \dots, a_n$. You can choose any subset of elements and then reorder them to create a “saw”. The […]

Graph Decomposition

2020 VietMX 0

You are given an undirected graph consisting of $n$ vertices and $m$ edges. Recall that a cycle is a path that starts and ends in […]

Good Subsets

2020 VietMX 2

You are given $n$ segments on the $Ox$ axis. The $i$-th segment is given as a pair $l_i, r_i$, where $l_i$ is the position of […]

Another One Bites The Dust

2020 VietMX 0

Let’s call a string good if and only if it consists of only two types of letters — ‘a’ and ‘b’ and every two consecutive letters are distinct. […]

Crazy Diamond

2020 VietMX 0

You are given a permutation $p$ of integers from $1$ to $n$, where $n$ is an even number. Your goal is to sort the permutation. […]

Born This Way

2020 VietMX 0

Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of […]

Foo Fighters

2020 VietMX 0

You are given $n$ objects. Each object has two integer properties: $val_i$ — its price — and $mask_i$. It is guaranteed that the sum of all prices […]

Earth Wind and Fire

2020 VietMX 0

There are $n$ stones arranged on an axis. Initially the $i$-th stone is located at the coordinate $s_i$. There may be more than one stone […]