Interesting Array

2020 VietMX 0

We’ll call an array of n non-negative integers a[1], a[2], …, a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers l i, r i, q i (1 ≤ l i ≤ r i ≤ n) meaning that value  should be equal to q i. Your task is […]

Random Function and Tree

2020 VietMX 0

You have a rooted tree consisting of n vertices. Let’s number them with integers from 1 to n inclusive. The root of the tree is the vertex 1. For each i > 1 direct parent of […]

Game with Strings

2020 VietMX 0

You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you […]

ELCA

2020 VietMX 0

You have a root tree containing n vertexes. Let’s number the tree vertexes with integers from 1 to n. The tree root is in the vertex 1. Each vertex (except fot […]

Vanya and Lanterns

2020 VietMX 0

Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to […]

Vanya and Cubes

2020 VietMX 0

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must […]

Vanya and Exams

2020 VietMX 0

Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at […]

Vanya and Field

2020 VietMX 0

Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (x i, y i). Vanya moves towards […]

Vanya and Computer Game

2020 VietMX 0

Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya’s character performs attack with frequency x hits per […]

Treasure

2020 VietMX 0

Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the […]

Obsessive String

2020 VietMX 0

Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he […]

Sharti

2020 VietMX 0

During the last 24 hours Hamed and Malek spent all their time playing “Sharti”. Now they are too exhausted to finish the last round. So […]

Helping People

2020 VietMX 0

Malek is a rich man. He also is very generous. That’s why he decided to split his money between poor people. A charity institute knows n poor […]

Birthday

2020 VietMX 0

Ali is Hamed’s little brother and tomorrow is his birthday. Hamed wants his brother to earn his gift so he gave him a hard programming […]

New Year Permutation

2020 VietMX 0

User ainta has a permutation p 1, p 2, …, p n. As the New Year is coming, he wants to make his permutation as pretty as possible. Permutation a 1, a 2, …, a n is prettier than permutation b 1, b 2, …, b n, if and […]

New Year Transportation

2020 VietMX 0

New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was […]

New Year Book Reading

2020 VietMX 0

New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The […]

New Year Santa Network

2020 VietMX 0

New Year is coming in Tree World! In this world, as the name implies, there are n cities connected by n - 1 roads, and for any two distinct cities there […]

New Year Domino

2020 VietMX 0

Celebrating the new year, many people post videos of falling dominoes; Here’s a list of them: https://www.youtube.com/results?search_query=New+Years+Dominos User ainta, who lives in a 2D world, is […]

New Year Shopping

2020 VietMX 0

Dohyun is running a grocery store. He sells n items numbered by integers from 1 to n. The i-th (1 ≤ i ≤ n) of them costs c i dollars, and if I buy it, my […]