Kay and Eternity

2020 VietMX 0

Snow Queen told Kay to form a word “eternity” using pieces of ice. Kay is eager to deal with the task, because he will then […]

LRU

2020 VietMX 0

While creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular caching algorithms […]

Break Up

2020 VietMX 21

Again, there are hard times in Berland! Many towns have such tensions that even civil war is possible. There are n towns in Reberland, some pairs of […]

Cron

2020 VietMX 0

Sometime the classic solution are not powerful enough and we have to design our own. For the purpose of this problem you have to implement […]

Huffman Coding on Segment

2020 VietMX 0

Alice wants to send an important message to Bob. Message a = (a 1, …, a n) is a sequence of positive integers (characters). To compress the message Alice wants to use binary […]

Coprime Permutation

2020 VietMX 0

Two positive integers are coprime if and only if they don’t have a common divisor greater than 1. Some bear doesn’t want to tell Radewoosh how […]

Limak and Shooting Points

2020 VietMX 0

Bearland is a dangerous place. Limak can’t travel on foot. Instead, he has k magic teleportation stones. Each stone can be used at most once. The i-th stone allows […]

King Moves

2020 VietMX 0

The only king stands on the standard chess board. You are given his position in format “cd”, where c is the column from ‘a’ to ‘h’ and d is […]

Optimal Point on a Line

2020 VietMX 0

You are given n points on a line with their coordinates x i. Find the point x so the sum of distances to the given points is minimal. Input The first […]

Generate a String

2020 VietMX 0

zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters ‘a’. He is too lazy to write […]

Magic Odd Square

2020 VietMX 0

Find an n × n matrix with different numbers from 1 to n 2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd […]

String Set Queries

2020 VietMX 0

You should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. It is guaranteed that the string s was […]

Two Arithmetic Progressions

2020 VietMX 0

You are given two arithmetic progressions: a 1 k + b 1 and a 2 l + b 2. Find the number of integers x such that L ≤ x ≤ R and x = a 1 k‘ + b 1 = a 2 l‘ + b 2, for some integers k‘, l‘ ≥ 0. Input The only line contains six integers a 1, b 1, a 2, b 2, L, R (0 < a 1, a 2 ≤ 2·109,  - 2·109 ≤ b 1, b 2, L, R ≤ 2·109, L ≤ R). Output Print the […]

Dexterina’s Lab

2020 VietMX 0

Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes […]

Potions Homework

2020 VietMX 10

Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they […]

Pokermon League challenge

2020 VietMX 0

Welcome to the world of Pokermon, yellow little mouse-like creatures, who absolutely love playing poker! Yeah, right… In the ensuing Pokermon League, there are n registered Pokermon […]