
Counting Rectangles is Fun
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 […]
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 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 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 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 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 […]
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. […]