
ACM



One-Based Arithmetic
Prof. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent […]

Berland Federalization
Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is […]

Three Problems
Polycarp is choosing three problems for creating a programming test. Totally he has $n$ problems in his list. The complexity of the $i$-th problem equals […]

Traveling Around the Golden Ring of Berland
The Golden Ring is the special tourist route in Berland. This route consists of $n$ cities and the cyclic railway route. Cities are numbered from $1$ […]



Double Permutation Inc
Polycarp recently became an employee of the company “Double Permutation Inc.” Now he is a fan of permutations and is looking for them everywhere! A […]

King’s Path
There are $n$ cities and $n-1$ two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to […]

Road Repair in Treeland
There are $n$ cities and $n-1$ two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to […]

Unusual Graph
Ivan on his birthday was presented with array of non-negative integers $a_1, a_2, \ldots, a_n$. He immediately noted that all $a_i$ satisfy the condition $0 […]

Paint the Numbers
You are given a sequence of integers $a_1, a_2, \dots, a_n$. You need to paint elements in colors, so that: If we consider any color, […]

Koala and Lights
It is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically. After taking […]

Paint the Digits
You are given a sequence of $n$ digits $d_1d_2 \dots d_{n}$. You need to paint all the digits in two colors so that: each digit […]

Cow and Snacks
The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are […]

Rotate Columns (easy version)
This is an easier version of the next problem. The difference is only in constraints. You are given a rectangular $n \times m$ matrix $a$. […]

Rotate Columns (hard version)
This is a harder version of the problem. The difference is only in constraints. You are given a rectangular $n \times m$ matrix $a$. In […]

Into Blocks (easy version)
This is an easier version of the next problem. In this version, $q = 0$. A sequence of integers is called nice if its elements are arranged […]

Koala and Notebook
Koala Land consists of $m$ bidirectional roads connecting $n$ cities. The roads are numbered from $1$ to $m$ by order in input. It is guaranteed, […]