
Closest Equals
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 […]
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 […]
ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. […]
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 […]
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 […]
Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his […]
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 is the main character of a game “Cut the Rope”. He is a bright little monster who likes visiting friends living at the […]
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 […]
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 […]
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 […]
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 […]
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. […]
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 […]
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 […]
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 […]
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 […]
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 […]