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
1765G
This is an interactive problem. You have to use flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout), in Java or Kotlin — System.out.flush(), and in Python — sys.stdout.flush(). The jury has a string $$$s$$$ consisting of characters 0 and/or 1. The first charact...
2,600
false
false
false
false
false
true
false
false
false
false
1,711
854A
Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (_a_u2009<u2009_b_) and that the fraction is called irreducible if its numerator and its denominator are coprime (they do not have positive ...
800
true
false
false
false
false
true
true
false
false
false
6,329
192B
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of _n_ tiles that are lain in a row and are numbered from 1 to _n_ from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number _n_. During the walk it is allowed to move...
1,100
false
false
true
false
false
false
true
false
false
false
9,071
183A
Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters e...
1,700
true
false
false
false
false
true
false
false
false
false
9,109
1088C
You're given an array $$$a$$$ of length $$$n$$$. You can perform the following operations on it: choose an index $$$i$$$ $$$(1 le i le n)$$$, an integer $$$x$$$ $$$(0 le x le 10^6)$$$, and replace $$$a_j$$$ with $$$a_j+x$$$ for all $$$(1 le j le i)$$$, which means add $$$x$$$ to all the elements in the prefix ending a...
1,400
true
true
false
false
false
true
false
false
false
false
5,289
1926E
Vladislav has $$$n$$$ cards numbered $$$1, 2, dots, n$$$. He wants to lay them down in a row as follows: First, he lays down all the odd-numbered cards from smallest to largest. Next, he lays down all cards that are twice an odd number from smallest to largest (i.e. $$$2$$$ multiplied by an odd number). Next, he lay...
1,500
true
false
true
true
true
false
false
true
false
false
733
469B
Little X and Little Z are good friends. They always chat online. But both of them have schedules. Little Z has fixed schedule. He always online at any moment of time between _a_1 and _b_1, between _a_2 and _b_2, ..., between _a__p_ and _b__p_ (all borders inclusive). But the schedule of Little X is quite strange, it de...
1,300
false
false
true
false
false
false
false
false
false
false
7,961
48B
Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the fruit because there’s no house in the garden! Vasya had been saving ...
1,200
false
false
true
false
false
false
true
false
false
false
9,736
1279F
New Year is getting near. So it's time to change handles on codeforces. Mishka wants to change his handle but in such a way that people would not forget who he is. To make it work, he only allowed to change letters case. More formally, during one handle change he can choose any segment of his handle $$$[i; i + l - 1]$$...
2,800
false
false
false
true
false
false
false
true
false
false
4,295
202B
A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a problem — a severe torcoder coordinator Ivan does not accept any Lesha's probl...
1,700
false
false
false
false
false
false
true
false
false
false
9,033
875E
Petya and Vasya got employed as couriers. During the working day they are to deliver packages to _n_ different points on the line. According to the company's internal rules, the delivery of packages must be carried out strictly in a certain order. Initially, Petya is at the point with the coordinate _s_1, Vasya is at t...
2,600
false
false
false
true
true
false
false
true
false
false
6,244
23A
Problem - 23A - Codeforces =============== xa0 . Input The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100. Output Output one number — length of the longest substring that can be met in the string ...
1,200
false
true
false
false
false
false
true
false
false
false
9,883
1936F
You are given $$$n$$$ circles on the plane. The $$$i$$$-th of these circles is given by a tuple of integers $$$(x_i, y_i, r_i)$$$, where $$$(x_i, y_i)$$$ are the coordinates of its center, and $$$r_i$$$ is the radius of the circle. Please find a circle $$$C$$$ which meets the following conditions: $$$C$$$ is contained...
3,300
false
false
false
false
false
false
false
true
false
false
663
1186C
Vus the Cossack has two binary strings, that is, strings that consist only of "0" and "1". We call these strings $$$a$$$ and $$$b$$$. It is known that $$$b leq a$$$, that is, the length of $$$b$$$ is at most the length of $$$a$$$. The Cossack considers every substring of length $$$b$$$ in string $$$a$$$. Let's call thi...
1,800
true
false
true
false
false
false
false
false
false
false
4,770
1063E
Oleg came to see the maze of mirrors. The maze is a $$$n$$$ by $$$n$$$ room in which each cell is either empty or contains a mirror connecting opposite corners of this cell. Mirrors in this maze reflect light in a perfect way, which causes the interesting visual effects and contributes to the loss of orientation in the...
3,000
true
false
false
false
false
true
false
false
false
false
5,392
845D
Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types. speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (cancel the action of the previous sign of this type); overtake is allowed: this sign means that after...
1,800
false
true
false
true
true
false
false
false
false
false
6,381
1787D
There are $$$n$$$ points $$$1,2,ldots,n$$$, each point $$$i$$$ has a number $$$a_i$$$ on it. You're playing a game on them. Initially, you are at point $$$1$$$. When you are at point $$$i$$$, take following steps: If $$$1le ile n$$$, go to $$$i+a_i$$$, Otherwise, the game ends. Before the game begins, you can choose ...
1,900
false
false
true
false
false
false
false
false
false
true
1,560
459E
Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem. As you know, he's really weak at graph theory; so try to help him in solving the problem. You are given a weighted directed graph with _n_ vertices and _m_ edges. You need to find a path (p...
1,900
false
false
false
true
false
false
false
false
true
false
8,002
1698G
There is a binary string $$$t$$$ of length $$$10^{100}$$$, and initally all of its bits are $$$ exttt{0}$$$. You are given a binary string $$$s$$$, and perform the following operation some times: Select some substring of $$$t$$$, and replace it with its XOR with $$$s$$$.$$$^dagger$$$ After several operations, the stri...
2,900
true
false
false
false
false
false
false
false
false
false
2,088
709B
Vasya takes part in the orienteering competition. There are _n_ checkpoints located along the line at coordinates _x_1,u2009_x_2,u2009...,u2009_x__n_. Vasya starts at the point with coordinate _a_. His goal is to visit at least _n_u2009-u20091 checkpoint in order to finish the competition. Participant are allowed to vi...
1,500
false
true
true
false
false
false
false
false
true
false
6,983
1889E
Consider two undirected graphs $$$G_1$$$ and $$$G_2$$$. Every node in $$$G_1$$$ and in $$$G_2$$$ has a label. Doremy calls $$$G_1$$$ and $$$G_2$$$ similar if and only if: The labels in $$$G_1$$$ are distinct, and the labels in $$$G_2$$$ are distinct. The set $$$S$$$ of labels in $$$G_1$$$ coincides with the set of la...
3,500
false
false
false
false
false
false
false
false
false
true
961
1089J
International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential features that make them qu...
3,200
false
true
true
false
false
false
false
false
false
false
5,276
315A
Problem - 315A - 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,400
false
false
false
false
false
false
true
false
false
false
8,585
1900B
Laura is a girl who does not like combinatorics. Nemanja will try to convince her otherwise. Nemanja wrote some digits on the board. All of them are either $$$1$$$, $$$2$$$, or $$$3$$$. The number of digits $$$1$$$ is $$$a$$$. The number of digits $$$2$$$ is $$$b$$$ and the number of digits $$$3$$$ is $$$c$$$. He told ...
900
true
false
false
true
false
false
false
false
false
false
914
1669D
A row of $$$n$$$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $$$color{blue}{ exttt{B}}color{red}{ exttt{R}}$$$ and as $$$color{red}{ exttt{R}}color{blue}{ ex...
1,100
false
false
true
false
false
false
false
false
false
false
2,262
959C
Mahmoud was trying to solve the vertex cover problem on trees. The problem statement is: Given an undirected tree consisting of _n_ nodes, find the minimum number of vertices that cover all the edges. Formally, we need to find a set of vertices such that for each edge (_u_,u2009_v_) that belongs to the tree, either _u_...
1,500
false
false
false
false
false
true
false
false
false
false
5,875
45A
Problem - 45A - 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...
900
false
false
true
false
false
false
false
false
false
false
9,759
1681B
Monocarp has just learned a new card trick, and can't wait to present it to you. He shows you the entire deck of $$$n$$$ cards. You see that the values of cards from the topmost to the bottommost are integers $$$a_1, a_2, dots, a_n$$$, and all values are different. Then he asks you to shuffle the deck $$$m$$$ times. Wi...
800
true
false
true
false
false
false
false
false
false
false
2,184
895B
Problem - 895B - 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,700
true
false
false
false
false
false
false
true
true
false
6,169
838B
You are given a directed weighted graph with _n_ nodes and 2_n_u2009-u20092 edges. The nodes are labeled from 1 to _n_, while the edges are labeled from 1 to 2_n_u2009-u20092. The graph's edges can be split into two parts. The first _n_u2009-u20091 edges will form a rooted spanning tree, with node 1 as the root. All t...
2,100
false
false
false
false
true
false
false
false
false
false
6,413
835E
Pay attention: this problem is interactive. Penguin Xoriy came up with a new game recently. He has _n_ icicles numbered from 1 to _n_. Each icicle has a temperaturexa0— an integer from 1 to 109. Exactly two of these icicles are special: their temperature is _y_, while a temperature of all the others is _x_u2009≠u2009_y...
2,400
false
false
false
false
false
true
false
true
false
false
6,423
1385G
You are given a table $$$a$$$ of size $$$2 imes n$$$ (i.e. two rows and $$$n$$$ columns) consisting of integers from $$$1$$$ to $$$n$$$. In one move, you can choose some column $$$j$$$ ($$$1 le j le n$$$) and swap values $$$a_{1, j}$$$ and $$$a_{2, j}$$$ in it. Each column can be chosen no more than once. Your task is...
2,300
false
false
true
false
false
false
false
false
false
true
3,741
1109F
One fine day Sasha went to the park for a walk. In the park, he saw that his favorite bench is occupied, and he had to sit down on the neighboring one. He sat down and began to listen to the silence. Suddenly, he got a question: what if in different parts of the park, the silence sounds in different ways? So it was. Le...
3,200
false
false
false
false
true
false
false
false
false
false
5,150
1536C
The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plank of wood can be represented as a string of $$$n$$$ characters. Each character i...
1,500
false
false
false
true
true
false
false
false
false
false
2,966
70B
Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing _n_ characters (which is the size of one text message). Thus, whole sentences and words get split! Fangy did not like...
1,600
false
true
false
false
false
false
false
false
false
false
9,620
1943D1
This is the easy version of the problem. The only difference between the two versions is the constraint on $$$n$$$. You can make hacks only if both versions of the problem are solved. An array $$$b$$$ of $$$m$$$ non-negative integers is said to be good if all the elements of $$$b$$$ can be made equal to $$$0$$$ using t...
2,400
true
false
false
true
false
false
true
false
false
false
620
1439A1
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem. You are given a binary table of size $$$n imes m$$$. This table consists of symbols $$$0$$$ and $$$1$$$. You ...
1,500
false
false
true
false
false
true
false
false
false
false
3,472
1150A
Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market! In the morning, there are $$$n$$$ opportunities to buy shares. The $$$i$$$-th of them allows to buy as many shares as you want, each at ...
800
false
true
true
false
false
false
false
false
false
false
4,964
1823E
Alice and Bob are playing a game on a graph. They have an undirected graph without self-loops and multiple edges. All vertices of the graph have degree equal to $$$2$$$. The graph may consist of several components. Note that if such graph has $$$n$$$ vertices, it will have exactly $$$n$$$ edges. Alice and Bob take turn...
2,500
true
false
false
true
false
false
true
false
false
true
1,339
926E
You are given a sequence of positive integers _a_1,u2009_a_2,u2009...,u2009_a__n_. While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to _x_, delete...
1,900
false
false
false
false
true
true
false
false
false
false
6,001
1237G
There are $$$n$$$ friends living on a circular street. The friends and their houses are numbered clockwise from $$$0$$$ to $$$n-1$$$. Initially person $$$i$$$ has $$$a_i$$$ stones. The friends want to make the distribution of stones among them perfectly balanced: everyone should possess the same number of stones. The o...
3,500
false
true
false
true
true
false
false
false
false
false
4,505
1153A
It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under such circumstances, th...
1,000
true
false
false
false
false
false
true
false
false
false
4,949
348D
You've got a table of size _n_u2009×u2009_m_. We'll consider the table rows numbered from top to bottom 1 through _n_, and the columns numbered from left to right 1 through _m_. Then we'll denote the cell in row _x_ and column _y_ as (_x_,u2009_y_). Initially cell (1,u20091) contains two similar turtles. Both turtles w...
2,500
false
false
false
true
false
false
false
false
false
false
8,439
727A
Vasily has a number _a_, which he wants to turn into a number _b_. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number _x_ by 2·_x_); append the digit 1 to the right of current number (that is, replace the number _x_ by 10·_x_u2009+u20091). You need to he...
1,000
true
false
false
false
false
false
true
false
false
false
6,900
93A
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well. This time Igor K. got disappointed in o...
1,700
false
false
true
false
false
false
false
false
false
false
9,515
387E
George is a cat, so he loves playing very much. Vitaly put _n_ cards in a row in front of George. Each card has one integer written on it. All cards had distinct numbers written on them. Let's number the cards from the left to the right with integers from 1 to _n_. Then the _i_-th card from the left contains number _p_...
2,200
false
false
false
false
true
false
false
true
false
false
8,278
421A
Pasha has two hamsters: Arthur and Alexander. Pasha put _n_ apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hams...
800
false
false
true
false
false
true
false
false
false
false
8,145
1335D
You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it $$$ to any other number in range $$$[1; 9]$$$) to make it anti-sudoku. The anti-sudoku is the $$$9 imes 9$$$ field, in which: Any number in this field is in range $$$[1; 9]$$$; each row contains at leas...
1,300
false
false
true
false
false
true
false
false
false
false
4,027
1215D
Monocarp and Bicarp live in Berland, where every bus ticket consists of $$$n$$$ digits ($$$n$$$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even. Monocarp and Bicarp have decided to play a game wi...
1,700
true
true
false
false
false
false
false
false
false
false
4,600
39H
Problem - 39H - 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,300
false
false
true
false
false
false
false
false
false
false
9,793
1584B
Problem - 1584B - Codeforces =============== xa0 ") ") have different colors. What is the minimum number of cells David will have to paint? Input The first line contains a single integer $$$t$$$ ($$$1 leq t leq 10^3$$$)xa0— the number of test cases. The next lines contain descriptions of test cases. The on...
1,000
true
true
false
false
false
false
false
false
false
false
2,708
548B
Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an _n_u2009×u2009_m_ grid, there's exactly one bear in each cell. We denote the bear standing in column number _j_ of row number _i_ by (_i_,u2009_j_). Mike's hands are on his ears (since he's the judge) and ea...
1,400
false
true
true
true
false
false
true
false
false
false
7,646
26C
Problem - 26C - 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
false
true
true
false
false
true
false
false
false
false
9,866
1986F
You are given a connected undirected graph, the vertices of which are numbered with integers from $$$1$$$ to $$$n$$$. Your task is to minimize the number of pairs of vertices $$$1 leq u < v leq n$$$ between which there exists a path in this graph. To achieve this, you can remove exactly one edge from the graph. Find th...
1,900
false
false
false
false
false
false
false
false
false
true
360
1661A
You are given two arrays of length $$$n$$$: $$$a_1, a_2, dots, a_n$$$ and $$$b_1, b_2, dots, b_n$$$. You can perform the following operation any number of times: 1. Choose integer index $$$i$$$ ($$$1 le i le n$$$); 2. Swap $$$a_i$$$ and $$$b_i$$$. What is the minimum possible sum $$$a_1 - a_2 + a_2 - a_3 + dots + a_{n-...
800
true
true
false
false
false
false
false
false
false
false
2,319
1041E
Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$...
1,900
false
true
false
false
true
true
false
false
false
true
5,491
518C
Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly _n_ applications, each application has its own icon. The icons are located on different screens, one screen contains _k_ icons. The icons from the first to the _k_-th one are located on the first screen, from the (_k_u...
1,600
false
false
true
false
true
true
false
false
false
false
7,766
754D
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has _n_ discount coupons, the _i_-th of them can be used with products wit...
2,100
false
true
false
false
true
false
false
true
true
false
6,779
1207C
You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as...
1,500
false
true
false
true
false
false
false
false
false
false
4,659
64D
Problem - 64D - Codeforces =============== xa0 is for the second sister. And the less valuable present is for the youngest sister. If two (or three) presents have the same price, corresponding sisters may get the in a random way. Input The only line contains three integer numbers _a_1,u2009_a_2,u2009_a_3 (1u2...
1,800
false
true
false
false
false
false
false
false
false
false
9,652
1895C
Problem - 1895C - 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 - ...
1,400
true
false
true
true
false
false
true
false
false
false
942
1167C
In some social network, there are $$$n$$$ users communicating with each other in $$$m$$$ groups of friends. Let's analyze the process of distributing some news between users. Initially, some user $$$x$$$ receives the news from some source. Then he or she sends the news to his or her friends (two users are friends if th...
1,400
false
false
false
false
false
false
false
false
false
true
4,881
348E
A long time ago there was a land called Dudeland. Dudeland consisted of _n_ towns connected with _n_u2009-u20091 bidirectonal roads. The towns are indexed from 1 to _n_ and one can reach any city from any other city if he moves along the roads of the country. There are _m_ monasteries in Dudeland located in _m_ differe...
2,800
false
false
false
true
false
false
false
false
false
false
8,438
1075B
Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5. Lyft has become so popular so that it is now used by all $$$m$$$ taxi drivers in the city, who every day transport the rest of the city residentsxa0— $$$n$$$ riders. Each resident (including taxi driv...
1,200
false
false
true
false
false
false
false
false
true
false
5,345
1250H
You have a set of birthday cake candles. Each of such candles represents a digit between $$$0$$$ and $$$9$$$, inclusive. Example of birthday cake candles. Let's denote the candle representing the digit $$$d$$$ as $$$d$$$-candle. Your set contains $$$c_0$$$ instances of $$$0$$$-candles, $$$c_1$$$ instances of $$$1$$$-c...
1,500
true
false
false
false
false
false
false
false
false
false
4,448
2029D
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Refact.ai Match 1 (Codeforces Round 985) 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 c...
1,900
false
true
false
false
true
true
false
false
false
true
94
729C
Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in _t_ minutes. There is a straight road of length _s_ from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point...
1,700
false
true
false
false
false
false
false
true
true
false
6,892
1000C
You are given $$$n$$$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide. Your task is the following: for every $$$k in [1..n]$$$, calculate the number of points w...
1,700
false
false
true
false
true
false
false
false
true
false
5,703
769B
Polycarp studies at the university in the group which consists of _n_ students (including himself). All they are registrated in the social net "TheContacnt!". Not all students are equally sociable. About each student you know the value _a__i_ — the maximum number of messages which the _i_-th student is agree to send pe...
1,200
false
true
false
false
false
false
false
false
false
false
6,705
75D
Ahmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mostafa couldn't. This problem is similar to a standard problem but it has a different format and constraints. In the standar...
2,000
true
true
true
true
true
false
false
false
false
false
9,588
976C
Problem - 976C - 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,500
false
true
true
false
false
false
false
false
true
false
5,828
793F
After hard work Igor decided to have some rest. He decided to have a snail. He bought an aquarium with a slippery tree trunk in the center, and put a snail named Julia into the aquarium. Igor noticed that sometimes Julia wants to climb onto the trunk, but can't do it because the trunk is too slippery. To help the snail...
3,000
false
false
false
true
true
false
false
false
false
false
6,602
558B
Problem - 558B - 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,300
false
false
true
false
false
false
false
false
false
false
7,602
1674F
Your friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size $$$n imes m$$$ consisting of characters '.' (empty cell of the desktop) and '*' (an icon). The desktop is called good if all its icons are occupying some prefix of full columns and, possibly, the ...
1,800
false
true
true
false
true
false
false
false
false
false
2,224
1508D
Based on a peculiar incident at basketball practice, Akari came up with the following competitive programming problem! You are given $$$n$$$ points on the plane, no three of which are collinear. The $$$i$$$-th point initially has a label $$$a_i$$$, in such a way that the labels $$$a_1, a_2, dots, a_n$$$ form a permutat...
3,000
false
false
false
false
false
true
false
false
true
false
3,133
997A
You've got a string $$$a_1, a_2, dots, a_n$$$, consisting of zeros and ones. Let's call a sequence of consecutive elements $$$a_i, a_{iu2009+u20091}, ldots,u2009a_j$$$ ($$$1lequ2009ilequ2009jlequ2009n$$$) a substring of string $$$a$$$. You can apply the following operations any number of times: Choose some substring o...
1,500
true
true
true
false
false
false
true
false
false
false
5,718
385C
Recently, the bear started studying data structures and faced the following problem. You are given a sequence of integers _x_1,u2009_x_2,u2009...,u2009_x__n_ of length _n_ and _m_ queries, each of them is characterized by two integers _l__i_,u2009_r__i_. Let's introduce _f_(_p_) to represent the number of such indexes ...
1,700
true
false
true
true
true
false
true
true
false
false
8,289
1527B2
The only difference between the easy and hard versions is that the given string $$$s$$$ in the easy version is initially a palindrome, this condition is not always true for the hard version. A palindrome is a string that reads the same left to right and right to left. For example, "101101" is a palindrome, while "0101"...
1,900
false
false
false
false
false
true
false
false
false
false
3,027
1476A
Problem - 1476A - 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 - ...
1,000
true
true
false
false
false
true
false
true
false
false
3,297
888D
Problem - 888D - Codeforces =============== xa0 such that _p__i_u2009=u2009_i_. Your task is to count the number of almost identity permutations for given numbers _n_ and _k_. Input The first line contains two integers _n_ and _k_ (4u2009≤u2009_n_u2009≤u20091000, 1u2009≤u2009_k_u2009≤u20094). Output Print...
1,600
true
false
false
true
false
false
false
false
false
false
6,193
1205D
You are given a tree with $$$n$$$ nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes $$$i$$$, $$$j$$$, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then ev...
2,700
false
false
false
false
false
true
false
false
false
false
4,666
1876G
There is an extremely hard video game that is one of Chaneka's favourite video games. One of the hardest levels in the game is called Clubstep. Clubstep consists of $$$n$$$ parts, numbered from $$$1$$$ to $$$n$$$. Chaneka has practised the level a good amount, so currently, her familiarity value with each part $$$i$$$ ...
3,500
false
true
false
false
true
false
true
true
false
false
1,020
1510K
The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task. There is a permutation $$$p_i$$$ of numbers from 1 to $$$2n$$$. You can make two types of operations. 1. ...
1,200
false
false
true
false
false
false
true
false
false
true
3,117
1194E
There are $$$n$$$ segments drawn on a plane; the $$$i$$$-th segment connects two points ($$$x_{i, 1}$$$, $$$y_{i, 1}$$$) and ($$$x_{i, 2}$$$, $$$y_{i, 2}$$$). Each segment is non-degenerate, and is either horizontal or vertical — formally, for every $$$i in [1, n]$$$ either $$$x_{i, 1} = x_{i, 2}$$$ or $$$y_{i, 1} = y_...
2,200
false
false
false
false
true
false
true
false
true
false
4,732
1452E
Berland regional ICPC contest has just ended. There were $$$m$$$ participants numbered from $$$1$$$ to $$$m$$$, who competed on a problemset of $$$n$$$ problems numbered from $$$1$$$ to $$$n$$$. Now the editorial is about to take place. There are two problem authors, each of them is going to tell the tutorial to exactl...
2,500
false
true
false
true
false
false
true
false
true
false
3,417
1181E1
This problem differs from the next problem only in constraints. Petya decided to visit Byteland during the summer holidays. It turned out that the history of this country is quite unusual. Initially, there were $$$n$$$ different countries on the land that is now Berland. Each country had its own territory that was repr...
2,500
false
false
false
false
false
false
true
false
true
false
4,810
995D
Allen and Bessie are playing a simple number game. They both know a function $$$f: {0, 1}^n o mathbb{R}$$$, i.xa0e. the function takes $$$n$$$ binary arguments and returns a real value. At the start of the game, the variables $$$x_1, x_2, dots, x_n$$$ are all set to $$$-1$$$. Each round, with equal probability, one of...
2,500
true
false
false
false
false
false
false
false
false
false
5,723
1891D
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 907 (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...
1,900
true
false
false
false
false
false
true
true
false
false
954
72G
Problem - 72G - Codeforces =============== xa0 → 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 - solve these problems in...
1,000
false
false
false
true
false
false
false
false
false
false
9,605
864E
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take _t__i_ seconds to save _i_-th item. In addition, for each item, he estimated the value of _d__i_ — the moment after which the item _i_ will be completely burned and will no long...
2,000
false
false
false
true
false
false
false
false
true
false
6,283
1051F
You are given a weighed undirected connected graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. You should answer $$$q$$$ queries, the $$$i$$$-th query is to find the shortest distance between vertices $$$u_i$$$ and $$$v_i$$$. Input The first line contains two integers $$$n$$$ and $$$m~(1 le n, m le 10^5, m - n l...
2,400
false
false
false
false
false
false
false
false
false
true
5,450
868D
You are given _n_ strings _s_1,u2009_s_2,u2009...,u2009_s__n_ consisting of characters 0 and 1. _m_ operations are performed, on each of them you concatenate two existing strings into a new one. On the _i_-th operation the concatenation _s__a__i__s__b__i_ is saved into a new string _s__n_u2009+u2009_i_ (the operations ...
2,200
false
false
true
true
false
false
true
false
false
false
6,270
1303F
You are given a matrix $$$n imes m$$$, initially filled with zeroes. We define $$$a_{i, j}$$$ as the element in the $$$i$$$-th row and the $$$j$$$-th column of the matrix. Two cells of the matrix are connected if they share a side, and the elements in these cells are equal. Two cells of the matrix belong to the same c...
2,800
false
false
true
false
false
false
false
false
false
false
4,173
1933C
You are given three positive integers $$$a$$$, $$$b$$$ and $$$l$$$ ($$$a,b,l>0$$$). It can be shown that there always exists a way to choose non-negative (i.e. $$$ge 0$$$) integers $$$k$$$, $$$x$$$, and $$$y$$$ such that $$$l = k cdot a^x cdot b^y$$$. Your task is to find the number of distinct possible values of $$$k$...
1,100
true
false
true
false
false
false
true
false
false
false
685
1789A
Mocha likes arrays, and Serval gave her an array consisting of positive integers as a gift. Mocha thinks that for an array of positive integers $$$a$$$, it is good iff the =3$$$ is greater than its length $$$2$$$. $$$[1,2,4]$$$ is both good and beautiful, because all of its prefixes whose length is no less than $$$2$$...
800
true
false
false
false
false
false
true
false
false
false
1,548
86C
Multidimensional spaces are completely out of style these days, unlike genetics problems" — thought physicist Woll and changed his subject of study to bioinformatics. Analysing results of sequencing he faced the following problem concerning DNA sequences. We will further think of a DNA sequence as an arbitrary string o...
2,500
false
false
false
true
false
false
false
false
false
false
9,539
455E
Problem - 455E - 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,900
false
false
false
false
true
false
false
false
false
false
8,015
641A
Problem - 641A - Codeforces =============== xa0 ]( "VK Cup 2016 — Round 2 (announcement)") ") xa0— length of the strip. Next line contains a string of length _n_ which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains _n_ integer...
1,000
false
false
true
false
false
false
false
false
false
false
7,251
325A
Problem - 325A - Codeforces =============== xa0 . Your task is to determine if the rectangles form a square. In other words, determine if the set of points inside or on the border of at least one rectangle is precisely equal to the set of points inside or on the border of some square. Input The first line...
1,500
false
false
true
false
false
false
false
false
false
false
8,541
746A
Nikolay has _a_ lemons, _b_ apples and _c_ pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1:u20092:u20094. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fru...
800
true
false
true
false
false
false
false
false
false
false
6,817