
ACM


Captain Marmot
Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has n regiments, each consisting of 4 moles. Initially, each […]


Ant colony
Mole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≤ i ≤ n) has a strength s i. In order to make his […]


Diverse Permutation
Permutation p is an ordered set of integers p 1, p 2, …, p n, consisting of n distinct positive integers not larger than n. We’ll denote as n the length of permutation p 1, p 2, …, p n. Your task is to find such […]

Interesting Array
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
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
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 […]


Vanya and Lanterns
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
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
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
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
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 […]


Obsessive String
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 […]


Helping People
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 […]
