New Year and Forgotten Tree

2020 VietMX 0

A tree is a connected undirected graph with n - 1 edges, where n denotes the number of vertices. Vertices are numbered 1 through n. Limak is a little polar bear. His bear family prepares a […]

New Year and Cake

2020 VietMX 0

Limak is a little polar bear. According to some old traditions, his bear family prepared a New Year cake. And Limak likes cakes. As you […]

Professor GukiZ’s Robot

2020 VietMX 0

Professor GukiZ makes a new robot. The robot are in the point with coordinates (x 1, y 1) and should go to the point (x 2, y 2). In a single step the robot […]

Grandfather Dovlet’s calculator

2020 VietMX 0

Once Max found an electronic calculator from his grandfather Dovlet’s chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). Max starts to […]

Pearls in a Row

2020 VietMX 0

There are n pearls in a row. Let’s enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a i. Let’s call a sequence […]

New Year Tree

2020 VietMX 0

The New Year holidays are over, but Resha doesn’t want to throw away the New Year tree. He invited his best friends Kerim and Gural […]

Xors on Segments

2020 VietMX 0

You are given an array with n integers a i and m queries. Each query is described by two integers (l j, r j). Let’s define the function . The function is defined for only u ≤ v. For each […]

Robot Sequence

2020 VietMX 0

Calvin the robot lies in an infinite rectangular grid. Calvin’s source code contains a list of n commands, each either ‘U’, ‘R’, ‘D’, or ‘L’ — instructions to […]

Cards

2020 VietMX 0

Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she […]

Block Towers

2020 VietMX 0

Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the […]

Jerry’s Protest

2020 VietMX 0

Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry draw […]

Group Projects

2020 VietMX 0

There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their […]

Simple Skewness

2020 VietMX 0

Define the simple skewness of a collection of numbers to be the collection’s mean minus its median. You are given a list of n (not necessarily distinct) integers. Find […]

Raffles

2020 VietMX 0

Johnny is at a carnival which has n raffles. Raffle i has a prize with value p i. Each participant can put tickets in whichever raffles they choose (they may have […]

Ebony and Ivory

2020 VietMX 0

Dante is engaged in a fight with “The Savior”. Before he can fight it with his sword, he needs to break its shields. He has […]

A Trivial Problem

2020 VietMX 0

Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of […]

Spy Syndrome 2

2020 VietMX 0

After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can’t […]

Fibonacci-ish

2020 VietMX 0

Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at […]

The Chocolate Spree

2020 VietMX 0

Alice and Bob have a tree (undirected acyclic connected graph). There are a i chocolates waiting to be picked up in the i-th vertex of the tree. First, they […]