Sereja ans Anagrams

2020 VietMX 0

Sereja has two sequences a and b and number p. Sequence a consists of n integers a 1, a 2, …, a n. Similarly, sequence b consists of m integers b 1, b 2, …, b m. As usual, Sereja studies the sequences he has. Today he wants to find the number […]

Sereja and the Arrangement of Numbers

2020 VietMX 0

Let’s call an array consisting of n integer numbers a 1, a 2, …, a n, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in […]

Sereja and Algorithm

2020 VietMX 0

Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let’s represent the […]

Sereja and Sets

2020 VietMX 0

Sereja has m non-empty sets of integers A 1, A 2, …, A m. What a lucky coincidence! The given sets are a partition of the set of all integers from 1 to n. In […]

Sereja and Intervals

2020 VietMX 0

Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of […]

Counting Kangaroos is Fun

2020 VietMX 0

There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo’s pocket if and only if the size […]

Counting Rectangles is Fun

2020 VietMX 0

There is an n × m rectangular grid, each cell of the grid contains a single integer: zero or one. Let’s call the cell on the i-th row and the j-th […]

Watching Fireworks is Fun

2020 VietMX 0

A festival will be held in a town’s main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance […]

Choosing Subtree is Fun

2020 VietMX 0

There is a tree consisting of n vertices. The vertices are numbered from 1 to n. Let’s define the length of an interval [l, r] as the value r - l + 1. The score of a subtree […]

Maze

2020 VietMX 0

Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one […]

Developing Game

2020 VietMX 0

Pavel is going to make a game of his dream. However, he knows that he can’t make it on his own so he founded a […]

Preparing for the Contest

2020 VietMX 0

Soon there will be held the world’s largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has no choice […]

Captains Mode

2020 VietMX 0

Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which […]

Cookie Clicker

2020 VietMX 0

Kostya is playing the computer game Cookie Clicker. The goal of this game is to gather cookies. You can get cookies using different buildings: you can […]

New Year Candles

2020 VietMX 0

Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it […]

New Year Ratings Change

2020 VietMX 0

One very well-known internet resource site (let’s call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to […]

New Year Present

2020 VietMX 0

The New Year is coming! That’s why many people today are busy preparing New Year presents. Vasily the Programmer is no exception. Vasily knows that […]

New Year Letter

2020 VietMX 0

Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an […]

New Year Tree Decorations

2020 VietMX 0

Due to atheistic Soviet past, Christmas wasn’t officially celebrated in Russia for most of the twentieth century. As a result, the Russian traditions for Christmas […]

Fox and Minimal path

2020 VietMX 0

Fox Ciel wants to write a task for a programming contest. The task is: “You are given a simple undirected graph with n vertexes. Each its edge […]