Closest Equals

2020 VietMX 0

You are given sequence a 1, a 2, …, a n and m queries l j, r j (1 ≤ l j ≤ r j ≤ n). For each query you need to print the minimum distance between such pair of elements a x and a y ( x ≠ y), that: both indexes of the elements […]

Rooks and Rectangles

2020 VietMX 2

Polycarpus has a chessboard of size n × m, where k rooks are placed. Polycarpus hasn’t yet invented the rules of the game he will play. However, he has already […]

Social Network

2020 VietMX 0

Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social […]

King of Thieves

2020 VietMX 0

In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called “King of Thieves” your aim […]

Om Nom and Candies

2020 VietMX 0

A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think […]

Om Nom and Necklace

2020 VietMX 0

One day Om Nom found a thread with n beads of different colors. He decided to cut the first several beads from this thread to make a […]

Transmitting Levels

2020 VietMX 0

Optimizing the amount of data transmitted via a network is an important and interesting part of developing any network application. In one secret game developed […]

Correcting Mistakes

2020 VietMX 0

Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what […]

Work Group

2020 VietMX 0

One Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. […]

Board Game

2020 VietMX 0

Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move […]

Encoding

2020 VietMX 0

Polycarp invented a new way to encode strings. Let’s assume that we have string T, consisting of lowercase English letters. Let’s choose several pairs of letters […]

Landmarks

2020 VietMX 0

We have an old building with n + 2 columns in a row. These columns support the ceiling. These columns are located in points with coordinates 0 = x 0 < x 1 < … < x n < x n + 1. The leftmost and […]

Berland Miners

2020 VietMX 0

The biggest gold mine in Berland consists of n caves, connected by n - 1 transitions. The entrance to the mine leads to the cave number 1, it is possible to go […]

Quest

2020 VietMX 0

Polycarp is making a quest for his friends. He has already made n tasks, for each task the boy evaluated how interesting it is as an integer q i, […]

Playing on Graph

2020 VietMX 0

Vova and Marina love offering puzzles to each other. Today Marina offered Vova to cope with the following task. Vova has a non-directed graph consisting […]

Place Your Ad Here

2020 VietMX 0

Ivan Anatolyevich’s agency is starting to become famous in the town. They have already ordered and made n TV commercial videos. Each video is made in a […]

Superhero’s Job

2020 VietMX 0

It’s tough to be a superhero. And it’s twice as tough to resist the supervillain who is cool at math. Suppose that you’re an ordinary […]