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 […]

Fox and Card Game

2020 VietMX 0

Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer […]

Fox and Box Accumulation

2020 VietMX 0

Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most x i boxes […]

Fox and Perfect Sets

2020 VietMX 0

Fox Ciel studies number theory. She thinks a non-empty set S contains non-negative integers is perfect if and only if for any  ( a can be equal to b), . Where operation xor means exclusive or […]

Long Path

2020 VietMX 0

One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of […]

Triangle

2020 VietMX 0

There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane […]

Curious Array

2020 VietMX 0

You’ve got an array consisting of n integers: a[1], a[2], …, a[n]. Moreover, there are m queries, each query can be described by three integers l i, r i, k i. Query l i, r i, k i means that we should add  to each element a[j], where l i ≤ j ≤ r i. […]