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
1838C
You are given integers $$$n$$$ and $$$m$$$. Fill an $$$n$$$ by $$$m$$$ grid with the integers $$$1$$$ through $$$ncdot m$$$, in such a way that for any two adjacent cells in the grid, the absolute difference of the values in those cells is not a prime number. Two cells in the grid are considered adjacent if they share ...
1,400
true
false
false
false
false
true
false
false
false
false
1,262
1695B
Mike and Joe are playing a game with some stones. Specifically, they have $$$n$$$ piles of stones of sizes $$$a_1, a_2, ldots, a_n$$$. These piles are arranged in a circle. The game goes as follows. Players take turns removing some positive number of stones from a pile in clockwise order starting from pile $$$1$$$. For...
1,000
false
true
false
false
false
false
false
false
false
false
2,113
2008B
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 970 (Div. 3) 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...
800
true
false
false
false
false
false
true
false
false
false
207
908E
Problem - 908E - Codeforces =============== xa0 ]( "g") ). The next _n_ lines will contain the elements of _T_. Each line will contain exactly _m_ zeros and ones. Elements of _T_ will be distinct. Output Print a single integer, the number of good sets modulo 109u2009+u20097. Examples Input 5 3 11010 0010...
2,500
true
false
false
true
false
false
false
false
false
false
6,116
280D
Consider integer sequence _a_1,u2009_a_2,u2009...,u2009_a__n_. You should run queries of two types: The query format is "0 _i_ _val_". In reply to this query you should make the following assignment: _a__i_u2009=u2009_val_. The query format is "1 _l_ _r_ _k_". In reply to this query you should print the maximum sum o...
2,800
false
false
true
false
true
false
false
false
false
true
8,712
1944B
You are given an array $$$a$$$ of length $$$2n$$$, consisting of each integer from $$$1$$$ to $$$n$$$ exactly twice. You are also given an integer $$$k$$$ ($$$1 leq k leq lfloor frac{n}{2} floor $$$). You need to find two arrays $$$l$$$ and $$$r$$$ each of length $$$mathbf{2k}$$$ such that: $$$l$$$ is a subset$$$^dag...
1,100
false
false
false
false
false
true
false
false
false
false
614
924C
Arkady decides to observe a river for _n_ consecutive days. The river's water level on each day is equal to some real value. Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water ...
1,700
false
true
false
true
true
false
false
false
false
false
6,015
1912A
Allyn is playing a new strategy game called "Accumulator Apex". In this game, Allyn is given the initial value of an integer $$$x$$$, referred to as the accumulator, and $$$k$$$ lists of integers. Allyn can make multiple turns. On each turn, Allyn can withdraw the leftmost element from any non-empty list and add it to ...
1,900
false
false
true
false
true
false
false
false
true
false
837
1617E
Christmas is coming, Icy has just received a box of chocolates from her grandparents! The box contains $$$n$$$ chocolates. The $$$i$$$-th chocolate has a non-negative integer type $$$a_i$$$. Icy believes that good things come in pairs. Unfortunately, all types of chocolates are distinct (all $$$a_i$$$ are distinct). Ic...
2,700
true
false
true
true
false
false
false
false
false
true
2,543
1784B
A cooperative game is played by $$$m$$$ people. In the game, there are $$$3m$$$ sheets of paper: $$$m$$$ sheets with letter 'w', $$$m$$$ sheets with letter 'i', and $$$m$$$ sheets with letter 'n'. Initially, each person is given three sheets (possibly with equal letters). The goal of the game is to allow each of the $$...
1,900
false
false
false
false
false
true
false
false
false
false
1,571
1722C
Three guys play a game: first, each person writes down $$$n$$$ distinct words of length $$$3$$$. Then, they total up the number of points as follows: if a word was written by one personxa0— that person gets 3 points, if a word was written by two peoplexa0— each of the two gets 1 point, if a word was written by allxa...
800
false
false
true
false
true
false
false
false
false
false
1,951
200D
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, de...
1,800
false
false
true
false
false
false
true
true
false
false
9,041
1215A
The final match of the Berland Football Cup has been held recently. The referee has shown $$$n$$$ yellow cards throughout the match. At the beginning of the match there were $$$a_1$$$ players in the first team and $$$a_2$$$ players in the second team. The rules of sending players off the game are a bit different in Ber...
1,000
true
true
true
false
false
false
false
false
false
false
4,603
1343A
Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ bu...
900
true
false
false
false
false
false
true
false
false
false
3,993
1152A
On a random day, Neko found $$$n$$$ treasure chests and $$$m$$$ keys. The $$$i$$$-th chest has an integer $$$a_i$$$ written on it and the $$$j$$$-th key has an integer $$$b_j$$$ on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible. The ...
800
true
true
true
false
false
false
false
false
false
false
4,956
720E
Borya has recently found a big electronic display. The computer that manages the display stores some integer number. The number has _n_ decimal digits, the display shows the encoded version of the number, where each digit is shown using some lowercase letter of the English alphabet. There is a legend near the display, ...
3,100
false
false
true
false
false
false
false
false
false
false
6,933
650C
Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name dis. Petya decided to compress tables. He is given a table _a_ consisting of _n_ rows and _m...
2,200
false
true
false
true
false
false
false
false
false
true
7,215
1081D
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago. You are given a connected undirected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. There are $$$k$$$ special vertices: $$$x_1, x_2, ldots, x_k$$$. Let's define the cost of the path as the maximum weight ...
1,800
false
false
false
false
false
false
false
false
true
true
5,320
1681F
Problem - 1681F - 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 - ...
2,300
false
false
false
true
true
false
false
false
false
false
2,180
1110H
Problem - 1110H - Codeforces =============== xa0 . The second line contains one integer $$$r$$$ ($$$l le r le 10^{800}$$$). The third line contains one integer $$$n$$$ ($$$1 le n le 2,000$$$). Output In the first line, print the maximum possible number of modest substrings. In the second line, print a str...
3,500
false
false
false
true
false
false
false
false
false
false
5,142
1713F
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 812 (Div. 2) 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...
2,900
true
false
false
true
false
true
false
false
false
false
2,001
452D
You have _k_ pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has _n_1 washing machines, _n_2 drying machines and _n_3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a piece of laundry before it is washed, and you can't fold it ...
1,900
false
true
true
false
false
false
false
false
false
false
8,029
1360C
We call two numbers $$$x$$$ and $$$y$$$ similar if they have the same parity (the same remainder when divided by $$$2$$$), or if $$$x-y=1$$$. For example, in each of the pairs $$$(2, 6)$$$, $$$(4, 3)$$$, $$$(11, 7)$$$, the numbers are similar to each other, and in the pairs $$$(1, 4)$$$, $$$(3, 12)$$$, they are not. Yo...
1,100
false
true
false
false
false
true
false
false
true
false
3,883
1620A
You had $$$n$$$ positive integers $$$a_1, a_2, dots, a_n$$$ arranged in a circle. For each pair of neighboring numbers ($$$a_1$$$ and $$$a_2$$$, $$$a_2$$$ and $$$a_3$$$, ..., $$$a_{n - 1}$$$ and $$$a_n$$$, and $$$a_n$$$ and $$$a_1$$$), you wrote down: are the numbers in the pair equal or not. Unfortunately, you've lost...
800
false
false
true
false
false
true
false
false
false
false
2,527
1790D
Matryoshka is a wooden toy in the form of a painted doll, inside which you can put a similar doll of a smaller size. A set of nesting dolls contains one or more nesting dolls, their sizes are consecutive positive integers. Thus, a set of nesting dolls is described by two numbers: $$$s$$$ — the size of a smallest nestin...
1,200
false
true
false
false
true
false
false
false
true
false
1,539
1986G2
This is the hard version of the problem. The only difference is that in this version $$$n leq 5 cdot 10^5$$$ and the sum of $$$n$$$ for all sets of input data does not exceed $$$5 cdot 10^5$$$. You are given a permutation $$$p$$$ of length $$$n$$$. Calculate the number of index pairs $$$1 leq i < j leq n$$$ such that $...
2,500
true
false
false
false
true
false
true
false
false
false
358
1029E
You are given an undirected tree consisting of $$$n$$$ vertices. An undirected tree is a connected undirected graph with $$$n - 1$$$ edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $$$1$$$ to any other vertex is at most $$$2$$$. Note that you are...
2,100
false
true
false
true
false
false
false
false
false
true
5,557
1469A
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a regular bracket sequence "RBS". You are given a sequence $$$s$$$ o...
1,000
false
true
false
false
false
true
false
false
false
false
3,338
1593C
There are one cat, $$$k$$$ mice, and one hole on a coordinate line. The cat is located at the point $$$0$$$, the hole is located at the point $$$n$$$. All mice are located between the cat and the hole: the $$$i$$$-th mouse is located at the point $$$x_i$$$ ($$$0 < x_i < n$$$). At each point, many mice can be located. I...
1,000
false
true
false
false
false
false
false
true
false
false
2,684
1917F
You are given an array of integers $$$l_1, l_2, dots, l_n$$$ and an integer $$$d$$$. Is it possible to construct a tree satisfying the following three conditions? The tree contains $$$n + 1$$$ nodes. The length of the $$$i$$$-th edge is equal to $$$l_i$$$. The (weighted) diameter of the tree is equal to $$$d$$$. Inp...
2,500
false
false
false
true
false
true
false
false
false
false
789
1155D
You are given an array $$$a$$$ consisting of $$$n$$$ integers. Beauty of array is the maximum sum of some consecutive subarray of this array (this subarray may be empty). For example, the beauty of the array [10, -5, 10, -4, 1] is 15, and the beauty of the array [-3, -5, -1] is 0. You may choose at most one consecutive...
1,900
false
true
false
true
true
false
true
false
false
false
4,933
1872B
You are in a corridor that extends infinitely to the right, divided into square rooms. You start in room $$$1$$$, proceed to room $$$k$$$, and then return to room $$$1$$$. You can choose the value of $$$k$$$. Moving to an adjacent room takes $$$1$$$ second. Additionally, there are $$$n$$$ traps in the corridor: the $$$...
900
false
true
true
false
false
false
false
false
false
false
1,050
444C
DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of _n_ units (they are numbered from 1 to _n_ from left to right). The color of the _i_-th unit of the ribbon is _i_ at first. It is colorful enough, but we still consider that the colorfulness of each unit is 0 at f...
2,400
false
false
false
false
true
false
false
false
false
false
8,061
220B
The Little Elephant loves playing with arrays. He has array _a_, consisting of _n_ positive integers, indexed from 1 to _n_. Let's denote the number with index _i_ as _a__i_. Additionally the Little Elephant has _m_ queries to the array, each query is characterised by a pair of integers _l__j_ and _r__j_ (1u2009≤u2009_...
1,800
false
false
false
false
true
true
false
false
false
false
8,958
1387A
You are given an undirected graph where each edge has one of two colors: black or red. Your task is to assign a real number to each node so that: for each black edge the sum of values at its endpoints is $$$1$$$; for each red edge the sum of values at its endpoints is $$$2$$$; the sum of the absolute values of all a...
2,100
true
false
false
true
false
false
false
true
false
false
3,737
687B
Problem - 687B - 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,800
true
false
false
false
false
false
false
false
false
false
7,075
43D
The territory of Berland is represented by a rectangular field _n_u2009×u2009_m_ in size. The king of Berland lives in the capital, located on the upper left square (1,u20091). The lower right square has coordinates (_n_,u2009_m_). One day the king decided to travel through the whole country and return back to the capi...
2,000
false
false
true
false
false
true
true
false
false
false
9,771
1294F
You are given an unweighted tree with $$$n$$$ vertices. Recall that a tree is a connected undirected graph without cycles. Your task is to choose three distinct vertices $$$a, b, c$$$ on this tree such that the number of edges which belong to at least one of the simple paths between $$$a$$$ and $$$b$$$, $$$b$$$ and $$$...
2,000
false
true
false
true
false
false
false
false
false
false
4,224
1815C
You are given an integer $$$n$$$, as well as $$$m$$$ pairs of integers $$$(a_i,b_i)$$$, where $$$1leq a_i , b_i leq n$$$, $$$a_i e b_i$$$. You want to construct a sequence satisfying the following requirements: All elements in the sequence are integers between $$$1$$$ and $$$n$$$. There is exactly one element with v...
2,200
false
true
false
false
false
true
false
false
false
true
1,379
46B
One day a well-known sponsor of a well-known contest decided to give every participant of the contest a T-shirt as a present. A natural problem occurred: on the one hand, it is not clear how many T-shirts of what sizes should be ordered, and on the other hand, one doesn't want to order too many T-shirts (and we do not ...
1,100
false
false
true
false
false
false
false
false
false
false
9,748
1806E
You are given a tree with $$$n$$$ weighted vertices labeled from $$$1$$$ to $$$n$$$ rooted at vertex $$$1$$$. The parent of vertex $$$i$$$ is $$$p_i$$$ and the weight of vertex $$$i$$$ is $$$a_i$$$. For convenience, define $$$p_1=0$$$. For two vertices $$$x$$$ and $$$y$$$ of the same depth$$$^dagger$$$, define $$$f(x,y...
2,200
false
false
false
false
true
false
true
false
false
false
1,438
1928D
Once, the people, elves, dwarves, and other inhabitants of Middle-earth gathered to reclaim the treasures stolen from them by Smaug. In the name of this great goal, they rallied around the powerful elf Timothy and began to plan the overthrow of the ruler of the Lonely Mountain. The army of Middle-earth inhabitants will...
1,900
true
true
false
false
true
false
true
false
false
false
720
1781B
A company of $$$n$$$ people is planning a visit to the cinema. Every person can either go to the cinema or not. That depends on how many other people will go. Specifically, every person $$$i$$$ said: "I want to go to the cinema if and only if at least $$$a_i$$$ other people will go, not counting myself". That means tha...
1,000
false
true
false
false
false
false
true
false
true
false
1,587
367C
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_,u2009_y_ (_x_u2009≠u2009_y_), such that number _x_ occurs in the array _a_ and number _y_ occurs in the array _a_; for each pair _x_,u2009_y_ must exist some pos...
2,000
false
true
false
false
false
false
false
false
true
true
8,363
574B
Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad guys. There are _n_ warriors. Richelimakieu wants to choose three ...
1,500
false
false
false
false
false
false
true
false
false
true
7,553
474B
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch. Marmot brought Mole _n_ ordered piles of worms such that _i_-th pile contains _a__i_ worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to _a_1, worms in second pile are labeled wi...
1,200
false
false
true
false
false
false
false
true
false
false
7,939
1023F
You are managing a mobile phone network, and want to offer competitive prices to connect a network. The network has $$$n$$$ nodes. Your competitor has already offered some connections between some nodes, with some fixed prices. These connections are bidirectional. There are initially $$$m$$$ connections the competitor ...
2,600
false
false
false
false
false
false
false
false
false
true
5,585
1630D
You are given an array $$$a$$$ of $$$n$$$ integers and a set $$$B$$$ of $$$m$$$ positive integers such that $$$1 leq b_i leq lfloor frac{n}{2} floor$$$ for $$$1le ile m$$$, where $$$b_i$$$ is the $$$i$$$-th element of $$$B$$$. You can make the following operation on $$$a$$$: 1. Select some $$$x$$$ such that $$$x$$$ ap...
2,400
false
true
false
true
false
true
false
false
false
false
2,463
75B
Facetook is a well known social network website, and it will launch a new feature called Facetook Priority Wall. This feature will sort all posts from your friends according to the priority factor (it will be described). This priority factor will be affected by three types of actions: 1. "_X_ posted on _Y_'s wall" (15...
1,500
false
false
true
false
false
false
false
false
false
false
9,590
82D
Vasya has recently developed a new algorithm to optimize the reception of customer flow and he considered the following problem. Let the queue to the cashier contain _n_ people, at that each of them is characterized by a positive integer _a__i_ — that is the time needed to work with this customer. What is special about...
2,000
false
false
false
true
false
false
false
false
false
false
9,555
1853A
Call an array $$$a$$$ of length $$$n$$$ sorted if $$$a_1 leq a_2 leq ldots leq a_{n-1} leq a_n$$$. Ntarsis has an array $$$a$$$ of length $$$n$$$. He is allowed to perform one type of operation on it (zero or more times): Choose an index $$$i$$$ ($$$1 leq i leq n-1$$$). Add $$$1$$$ to $$$a_1, a_2, ldots, a_i$$$. Sub...
800
true
true
false
false
false
false
true
false
false
false
1,161
1593E
A tree is an undirected connected graph in which there are no cycles. This problem is about non-rooted trees. A leaf of a tree is a vertex that is connected to at most one vertex. The gardener Vitaly grew a tree from $$$n$$$ vertices. He decided to trim the tree. To do this, he performs a number of operations. In one o...
1,600
false
true
true
false
true
false
true
false
false
false
2,681
500A
New Year is coming in Line World! In this world, there are _n_ cells numbered by integers from 1 to _n_, as a 1u2009×u2009_n_ board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells. So, user t...
1,000
false
false
true
false
false
false
false
false
false
true
7,837
965C
$$$k$$$ people want to split $$$n$$$ candies between them. Each candy should be given to exactly one of them or be thrown away. The people are numbered from $$$1$$$ to $$$k$$$, and Arkady is the first of them. To split the candies, Arkady will choose an integer $$$x$$$ and then give the first $$$x$$$ candies to himself...
2,000
true
false
false
false
false
false
false
false
false
false
5,840
1455B
You are standing on the $$$mathit{OX}$$$-axis at point $$$0$$$ and you want to move to an integer point $$$x > 0$$$. You can make several jumps. Suppose you're currently at point $$$y$$$ ($$$y$$$ may be negative) and jump for the $$$k$$$-th time. You can: either jump to the point $$$y + k$$$ or jump to the point $$$y...
1,200
true
false
false
false
false
true
false
false
false
false
3,401
869D
The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor. The Cinderswarm Bee. Koyomi knows it. The bees, according to their nature, live in a tree. To be more specific, a complete binary tree with _n_ nodes numbered from 1 to _n_. The node numbered 1 is t...
2,800
false
false
false
false
false
false
true
false
false
true
6,263
622C
Problem - 622C - Codeforces =============== xa0 ]( "Educational Codeforces Round 7") so that _a__p__i_u2009≠u2009_x__i_. Input The first line contains two integers _n_,u2009_m_ (1u2009≤u2009_n_,u2009_m_u2009≤u20092·105) — the number of elements in _a_ and the number of queries. The second line contains _n_...
1,700
false
false
true
false
true
false
false
false
false
false
7,344
883A
There is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, when one or several people come to the door and it is open, all people immediatel...
2,200
false
false
true
false
false
false
false
false
false
false
6,227
618E
Roger is a robot. He has an arm that is a series of _n_ segments connected to each other. The endpoints of the _i_-th segment are initially located at points (_i_u2009-u20091,u20090) and (_i_,u20090). The endpoint at (_i_u2009-u20091,u20090) is colored red and the endpoint at (_i_,u20090) is colored blue for all segmen...
2,500
false
false
false
false
true
false
false
false
false
false
7,360
2032D
This is an interactive problem. Upon clearing the Waterside Area, Gretel has found a monster named Genokraken, and she's keeping it contained for her scientific studies. The monster's nerve system can be structured as a tree$$$^{dagger}$$$ of $$$n$$$ nodes (really, everything should stop resembling trees all the time$$...
1,800
false
true
true
false
true
true
false
false
false
true
71
291D
Polycarpus has a computer with _n_ processors. Also, his computer has _n_ memory cells. We'll consider the processors numbered by integers from 1 to _n_ and that the memory cells are consecutively numbered by integers from 1 to _n_. Polycarpus needs to come up with a parallel program model. For each memory cell number ...
1,600
false
true
false
false
false
false
false
false
false
false
8,668
1641D
Sam changed his school and on the first biology lesson he got a very interesting task about genes. You are given $$$n$$$ arrays, the $$$i$$$-th of them contains $$$m$$$ different integers — $$$a_{i,1}, a_{i,2},ldots,a_{i,m}$$$. Also you are given an array of integers $$$w$$$ of length $$$n$$$. Find the minimum value of...
2,700
true
true
false
false
false
false
true
false
false
false
2,406
27C
Problem - 27C - 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
true
false
false
false
true
false
false
false
false
9,861
812B
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off. The building consists of _n_ floors with stairs at the left and the right side...
1,600
false
false
false
true
false
false
true
false
false
false
6,515
313D
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as _n_ holes in a row. We will consider the holes numbered from 1 to _n_, from left to right. Ilya is really keep on helping his city. So, he wants to fix at least _k_ holes (perharps he can fix more) on a singl...
2,100
false
false
false
true
false
false
false
false
false
false
8,592
1081C
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard. There are $$$n$$$ bricks lined in a row on the ground. Chouti has got $$$m$$$ paint buckets of different colors at hand, so he painted each brick in one of those $$$m$$$ colors. Having finished painting all bric...
1,500
true
false
false
true
false
false
false
false
false
false
5,321
983C
You work in a big office. It is a 9xa0floor building with an elevator that can accommodate up to 4xa0people. It is your responsibility to manage this elevator. Today you are late, so there are queues on some floors already. For each person you know the floor where he currently is and the floor he wants to reach. Also, ...
2,400
false
false
false
true
false
false
false
false
false
true
5,784
568B
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation. A set ρ of pairs (_a_,u2009_b_) of el...
1,900
true
false
false
true
false
false
false
false
false
false
7,577
1400G
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries. Polycarp wants to gather his army for a quest. There are $$$n$$$ mercenaries for hire, and the army should consist of some subset of them. The $$$i$$$-th mercenary can be chosen if the resulting number of chosen merc...
2,600
true
false
false
true
false
false
true
false
false
false
3,666
1621F
Dasha has $$$10^{100}$$$ coins. Recently, she found a binary string $$$s$$$ of length $$$n$$$ and some operations that allows to change this string (she can do each operation any number of times): 1. Replace substring 00 of $$$s$$$ by 0 and receive $$$a$$$ coins. 2. Replace substring 11 of $$$s$$$ by 1 and receive $$$b...
2,700
false
true
true
false
true
false
false
false
false
false
2,515
213C
Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of _n_ meters. The given square is split into _n_u2009×u2009_n_ cells (represented as unit squares), each cell has some number. At the beginning of the race Furik stands in a cell with coordinates (1,u20091), and Rubik st...
2,000
false
false
false
true
false
false
false
false
false
false
8,986
639F
Limak is a smart brown bear who loves chemistry, reactions and transforming elements. In Bearland (Limak's home) there are _n_ elements, numbered 1 through _n_. There are also special machines, that can transform elements. Each machine is described by two integers _a__i_,u2009_b__i_ representing two elements, not neces...
3,300
false
false
false
false
true
false
false
false
false
true
7,252
1598C
Monocarp has got an array $$$a$$$ consisting of $$$n$$$ integers. Let's denote $$$k$$$ as the mathematic mean of these elements (note that it's possible that $$$k$$$ is not an integer). The mathematic mean of an array of $$$n$$$ elements is the sum of elements divided by the number of these elements (i.u2009e. sum divi...
1,200
true
false
true
true
true
false
false
false
false
false
2,669
1551B2
This problem is an extension of the problem "Wonderful Coloring - 1". It has quite many differences, so you should read this statement completely. Recently, Paul and Mary have found a new favorite sequence of integers $$$a_1, a_2, dots, a_n$$$. They want to paint it using pieces of chalk of $$$k$$$ colors. The coloring...
1,400
false
true
false
false
true
true
false
true
false
false
2,890
180F
Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to _n_. Each student _i_ (1u2009≤u2009_i_u2009≤u2009_n_) has a best friend _p_[_i_] (1u2009≤u2009_p_[_i_]u20...
1,200
true
false
true
false
false
true
false
false
false
false
9,117
286B
Problem - 286B - 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,200
false
false
true
false
false
false
false
false
false
false
8,690
1844E
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 884 (Div. 1 + Div. 2) 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 con...
2,400
false
false
false
false
false
true
false
false
false
true
1,219
51D
Problem - 51D - Codeforces =============== xa0 — the number of elements in the given sequence. The second line contains the given sequence. The numbers are space-separated. All the elements of the given sequence are integers and their absolute value does not exceed 104. Output Print 0, if the given sequen...
2,200
false
false
true
false
false
false
false
false
false
false
9,716
837C
One very important person has a piece of paper in the form of a rectangle _a_u2009×u2009_b_. Also, he has _n_ seals. Each seal leaves an impression on the paper in the form of a rectangle of the size _x__i_u2009×u2009_y__i_. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by...
1,500
false
false
true
false
false
false
true
false
false
false
6,419
598B
You are given a string _s_ and should process _m_ queries. Each query is described by two 1-based indices _l__i_, _r__i_ and integer _k__i_. It means that you should cyclically shift the substring _s_[_l__i_... _r__i_] _k__i_ times. The queries should be processed one after another in the order they are given. One oper...
1,300
false
false
true
false
false
false
false
false
false
false
7,456
173A
Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!). Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round the players choose one of three items independently from each other. They show the items with their hands: a rock, scissor...
1,300
true
false
true
false
false
false
false
false
false
false
9,173
1118E
The king of Berland organizes a ball! $$$n$$$ pair are invited to the ball, they are numbered from $$$1$$$ to $$$n$$$. Each pair consists of one man and one woman. Each dancer (either man or woman) has a monochrome costume. The color of each costume is represented by an integer from $$$1$$$ to $$$k$$$, inclusive. Let $...
1,700
false
false
true
false
false
true
false
false
false
false
5,097
932E
Problem - 932E - 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,400
true
false
false
true
false
false
false
false
false
false
5,974
868G
The prehistoric caves of El Toll are located in Moià (Barcelona). You have heard that there is a treasure hidden in one of _n_ possible spots in the caves. You assume that each of the spots has probability 1u2009/u2009_n_ to contain a treasure. You cannot get into the caves yourself, so you have constructed a robot tha...
3,300
true
false
false
false
false
false
false
false
false
false
6,267
769A
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups for...
800
false
false
true
false
false
false
false
false
true
false
6,706
1333B
Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers $$$a$$$ and $$$b$$$ of length $$$n$$$. It turned out that array $$$a$$$ contains only elements from the set $$${-1, 0, 1}$$$. Anton can perform the following sequence of o...
1,100
false
true
true
false
false
false
false
false
false
false
4,042
1656A
You are given an array $$$a_1, a_2, ldots, a_n$$$ of positive integers. A good pair is a pair of indices $$$(i, j)$$$ with $$$1 leq i, j leq n$$$ such that, for all $$$1 leq k leq n$$$, the following equality holds: $$$$$$ a_i - a_k + a_k - a_j = a_i - a_j, $$$$$$ where $$$x$$$ denotes the absolute value of $$$x$$$. Fi...
800
true
false
false
false
false
false
false
false
true
false
2,354
1041B
Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the scr...
1,000
true
false
false
false
false
false
false
false
false
false
5,494
1627C
You are given a tree of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$, with edges numbered from $$$1$$$ to $$$n-1$$$. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of the tree, such that the resultant graph is a prime tree. A prime tree is a tree where the we...
1,400
false
false
false
false
false
true
false
false
false
false
2,479
961B
Your friend Mishka and you attend a calculus lecture. Lecture lasts _n_ minutes. Lecturer tells _a__i_ theorems during the _i_-th minute. Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array _t_ of Mishka's behavior. If Mishka is asleep during t...
1,200
false
false
true
true
true
false
false
false
false
false
5,862
796C
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. There are _n_ banks, numbered from 1 to _n_. There are also _n_u2009-u20091 wires connecting ...
1,900
false
false
false
true
true
true
false
false
false
false
6,591
665D
Problem - 665D - Codeforces =============== xa0 ]( "Educational Codeforces Round 12") (1u2009u2009≤u2009_i_u2009u2009<u2009u2009_j_u2009≤u2009_k_), _x__i_u2009u2009+u2009u2009_x__j_ is a prime. You are given an array _a_ with _n_ positive integers _a_1,u2009u2009_a_2,u2009u2009...,u2009u2009_a__n_ (not nec...
1,800
false
true
false
false
false
true
false
false
false
false
7,158
141B
So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks...
1,400
true
false
false
false
false
false
false
false
false
false
9,311
1263C
On the well-known testing system MathForces, a draw of $$$n$$$ rating units is arranged. The rating will be distributed according to the following algorithm: if $$$k$$$ participants take part in this event, then the $$$n$$$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end o...
1,400
true
false
false
false
false
false
false
true
false
false
4,385
1701D
Monocarp had a permutation $$$a$$$ of $$$n$$$ integers $$$1$$$, $$$2$$$, ..., $$$n$$$ (a permutation is an array where each element from $$$1$$$ to $$$n$$$ occurs exactly once). Then Monocarp calculated an array of integers $$$b$$$ of size $$$n$$$, where $$$b_i = leftlfloor frac{i}{a_i} ight floor$$$. For example, if ...
1,900
true
true
false
false
true
false
false
true
true
false
2,073
241B
Problem - 241B - 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,700
true
false
false
false
true
false
false
true
false
false
8,874
218A
Little Bolek has found a picture with _n_ mountain peaks painted on it. The _n_ painted peaks are represented by a non-closed polyline, consisting of 2_n_ segments. The segments go through 2_n_u2009+u20091 points with coordinates (1,u2009_y_1), (2,u2009_y_2), ..., (2_n_u2009+u20091,u2009_y_2_n_u2009+u20091), with the _...
1,100
false
false
true
false
false
true
true
false
false
false
8,966
81A
Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. For example, instead of the phrase "how are you" he can type "hhoow aaaare yy...
1,400
false
false
true
false
false
false
false
false
false
false
9,563
1200F
Gildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of $$$n$$$ vertices numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th vertex has $$$m_i$$$ outgoing edges that are labeled as $$$e_i[0]$$$, $$$e_i[1]$$$, $$$ldots$$$, $$$e_i[m_i-1]$$$, each repres...
2,300
true
false
true
true
true
false
true
false
false
true
4,696
1975D
378QAQ has a tree with $$$n$$$ vertices. Initially, all vertices are white. There are two chess pieces called $$$P_A$$$ and $$$P_B$$$ on the tree. $$$P_A$$$ and $$$P_B$$$ are initially located on vertices $$$a$$$ and $$$b$$$ respectively. In one step, 378QAQ will do the following in order: 1. Move $$$P_A$$$ to a neighb...
1,700
false
true
false
true
false
false
true
false
false
false
439