Problem ID
stringlengths
2
6
Problem Description
stringlengths
0
7.52k
Rating
float64
800
3.5k
math
bool
2 classes
greedy
bool
2 classes
implementation
bool
2 classes
dp
bool
2 classes
data structures
bool
2 classes
constructive algorithms
bool
2 classes
brute force
bool
2 classes
binary search
bool
2 classes
sortings
bool
2 classes
graphs
bool
2 classes
__index_level_0__
int64
3
9.98k
85D
In one well-known algorithm of finding the _k_-th order statistics we should divide all elements into groups of five consecutive elements and find the median of each five. A median is called the middle element of a sorted array (it's the third largest element for a group of five). To increase the algorithm's performanc...
2,300
false
false
true
false
true
false
true
true
false
false
9,543
44J
There are many interesting tasks on domino tilings. For example, an interesting fact is known. Let us take a standard chessboard (8u2009×u20098) and cut exactly two squares out of it. It turns out that the resulting board can always be tiled using dominoes 1u2009×u20092, if the two cut out squares are of the same color...
2,000
false
true
false
false
false
true
false
false
false
false
9,760
659F
The farmer Polycarp has a warehouse with hay, which can be represented as an _n_u2009×u2009_m_ rectangular table, where _n_ is the number of rows, and _m_ is the number of columns in the table. Each cell of the table contains a haystack. The height in meters of the hay located in the _i_-th row and the _j_-th column is...
2,000
false
true
false
false
false
false
false
false
true
true
7,184
509C
Problem - 509C - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,000
false
true
true
true
false
false
false
false
false
false
7,804
1118A
Polycarp wants to cook a soup. To do it, he needs to buy exactly $$$n$$$ liters of water. There are only two types of water bottles in the nearby shop — $$$1$$$-liter bottles and $$$2$$$-liter bottles. There are infinitely many bottles of these two types in the shop. The bottle of the first type costs $$$a$$$ burles an...
800
true
false
false
false
false
false
false
false
false
false
5,102
1425I
Mr. Chanek has an orchard structured as a rooted ternary tree with $$$N$$$ vertices numbered from $$$1$$$ to $$$N$$$. The root of the tree is vertex $$$1$$$. $$$P_i$$$ denotes the parent of vertex $$$i$$$, for $$$(2 le i le N)$$$. Interestingly, the height of the tree is not greater than $$$10$$$. Height of a tree is d...
2,800
false
false
false
false
true
false
false
false
false
false
3,540
234A
One fine October day a mathematics teacher Vasily Petrov went to a class and saw there _n_ pupils who sat at the desks, two people at each desk. Vasily quickly realized that number _n_ is even. Like all true mathematicians, Vasily has all students numbered from 1 to _n_. But Vasily Petrov did not like the way the child...
1,200
false
false
true
false
false
false
false
false
false
false
8,904
416B
A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of _n_ painters who decided to organize their work as follows. Each painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the first painter uses color ...
1,300
false
false
true
true
false
false
true
false
false
false
8,161
570D
Roman planted a tree consisting of _n_ vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the _n_u2009-u20091 remaining vertices has a parent in the tree. Vertex is connected with its parent by an edge. The parent of vertex _i_ is vertex _p__i_, the parent index is alwa...
2,200
false
false
false
false
false
true
false
true
false
true
7,568
1677D
Tokitsukaze has a permutation $$$p$$$. She performed the following operation to $$$p$$$ exactly $$$k$$$ times: in one operation, for each $$$i$$$ from $$$1$$$ to $$$n - 1$$$ in order, if $$$p_i$$$ > $$$p_{i+1}$$$, swap $$$p_i$$$, $$$p_{i+1}$$$. After exactly $$$k$$$ times of operations, Tokitsukaze got a new sequence $...
2,500
true
false
false
true
false
false
false
false
false
false
2,203
1695E
Polycarp and Monocarp are both solving the same puzzle with dominoes. They are given the same set of $$$n$$$ dominoes, the $$$i$$$-th of which contains two numbers $$$x_i$$$ and $$$y_i$$$. They are also both given the same $$$m$$$ by $$$k$$$ grid of values $$$a_{ij}$$$ such that $$$mcdot k = 2n$$$. The puzzle asks them...
2,700
false
false
false
false
false
true
false
false
false
true
2,109
540A
Problem - 540A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
800
false
false
true
false
false
false
false
false
false
false
7,680
132B
Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet language with simplified rules. The program will be a rectangular image consisting of colo...
2,100
false
false
true
false
false
false
false
false
false
false
9,346
616D
Problem - 616D - Codeforces =============== xa0 — the number of elements in _a_ and the parameter _k_. The second line contains _n_ integers _a__i_ (0u2009≤u2009_a__i_u2009≤u2009106) — the elements of the array _a_. Output Print two integers _l_,u2009_r_ (1u2009≤u2009_l_u2009≤u2009_r_u2009≤u2009_n_) — the...
1,600
false
false
false
false
true
false
false
true
false
false
7,372
1056D
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $$$1$$$ to $$$n$$$, the junction $$$1$$$ is called the root. A subtree of a junction $...
1,600
false
true
false
true
false
true
false
false
true
true
5,429
1949K
You are given $$$n$$$ positive integers $$$x_1, x_2, ldots, x_n$$$ and three positive integers $$$n_a, n_b, n_c$$$ satisfying $$$n_a+n_b+n_c = n$$$. You want to split the $$$n$$$ positive integers into three groups, so that: The first group contains $$$n_a$$$ numbers, the second group contains $$$n_b$$$ numbers, the t...
2,800
true
false
false
false
false
true
false
false
false
false
582
1790B
Taisia has $$$n$$$ six-sided dice. Each face of the die is marked with a number from $$$1$$$ to $$$6$$$, each number from $$$1$$$ to $$$6$$$ is used once. Taisia rolls all $$$n$$$ dice at the same time and gets a sequence of values $$$a_1, a_2, ldots, a_n$$$ ($$$1 le a_i le 6$$$), where $$$a_i$$$ is the value on the up...
800
true
true
false
false
false
false
false
false
false
false
1,541
25D
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are _n_ cities in Berland and neighboring countries in total and exactly _n_u2009-u200...
1,900
false
false
false
false
false
false
false
false
false
true
9,870
1574B
You are given four integer values $$$a$$$, $$$b$$$, $$$c$$$ and $$$m$$$. Check if there exists a string that contains: $$$a$$$ letters 'A'; $$$b$$$ letters 'B'; $$$c$$$ letters 'C'; no other letters; exactly $$$m$$$ pairs of adjacent equal letters (exactly $$$m$$$ such positions $$$i$$$ that the $$$i$$$-th letter ...
1,100
true
true
false
false
false
false
false
false
false
false
2,773
1713B
Consider an array $$$a$$$ of $$$n$$$ positive integers. You may perform the following operation: select two indices $$$l$$$ and $$$r$$$ ($$$1 leq l leq r leq n$$$), then decrease all elements $$$a_l, a_{l + 1}, dots, a_r$$$ by $$$1$$$. Let's call $$$f(a)$$$ the minimum number of operations needed to change array $$$a...
1,000
false
false
false
false
false
true
false
false
true
false
2,005
314B
Problem - 314B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,000
false
false
false
false
false
false
false
true
false
false
8,589
1543D2
This is the hard version of the problem. The only difference is that here $$$2leq kleq 100$$$. You can make hacks only if both the versions of the problem are solved. This is an interactive problem! Every decimal number has a base $$$k$$$ equivalent. The individual digits of a base $$$k$$$ number are called $$$k$$$-its...
2,200
true
false
false
false
false
true
true
false
false
false
2,924
778C
Peterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set of words, and word is a sequence of lowercase Latin letters. Peterson makes new language every morning. It is difficult task to store the whole language, so Peterson have invented new data structure for storing his langu...
2,500
false
false
false
false
false
false
true
false
false
false
6,654
1715D
The Narrator has an integer array $$$a$$$ of length $$$n$$$, but he will only tell you the size $$$n$$$ and $$$q$$$ statements, each of them being three integers $$$i, j, x$$$, which means that $$$a_i mid a_j = x$$$, where $$$$$$ denotes the . In the next $$$q$$$ lines you are given with three integers $$$i$$$, $$$j$$$...
1,900
false
true
false
false
false
false
false
false
false
true
1,990
38A
Problem - 38A - Codeforces =============== xa0 - Codeforces Beta Round 38 (ACM-ICPC Rules)]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these pro...
800
false
false
true
false
false
false
false
false
false
false
9,808
873E
Alexey recently held a programming contest for students from Berland. _n_ students participated in a contest, _i_-th of them solved _a__i_ problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different degrees. Each student either will receive one diploma of some degree...
2,300
false
false
false
true
true
false
true
false
false
false
6,250
400A
There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" ...
1,000
false
false
true
false
false
false
false
false
false
false
8,227
839A
Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies. At first, Arya and Bran have 0 Candies. There are _n_ days, at the _i_-th day, Arya finds _a__i_ candies in a box, that is given by the Many-Faced God. Every day she can give Bran at most 8 of h...
900
false
false
true
false
false
false
false
false
false
false
6,408
1677C
Tokitsukaze has two colorful tapes. There are $$$n$$$ distinct colors, numbered $$$1$$$ through $$$n$$$, and each color appears exactly once on each of the two tapes. Denote the color of the $$$i$$$-th position of the first tape as $$$ca_i$$$, and the color of the $$$i$$$-th position of the second tape as $$$cb_i$$$. N...
1,900
false
true
false
false
false
true
false
false
false
true
2,204
154C
You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user. The social network contains _n_ registered profiles, numbered from 1 to _n_. Some pairs there are friends (the "friendship" relationship is mutual,...
2,300
false
false
false
false
false
false
false
false
true
true
9,257
887D
There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by _a_ and after each fashion show decreases by _b_ (designers do too many experiments nowadays)....
2,400
false
false
false
false
true
false
false
false
false
false
6,199
1958E
Suppose you have a permutation $$$p$$$ of $$$n$$$ integers — an array where each element is an integer from $$$1$$$ to $$$n$$$, and every integer from $$$1$$$ to $$$n$$$ appears exactly once. In one operation, you remove every element of this permutation which is less than at least one of its neighbors. For example, wh...
1,900
false
false
false
false
false
true
false
false
false
false
522
903F
You are given a matrix _f_ with 4 rows and _n_ columns. Each element of the matrix is either an asterisk (*) or a dot (.). You may perform the following operation arbitrary number of times: choose a square submatrix of _f_ with size _k_u2009×u2009_k_ (where 1u2009≤u2009_k_u2009≤u20094) and replace each element of the c...
2,200
false
false
false
true
false
false
false
false
false
false
6,129
1901C
You are given an integer array $$$a_1, a_2, dots, a_n$$$ ($$$0 le a_i le 10^9$$$). In one operation, you can choose an integer $$$x$$$ ($$$0 le x le 10^{18}$$$) and replace $$$a_i$$$ with $$$lfloor frac{a_i + x}{2} floor$$$ ($$$lfloor y floor$$$ denotes rounding $$$y$$$ down to the nearest integer) for all $$$i$$$ fr...
1,400
true
true
false
false
false
true
false
false
false
false
907
1396D
Shrimpy Duc is a fat and greedy boy who is always hungry. After a while of searching for food to satisfy his never-ending hunger, Shrimpy Duc finds M&M candies lying unguarded on a $$$L imes L$$$ grid. There are $$$n$$$ M&M candies on the grid, the $$$i$$$-th M&M is currently located at $$$(x_i + 0.5, y_i + 0.5),$$$ a...
3,300
false
false
false
false
true
false
false
false
true
false
3,690
1131D
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review xa0— in each restaurant Mr. Apple orders two sets of dishes on two different days. All the...
2,000
false
true
false
true
false
false
false
false
false
true
5,065
16E
Problem - 16E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - so...
1,900
false
false
false
true
false
false
false
false
false
false
9,911
1666F
Little Fiona has a collection of $$$n$$$ blocks of various sizes $$$a_1, a_2, ldots, a_n$$$, where $$$n$$$ is even. Some of the blocks can be equal in size. She would like to put all these blocks one onto another to form a fancy stack. Let $$$b_1, b_2, ldots, b_n$$$ be the sizes of blocks in the stack from top to botto...
2,200
false
false
true
true
false
false
false
false
false
false
2,280
168B
Let's dive into one of the most interesting areas of magic — writing spells. Learning this exciting but challenging science is very troublesome, so now you will not learn the magic words, but only get to know the basic rules of writing spells. Each spell consists of several lines. The line, whose first non-space charac...
1,700
false
false
true
false
false
false
false
false
false
false
9,189
891E
Problem - 891E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
3,000
true
false
false
false
false
false
false
false
false
false
6,184
181A
The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang. The Berland capital's map is represented by an _n_u2009×u2009_m_ rectangular table. Each cell of the table on the map represents some districts of the capital. The capital's main detective Polycarpus took a map an...
800
false
false
true
false
false
false
true
false
false
false
9,116
1979C
You have been offered to play a game. In this game, there are $$$n$$$ possible outcomes, and for each of them, you must bet a certain integer amount of coins. In the event that the $$$i$$$-th outcome turns out to be winning, you will receive back the amount of coins equal to your bet on that outcome, multiplied by $$$k...
1,200
false
false
false
false
false
true
false
true
false
false
414
1693F
You are given a binary string $$$S$$$ of length $$$n$$$ indexed from $$$1$$$ to $$$n$$$. You can perform the following operation any number of times (possibly zero): Choose two integers $$$l$$$ and $$$r$$$ ($$$1 le l le r le n$$$). Let $$$cnt_0$$$ be the number of times 0 occurs in $$$S[l ldots r]$$$ and $$$cnt_1$$$ b...
3,400
false
true
false
false
false
false
false
true
false
false
2,117
1019A
As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the number of voters and the number of partiesxa0— $$$n$$$ and $$$m$$$ respectively. ...
1,700
false
true
false
false
false
false
true
false
false
false
5,597
843E
You are given a directed graph, consisting of _n_ vertices and _m_ edges. The vertices _s_ and _t_ are marked as source and sink correspondingly. Additionally, there are no edges ending at _s_ and there are no edges beginning in _t_. The graph was constructed in a following way: initially each edge had capacity _c__i_u...
3,000
false
false
false
false
false
false
false
false
false
true
6,387
42D
Problem - 42D - Codeforces =============== xa0 assigned to it and all prices are distinct. But the most striking thing about this town is that each city sightseeing tour has the same total price! That is, if we choose any city sightseeing tour — a cycle which visits every attraction exactly once — the...
2,300
true
false
false
false
false
true
false
false
false
false
9,776
1819D
Schoolboy Misha got tired of doing sports programming, so he decided to quit everything and go to the magical forest to sell magic apples. His friend Danya came to the magical forest to visit Misha. What was his surprise when he found out that Misha found a lot of friends there, the same former sports programmers. And ...
2,800
false
false
false
true
true
false
true
false
false
false
1,362
132E
Another feature of Shakespeare language is that the variables are named after characters of plays by Shakespeare, and all operations on them (value assignment, output etc.) look like a dialog with other characters. New values of variables are defined in a rather lengthy way, so a programmer should try to minimize their...
2,700
false
false
false
false
false
false
false
false
false
true
9,343
475B
Imagine a city with _n_ horizontal streets crossing _m_ vertical streets, forming an (_n_u2009-u20091)u2009×u2009(_m_u2009-u20091) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or onl...
1,400
false
false
true
false
false
false
true
false
false
true
7,933
1218B
Bob Bubblestrong just got a new job as security guard. Bob is now responsible for safety of a collection of warehouses, each containing the most valuable Bubble Cup assets - the high-quality bubbles. His task is to detect thieves inside the warehouses and call the police. Looking from the sky, each warehouse has a shap...
3,000
false
false
false
false
true
false
false
false
false
false
4,583
1725F
Pak Chanek is traveling to Manado. It turns out that OSN (Indonesian National Scientific Olympiad) 2019 is being held. The contestants of OSN 2019 are currently lining up in a field to be photographed. The field is shaped like a grid of size $$$N imes 10^{100}$$$ with $$$N$$$ rows and $$$10^{100}$$$ columns. The rows ...
2,100
false
false
false
false
true
false
false
false
true
false
1,941
78C
Two beavers, Timur and Marsel, play the following game. There are _n_ logs, each of exactly _m_ meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of each one is expressed by an integer and is no less than _k_ meters...
2,000
false
false
false
true
false
false
false
false
false
false
9,573
1864D
There is a matrix of size $$$n imes n$$$ which consists of 0s and 1s. The rows are numbered from $$$1$$$ to $$$n$$$ from top to bottom, the columns are numbered from $$$1$$$ to $$$n$$$ from left to right. The cell at the intersection of the $$$x$$$-th row and the $$$y$$$-th column is denoted as $$$(x, y)$$$. AquaMoon ...
1,700
true
true
false
true
true
true
true
false
false
false
1,094
18E
According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field _n_u2009×u2009_m_, each square should be wholly painted one of 26 colours. The following restrictions are set: In each row at most two different colours can be used. No two adjacent squares can be painted the sam...
2,000
false
false
false
true
false
false
false
false
false
false
9,901
1809E
There are two water tanks, the first one fits $$$a$$$ liters of water, the second one fits $$$b$$$ liters of water. The first tank has $$$c$$$ ($$$0 le c le a$$$) liters of water initially, the second tank has $$$d$$$ ($$$0 le d le b$$$) liters of water initially. You want to perform $$$n$$$ operations on them. The $$$...
2,400
true
false
true
true
false
false
false
true
false
false
1,416
768F
Tarly has two different type of items, food boxes and wine barrels. There are _f_ food boxes and _w_ wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no t...
2,300
true
false
false
false
false
false
true
false
false
false
6,708
1968F
Let us call an array $$$x_1,dots,x_m$$$ interesting if it is possible to divide the array into $$$k>1$$$ parts so that xa0— the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$2 le n le 2 cdot 10^5$$$, $$$1 le q le 2 cdot 10^5$$$)xa0— the number of elements in the ar...
1,800
false
false
false
false
true
false
false
true
false
false
495
1534F2
This is the hard version of the problem. The difference between the versions is the constraints on $$$a_i$$$. You can make hacks only if all versions of the problem are solved. Little Dormi has recently received a puzzle from his friend and needs your help to solve it. The puzzle consists of an upright board with $$$n$...
3,000
false
true
false
true
false
false
false
false
false
true
2,977
420A
Problem - 420A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,000
false
false
true
false
false
false
false
false
false
false
8,150
1760C
There are $$$n$$$ participants in a competition, participant $$$i$$$ having a strength of $$$s_i$$$. Every participant wonders how much of an advantage they have over the other best participant. In other words, each participant $$$i$$$ wants to know the difference between $$$s_i$$$ and $$$s_j$$$, where $$$j$$$ is the s...
800
false
false
true
false
true
false
false
false
true
false
1,753
76A
The kingdom of Olympia consists of _N_ cities and _M_ bidirectional roads. Each road connects exactly two cities and two cities can be connected with more than one road. Also it possible that some roads connect city with itself making a loop. All roads are constantly plundered with bandits. After a while bandits became...
2,200
false
false
false
false
false
false
false
false
true
true
9,586
1840G2
The only difference between easy and hard versions is the maximum number of queries. In this version, you are allowed to ask at most $$$1000$$$ queries. This is an interactive problem. You are playing a game. The circle is divided into $$$n$$$ sectors, sectors are numbered from $$$1$$$ to $$$n$$$ in some order. You are...
2,500
true
false
false
false
false
true
false
false
false
false
1,246
1593B
It is given a positive integer $$$n$$$. In $$$1$$$ move, one can select any single digit and remove it (i.e. one selects some position in the number and removes the digit located at this position). The operation cannot be performed if only one digit remains. If the resulting number contains leading zeroes, they are aut...
900
true
true
false
true
false
false
false
false
false
false
2,685
1834A
Given an array $$$a$$$ of length $$$n$$$, which elements are equal to $$$-1$$$ and $$$1$$$. Let's call the array $$$a$$$ good if the following conditions are held at the same time: $$$a_1 + a_2 + ldots + a_n ge 0$$$; $$$a_1 cdot a_2 cdot ldots cdot a_n = 1$$$. In one operation, you can select an arbitrary element of ...
800
true
true
false
false
false
false
false
false
false
false
1,284
701A
There are _n_ cards (_n_ is even) in the deck. Each card has a positive integer written on it. _n_u2009/u20092 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the ca...
800
false
true
true
false
false
false
false
false
false
false
7,020
938E
Problem - 938E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,300
true
false
false
false
false
false
false
false
false
false
5,947
129B
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
1,200
false
false
true
false
false
false
true
false
false
true
9,364
360B
Problem - 360B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,000
false
false
false
true
false
false
false
true
false
false
8,393
744A
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries. The world can be modeled as an undirected graph with _n_ nodes and _m_ edges. _k_ of the nodes are home to the governments of the _k_ countries that make up the world. There is at mo...
1,500
false
false
false
false
false
false
false
false
false
true
6,824
1895G
You are given a string consisting of characters 0 and/or 1. You have to paint every character of this string into one of two colors, red or blue. If you paint the $$$i$$$-th character red, you get $$$r_i$$$ coins. If you paint it blue, you get $$$b_i$$$ coins. After coloring the string, you remove every blue character ...
3,100
false
true
false
true
true
false
false
true
false
false
938
1499C
Let's say you are standing on the $$$XY$$$-plane at point $$$(0, 0)$$$ and you want to reach point $$$(n, n)$$$. You can move only in two directions: to the right, i.xa0e. horizontally and in the direction that increase your $$$x$$$ coordinate, or up, i.xa0e. vertically and in the direction that increase your $$$y$$$...
1,500
true
true
false
false
true
false
true
false
false
false
3,173
1003F
You are given a text consisting of $$$n$$$ space-separated words. There is exactly one space character between any pair of adjacent words. There are no spaces before the first word and no spaces after the last word. The length of text is the number of letters and spaces in it. $$$w_i$$$ is the $$$i$$$-th word of text. ...
2,200
false
false
false
true
false
false
false
false
false
false
5,669
1037D
The which denotes the number of nodes in the tree. The following $$$n - 1$$$ lines describe the edges of the tree. Each of them contains two integers $$$x$$$ and $$$y$$$ ($$$1 le x, y le n$$$)xa0— the endpoints of the corresponding edge of the tree. It is guaranteed that the given graph is a tree. The last line contain...
1,700
false
false
false
false
false
false
false
false
false
true
5,513
954C
There is a matrix _A_ of size _x_u2009×u2009_y_ filled with integers. For every , _A__i_,u2009_j_u2009=u2009_y_(_i_u2009-u20091)u2009+u2009_j_. Obviously, every integer from [1.._xy_] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cel...
1,700
false
false
true
false
false
false
false
false
false
false
5,907
1950E
You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase Latin characters. Find the length of the shortest string $$$k$$$ such that several (possibly one) copies of $$$k$$$ can be concatenated together to form a string with the same length as $$$s$$$ and, at most, one different character. More formally,...
1,500
false
false
true
false
false
false
true
false
false
false
577
1012A
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $$$(x, y)$$$, such that $$$x_1 leq x leq x_2$$$ and $$$y_1 leq y leq y_2$$$...
1,500
true
false
true
false
false
false
true
false
true
false
5,627
1846A
There are $$$n$$$ nails driven into the wall, the $$$i$$$-th nail is driven $$$a_i$$$ meters above the ground, one end of the $$$b_i$$$ meters long rope is tied to it. All nails hang at different heights one above the other. One candy is tied to all ropes at once. Candy is tied to end of a rope that is not tied to a na...
800
true
false
true
false
false
false
false
false
false
false
1,208
34E
Problem - 34E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - so...
2,000
true
false
true
false
false
false
true
false
false
false
9,824
311A
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given _n_ points in the plane, find a pair of points betwee...
1,300
false
false
true
false
false
true
false
false
false
false
8,602
141E
After Santa Claus and his assistant Elf delivered all the presents and made all the wishes come true, they returned to the North Pole and found out that it is all covered with snow. Both of them were quite tired and they decided only to remove the snow from the roads connecting huts. The North Pole has _n_ huts connect...
2,300
false
false
false
true
false
true
false
false
false
true
9,308
1415A
There is a prison that can be represented as a rectangular matrix with $$$n$$$ rows and $$$m$$$ columns. Therefore, there are $$$n cdot m$$$ prison cells. There are also $$$n cdot m$$$ prisoners, one in each prison cell. Let's denote the cell in the $$$i$$$-th row and the $$$j$$$-th column as $$$(i, j)$$$. There's a se...
800
true
false
false
false
false
false
true
false
false
false
3,608
507E
Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers. Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of ...
2,100
false
false
false
true
false
false
false
false
false
true
7,812
1501B
This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead. To bake a Napoleon cake, one has to bake $$$...
900
false
false
true
true
false
false
false
false
true
false
3,161
1248D1
This is an easier version of the problem. In this version, $$$n le 500$$$. Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya b...
2,000
false
true
true
true
false
false
true
false
false
false
4,465
1442B
We start with a permutation $$$a_1, a_2, ldots, a_n$$$ and with an empty array $$$b$$$. We apply the following operation $$$k$$$ times. On the $$$i$$$-th iteration, we select an index $$$t_i$$$ ($$$1 le t_i le n-i+1$$$), remove $$$a_{t_i}$$$ from the array, and append one of the numbers $$$a_{t_i-1}$$$ or $$$a_{t_i+1}$...
1,800
false
true
true
false
true
false
false
false
false
false
3,463
802J
Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver states: "Send the fool further!", and upon reading it the recipient will ask Heidi to d...
1,400
false
false
false
false
false
false
false
false
false
true
6,558
702F
The big consignment of t-shirts goes on sale in the shop before the beginning of the spring. In all _n_ types of t-shirts go on sale. The t-shirt of the _i_-th type has two integer parameters — _c__i_ and _q__i_, where _c__i_ — is the price of the _i_-th type t-shirt, _q__i_ — is the quality of the _i_-th type t-shirt....
2,800
false
false
false
false
true
false
false
false
false
false
7,012
14E
Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with _t_ humps, representing them as polylines in the plane. Each polyline consists of _n_ vertices with coordinates (_x_1,u2009_y_1), (_x_2,u2009_y_2), ..., (_...
1,900
false
false
false
true
false
false
false
false
false
false
9,921
1579A
Casimir has a string $$$s$$$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions: he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent); or he can er...
800
true
false
false
false
false
false
false
false
false
false
2,741
1534D
This is an interactive problem. Little Dormi was faced with an awkward problem at the carnival: he has to guess the edges of an unweighted tree of $$$n$$$ nodes! The nodes of the tree are numbered from $$$1$$$ to $$$n$$$. The game master only allows him to ask one type of question: Little Dormi picks a node $$$r$$$ ($...
1,800
false
false
false
false
false
true
false
false
false
false
2,980
343C
Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but _n_ different heads that can read data in parallel. When viewed from the side, Mike's hard drive is an endless array of tracks. The tracks of the array are numbered from left to right with integers, starting with 1. In th...
1,900
false
true
false
false
false
false
false
true
false
false
8,461
1506A
Polycarp found a rectangular table consisting of $$$n$$$ rows and $$$m$$$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": cells are numbered starting from one; cells are numbered from left to right by columns, and inside each column from top to bottom;...
800
true
false
false
false
false
false
false
false
false
false
3,143
1016G
Since next season are coming, you'd like to form a team from two or three participants. There are $$$n$$$ candidates, the $$$i$$$-th candidate has rank $$$a_i$$$. But you have weird requirements for your teammates: if you have rank $$$v$$$ and have chosen the $$$i$$$-th and $$$j$$$-th candidate, then $$$GCD(v, a_i) = X...
2,700
true
false
false
false
false
false
false
false
false
false
5,606
594C
Edo has got a collection of _n_ refrigerator magnets! He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be posi...
2,300
false
true
true
false
false
false
true
false
false
false
7,470
1371F
2,800
false
false
true
false
true
false
false
false
false
false
3,808
171A
Problem - 171A - Codeforces =============== xa0 , separated by a single space. Output Output a single integer. Examples Input 3 14 Output 44 Input 27 12 Output 48 Input 100 200 Output 102
1,200
false
false
false
false
false
true
false
false
false
false
9,186
683I
A loader works in a warehouse, which is a rectangular field with size _n_u2009×u2009_m_. Some cells of this field are free, others are occupied by pillars on which the roof of the warehouse rests. There is a load in one of the free cells, and the loader in another. At any moment, the loader and the load can not be in t...
2,500
false
false
false
false
false
false
false
false
false
true
7,085
1582E
Pchelyonok decided to give Mila a gift. Pchelenok has already bought an array $$$a$$$ of length $$$n$$$, but gifting an array is too common. Instead of that, he decided to gift Mila the segments of that array! Pchelyonok wants his gift to be beautiful, so he decided to choose $$$k$$$ non-overlapping segments of the arr...
2,000
true
true
false
true
true
false
false
true
false
false
2,721
1569C
$$$n$$$ people gathered to hold a jury meeting of the upcoming competition, the $$$i$$$-th member of the jury came up with $$$a_i$$$ tasks, which they want to share with each other. First, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation $$$p$$$ of numbers from ...
1,500
true
false
false
false
false
false
false
false
false
false
2,796
222D
A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least _x_ points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have only points, no names. The teacher has to know Vasya's chances....
1,900
false
true
false
false
false
false
false
true
true
false
8,949