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
1401D
You are given a tree that consists of $$$n$$$ nodes. You should label each of its $$$n-1$$$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $$$0$$$; the product of all $$$n-1$$$ numbers should be equal to $$$k$$$; the number of $$$1$$$-s among all $$$n-1$$...
1,800
true
true
true
true
false
false
false
false
true
false
3,662
1409E
There are $$$n$$$ points on a plane. The $$$i$$$-th point has coordinates $$$(x_i, y_i)$$$. You have two horizontal platforms, both of length $$$k$$$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $$$y$$$-coordinate) and have integer borders. If the left border of the...
1,800
false
false
false
true
false
false
false
true
true
false
3,623
671C
Yasin has an array _a_ containing _n_ integers. Yasin is a 5 year old, so he loves ultimate weird things. Yasin denotes weirdness of an array as maximum _gcd_(_a__i_,u2009u2009_a__j_) value among all 1u2009≤u2009_i_u2009<u2009_j_u2009≤u2009_n_. For _n_u2009≤u20091 weirdness is equal to 0, _gcd_(_x_,u2009u2009_y_) is th...
2,800
false
false
false
false
true
false
false
false
false
false
7,138
865G
It's Piegirl's birthday soon, and Pieguy has decided to buy her a bouquet of flowers and a basket of chocolates. The flower shop has _F_ different types of flowers available. The _i_-th type of flower always has exactly _p__i_ petals. Pieguy has decided to buy a bouquet consisting of exactly _N_ flowers. He may buy the...
3,300
true
false
false
false
false
false
false
false
false
false
6,275
877A
Problem - 877A - 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,100
false
false
true
false
false
false
false
false
false
false
6,240
703B
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXXxa0— beautiful, but little-known northern country. Here are some interesting facts about XXX: 1. XXX consists of _n_ cities, _k_ of whose (just imagine!) are capital cities. 2. All of cities i...
1,400
true
false
true
false
false
false
false
false
false
false
7,010
933D
Everything red frightens Nian the monster. So do red paper and... you, red on Codeforces, potential or real. Big Banban has got a piece of paper with endless lattice points, where lattice points form squares with the same area. His most favorite closed shape is the circle because of its beauty and simplicity. Once he h...
2,900
true
false
false
false
false
false
true
false
false
false
5,968
1578G
The King wants to marry off his daughter, and he wants her husband to have the greatest innate luckiness possible. To find such a person he decided to hold a heads-or-tails tournament. If person $$$A$$$ with luckiness $$$x$$$ and person $$$B$$$ with luckiness $$$y$$$ play heads-or-tails against each other, person $$$A$...
3,500
true
false
false
false
false
false
false
false
false
false
2,748
1487C
A big football championship will occur soon! $$$n$$$ teams will compete in it, and each pair of teams will play exactly one game against each other. There are two possible outcomes of a game: the game may result in a tie, then both teams get $$$1$$$ point; one team might win in a game, then the winning team gets $$$3...
1,500
true
true
true
false
false
true
true
false
false
true
3,244
1992B
To celebrate his recovery, k1o0n has baked an enormous $$$n$$$ metres long potato casserole. Turns out, Noobish_Monk just can't stand potatoes, so he decided to ruin k1o0n's meal. He has cut it into $$$k$$$ pieces, of lengths $$$a_1, a_2, dots, a_k$$$ meters. k1o0n wasn't keen on that. Luckily, everything can be fixed....
800
true
true
false
false
false
false
false
false
true
false
318
940D
We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme." "Little Alena got an array as a birthday present..." The array _b_ of length _n_ is obtained from the array _a_ of length _n_ and two integers _l_ and _r_xa0(_l_u2009≤u2009_r_) using the following p...
1,600
false
false
true
false
false
false
false
true
false
false
5,935
898B
Vasya has _n_ burles. One bottle of Ber-Cola costs _a_ burles and one Bars bar costs _b_ burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars. Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly _n_ bur...
1,100
false
false
true
false
false
false
true
false
false
false
6,157
992B
Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well. We define a pair of integers (_a_,u2009_b_) good, if _GCD_(_a_,u2009_b_)u2009=u2009_x_ and _LCM_(_a_,u2009_b_)u2009=u2009_...
1,600
true
false
false
false
false
false
false
false
false
false
5,738
1129A1
This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled. Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $$$n$$$ stations, enumerated from $$$1$$$ through $$$n$$$. The train occupi...
1,700
false
true
false
false
false
false
true
false
false
false
5,077
1474C
You found a useless array $$$a$$$ of $$$2n$$$ positive integers. You have realized that you actually don't need this array, so you decided to throw out all elements of $$$a$$$. It could have been an easy task, but it turned out that you should follow some rules: 1. In the beginning, you select any positive integer $$$x...
1,700
false
true
true
false
true
true
true
false
true
false
3,308
1791G2
The only difference between the easy and hard versions are the locations you can teleport to. Consider the points $$$0,1,dots,n+1$$$ on the number line. There is a teleporter located on each of the points $$$1,2,dots,n$$$. At point $$$i$$$, you can do the following: Move left one unit: it costs $$$1$$$ coin. Move rig...
1,900
false
true
false
false
false
false
false
true
true
false
1,528
1147B
Inaka has a disc, the circumference of which is $$$n$$$ units. The circumference is equally divided by $$$n$$$ points numbered clockwise from $$$1$$$ to $$$n$$$, such that points $$$i$$$ and $$$i + 1$$$ ($$$1 leq i < n$$$) are adjacent, and so are points $$$n$$$ and $$$1$$$. There are $$$m$$$ straight segments on the d...
1,900
false
false
false
false
false
false
true
false
false
false
4,982
679D
Bearland has _n_ cities, numbered 1 through _n_. There are _m_ bidirectional roads. The _i_-th road connects two distinct cities _a__i_ and _b__i_. No two roads connect the same pair of cities. It's possible to get from any city to any other city (using one or more roads). The distance between cities _a_ and _b_ is def...
2,900
true
false
true
false
false
false
true
false
false
true
7,107
1982E
Let $$$bit(x)$$$ denote the number of ones in the binary representation of a non-negative integer $$$x$$$. A subarray of an array is called $$$k$$$-good if it consists only of numbers with no more than $$$k$$$ ones in their binary representation, i.e., a subarray $$$(l, r)$$$ of array $$$a$$$ is good if for any $$$i$$$...
2,300
true
false
false
true
false
false
true
false
false
false
392
1718A2
This is the hard version of this problem. The difference between easy and hard versions is only the constraints on $$$a_i$$$ and on $$$n$$$. You can make hacks only if both versions of the problem are solved. Burenka is the crown princess of Buryatia, and soon she will become the $$$n$$$-th queen of the country. There ...
1,900
false
true
false
true
true
false
false
false
false
false
1,974
1260D
You are playing a computer game, where you lead a party of $$$m$$$ soldiers. Each soldier is characterised by his agility $$$a_i$$$. The level you are trying to get through can be represented as a straight line segment from point $$$0$$$ (where you and your squad is initially located) to point $$$n + 1$$$ (where the bo...
1,900
false
true
false
true
false
false
false
true
true
false
4,391
1009F
Problem - 1009F - 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
false
true
false
false
false
false
false
5,637
1725H
One day, you are accepted as being Dr. Chanek's assistant. The first task given by Dr. Chanek to you is to take care and store his magical stones. Dr. Chanek has $$$N$$$ magical stones with $$$N$$$ being an even number. Those magical stones are numbered from $$$1$$$ to $$$N$$$. Magical stone $$$i$$$ has a strength of $...
1,800
true
false
false
false
false
true
false
false
false
false
1,939
1759C
Vlad came home and found out that someone had reconfigured the old thermostat to the temperature of $$$a$$$. The thermostat can only be set to a temperature from $$$l$$$ to $$$r$$$ inclusive, the temperature cannot change by less than $$$x$$$. Formally, in one operation you can reconfigure the thermostat from temperatu...
1,100
true
true
false
false
false
false
false
false
false
false
1,760
1914C
Monocarp is playing a computer game. In order to level up his character, he can complete quests. There are $$$n$$$ quests in the game, numbered from $$$1$$$ to $$$n$$$. Monocarp can complete quests according to the following rules: the $$$1$$$-st quest is always available for completion; the $$$i$$$-th quest is avail...
1,100
true
true
false
false
false
false
false
false
false
false
817
553E
Kyoya Ootori wants to take the train to get to school. There are _n_ train stations and _m_ one-way train lines going between various stations. Kyoya is currently at train station 1, and the school is at station _n_. To take a train, he must pay for a ticket, and the train also takes a certain amount of time. However, ...
3,200
true
false
false
true
false
false
false
false
false
true
7,618
333E
Problem - 333E - 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,500
false
false
false
false
false
false
true
true
true
false
8,501
411A
Problem - 411A - Codeforces =============== xa0 ") . Each character is either a large English letter, or a small English letter, or a digit, or one of characters: "!", "?", ".", ",", "_". Output If the password is complex enough, print message "Correct" (without the quotes), otherwise print message "Too w...
800
false
false
true
false
false
false
false
false
false
false
8,182
1994A
Petr, watching Sergey's stream, came up with a matrix $$$a$$$, consisting of $$$n$$$ rows and $$$m$$$ columns (the number in the $$$i$$$-th row and $$$j$$$-th column is denoted as $$$a_{i, j}$$$), which contains all integers from $$$1$$$ to $$$n cdot m$$$. But he didn't like the arrangement of the numbers, and now he w...
800
false
true
true
false
false
true
false
false
false
false
305
1650E
Now Dmitry has a session, and he has to pass $$$n$$$ exams. The session starts on day $$$1$$$ and lasts $$$d$$$ days. The $$$i$$$th exam will take place on the day of $$$a_i$$$ ($$$1 le a_i le d$$$), all $$$a_i$$$xa0— are different. Sample, where $$$n=3$$$, $$$d=12$$$, $$$a=[3,5,9]$$$. Orangexa0— exam days. Before the...
1,900
true
true
true
false
true
false
false
true
true
false
2,371
1381A2
This is the hard version of the problem. The difference between the versions is the constraint on $$$n$$$ and the required number of operations. You can make hacks only if all versions of the problem are solved. There are two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$ (a binary string is a string consisting o...
1,700
false
false
true
false
true
true
false
false
false
false
3,763
1428C
Zookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters 'A' and 'B'. He can use bombs to bomb a substring which is either "AB" or "BB". When he bombs such a substring, the substring gets deleted from the string and the remaining parts of the string get concatenated....
1,100
false
true
false
false
true
false
true
false
false
false
3,523
1674E
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall. The wall consists of $$$n$$$ sections, aligned in a row. The $$$i$$$-th sectio...
2,000
true
true
false
false
false
true
true
true
false
false
2,225
1054C
There are $$$n$$$ children numbered from $$$1$$$ to $$$n$$$ in a kindergarten. Kindergarten teacher gave $$$a_i$$$ ($$$1 leq a_i leq n$$$) candies to the $$$i$$$-th child. Children were seated in a row in order from $$$1$$$ to $$$n$$$ from left to right and started eating candies. While the $$$i$$$-th child was eating ...
1,500
false
false
true
false
false
true
false
false
false
false
5,445
368B
Problem - 368B - 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,100
false
false
false
true
true
false
false
false
false
false
8,359
1958A
In Berland, coins of worth $$$1$$$, $$$3$$$ and $$$5$$$ burles are commonly used (burles are local currency). Eva has to pay exactly $$$n$$$ burles in a shop. She has an infinite amount of coins of all three types. However, she doesn't like to pay using coins worth $$$1$$$ burle — she thinks they are the most convenien...
1,100
false
false
false
true
false
false
false
false
false
false
526
323B
Problem - 323B - Codeforces =============== xa0 (_v_u2009≠u2009_u_) there exists a path from vertex _v_ to vertex _u_ consisting of no more then two edges. A directed graph without self-loops is a tournament, if there is exactly one edge between any two distinct vertices (in one out of two possible directions...
2,200
false
false
false
false
false
true
false
false
false
true
8,543
858B
In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are o...
1,500
false
false
true
false
false
false
true
false
false
false
6,313
528D
Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'. Let's consider the following scenario. There is a fragment of a human DNA chain, recorded as a str...
2,500
false
false
false
false
false
false
true
false
false
false
7,719
1775A1
This is an easy version of the problem. The difference between the versions is that the string can be longer than in the easy version. You can only do hacks if both versions of the problem are passed. Kazimir Kazimirovich is a Martian gardener. He has a huge orchard of binary balanced apple trees. Recently Casimir deci...
800
false
false
true
false
false
true
true
false
false
false
1,635
1056A
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in. During his ride, Arkady woke up several times...
800
false
false
true
false
false
false
false
false
false
false
5,432
1833C
Vlad was given an array $$$a$$$ of $$$n$$$ positive integers. Now he wants to build a beautiful array $$$b$$$ of length $$$n$$$ from it. Vlad considers an array beautiful if all the numbers in it are positive and have the same parity. That is, all numbers in the beautiful array are greater than zero and are either all ...
800
true
true
false
false
false
false
false
false
false
false
1,289
355A
Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you. Let's assume that _S_(_n_) is the sum of digits of number _n_, for example, _S_(4098)u2009=u20094u2009+u20090u2009+u20099u2009+u20098u2009=u200921. Then the digital root of number _n_ equals to: 1. _dr_(_n_)u...
1,100
false
false
true
false
false
true
false
false
false
false
8,413
196C
You are given a tree with _n_ vertexes and _n_ points on a plane, no three points lie on one straight line. Your task is to paint the given tree on a plane, using the given points as vertexes. That is, you should correspond each vertex of the tree to exactly one point and each point should correspond to a vertex. If tw...
2,200
false
false
false
false
false
true
false
false
true
false
9,056
1926F
Vladislav has a grid of size $$$7 imes 7$$$, where each cell is colored black or white. In one operation, he can choose any cell and change its color (black $$$leftrightarrow$$$ white). Find the minimum number of operations required to ensure that there are no black cells with four diagonal neighbors also being black....
2,200
false
false
true
true
false
false
true
false
false
false
732
685A
Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches. First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in _n_ hou...
1,700
true
false
false
true
false
false
true
false
false
false
7,083
984B
One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won. Alex has grown up since then, so he easily wins the most difficul...
1,100
false
false
true
false
false
false
false
false
false
false
5,780
484B
, where 1u2009≤u2009_i_,u2009_j_u2009≤u2009_n_ and _a__i_u2009≥u2009_a__j_. Input The first line contains integer _n_xa0— the length of the sequence (1u2009≤u2009_n_u2009≤u20092·105). The second line contains _n_ space-separated integers _a__i_ (1u2009≤u2009_a__i_u2009≤u2009106). Output Print the answer to the problem.
2,100
true
false
false
false
false
false
false
true
true
false
7,901
1491G
There are $$$n$$$ coins labeled from $$$1$$$ to $$$n$$$. Initially, coin $$$c_i$$$ is on position $$$i$$$ and is facing upwards (($$$c_1, c_2, dots, c_n)$$$ is a permutation of numbers from $$$1$$$ to $$$n$$$). You can do some operations on these coins. In one operation, you can do the following: Choose $$$2$$$ distin...
2,800
true
false
false
false
false
true
false
false
false
true
3,216
679A
This is an interactive problem. In the output section below you will see the information about flushing the output. Bear Limak thinks of some hidden numberxa0— an integer from interval [2,u2009100]. Your task is to say if the hidden number is prime or composite. Integer _x_u2009>u20091 is called prime if it has exactly...
1,400
true
false
false
false
false
true
false
false
false
false
7,110
333C
Gerald has a friend, Pollard. Pollard is interested in lucky tickets (ticket is a sequence of digits). At first he thought that a ticket is lucky if between some its digits we can add arithmetic signs and brackets so that the result obtained by the arithmetic expression was number 100. But he quickly analyzed all such ...
2,700
false
false
false
false
false
true
true
false
false
false
8,503
1787H
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN TypeDB Forces 2023 (Div. 1 + Div. 2, Rated, Prizes!) 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 f...
3,300
false
false
false
true
true
false
false
true
false
false
1,556
269E
Emuskald is an innovative musician and always tries to push the boundaries of music production. Now he has come up with an idea for a revolutionary musical instrument — a rectangular harp. A rectangular harp is a rectangle _n_u2009×u2009_m_ consisting of _n_ rows and _m_ columns. The rows are numbered 1 to _n_ from top...
3,100
true
false
false
false
false
false
false
false
false
false
8,754
293E
Problem - 293E - Codeforces =============== xa0 , such that vertices _v_ and _u_ are close. Input The first line contains three integers _n_, _l_ and _w_ (1u2009≤u2009_n_u2009≤u2009105,u20091u2009≤u2009_l_u2009≤u2009_n_,u20090u2009≤u2009_w_u2009≤u2009109). The next _n_u2009-u20091 lines contain the descri...
2,700
false
false
false
false
true
false
false
false
false
false
8,657
1837A
You are given two integers $$$x$$$ and $$$k$$$. Grasshopper starts in a point $$$0$$$ on an OX axis. In one move, it can jump some integer distance, that is not divisible by $$$k$$$, to the left or to the right. What's the smallest number of moves it takes the grasshopper to reach point $$$x$$$? What are these moves? I...
800
true
false
false
false
false
true
false
false
false
false
1,270
1475D
Polycarp often uses his smartphone. He has already installed $$$n$$$ applications on it. Application with number $$$i$$$ takes up $$$a_i$$$ units of memory. Polycarp wants to free at least $$$m$$$ units of memory (by removing some applications). Of course, some applications are more important to Polycarp than others. H...
1,800
false
false
false
true
false
false
false
true
true
false
3,301
1644C
You are given an array $$$a_1, a_2, dots, a_n$$$, consisting of $$$n$$$ integers. You are also given an integer value $$$x$$$. Let $$$f(k)$$$ be the maximum sum of a contiguous subarray of $$$a$$$ after applying the following operation: add $$$x$$$ to the elements on exactly $$$k$$$ distinct positions. An empty subarra...
1,400
false
true
true
true
false
false
true
false
false
false
2,399
1975F
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 947 (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,600
true
false
false
true
false
false
true
false
false
false
437
1957D
You are given an array $$$a_1, a_2, ldots, a_n$$$. Find the number of tuples ($$$x, y, z$$$) such that: $$$1 leq x leq y leq z leq n$$$, and $$$f(x, y) oplus f(y, z) > f(x, z)$$$. We define $$$f(l, r) = a_l oplus a_{l + 1} oplus ldots oplus a_{r}$$$, where $$$oplus$$$ denotes the xa0— the number of test cases. The fi...
1,900
true
false
false
true
false
false
true
false
false
false
530
651B
Problem - 651B - 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,200
false
true
false
false
false
false
false
false
true
false
7,211
1571E
A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example: bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)"); br...
1,700
false
true
false
true
false
false
false
false
false
false
2,788
1769C2
Statement is not available on English language В этой версии задачи $$$n le 2 cdot 10^5$$$ и $$$a_i le 10^6$$$ (а также есть ограничение на сумму $$$n$$$ по наборам входных данных внутри одного теста). Вика за время работы в компании VK уже сделала $$$n$$$ коммитов в системе контроля версий. $$$i$$$-й коммит был сделан...
1,300
false
false
false
true
false
false
false
false
false
false
1,681
1957C
You are given an $$$n imes n$$$ chessboard where you and the computer take turns alternatingly to place white rooks & black rooks on the board respectively. While placing rooks, you have to ensure that no two rooks attack each other. Two rooks attack each other if they share the same row or column regardless of color....
1,600
true
false
false
true
false
false
false
false
false
false
531
118D
Problem - 118D - 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
false
false
false
true
false
false
false
false
false
false
9,413
1616D
You are given an array of integers $$$a_1, a_2, ldots, a_n$$$ and an integer $$$x$$$. You need to select the maximum number of elements in the array, such that for every subsegment $$$a_l, a_{l + 1}, ldots, a_r$$$ containing strictly more than one element $$$(l < r)$$$, either: At least one element on this subsegment ...
2,000
true
true
false
true
false
false
false
false
false
false
2,553
936B
Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of _n_ vertices and _m_ edges. One of the vertices contains a chip. Initially the chip is located at vertex _s_. Players take turns moving the chip along some edge of the graph. Petya goes first. Player who c...
2,100
false
false
false
true
false
false
false
false
false
true
5,957
910B
Petya has equal wooden bars of length _n_. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length _a_ and one top side of length _b_. A solid (i.e. continuous without breaks) piece of bar is needed for each side. Determine a minimal number of wooden bars which are nee...
1,600
false
true
true
false
false
false
false
false
false
false
6,105
1934B
You have $$$5$$$ different types of coins, each with a value equal to one of the first $$$5$$$ triangular numbers: $$$1$$$, $$$3$$$, $$$6$$$, $$$10$$$, and $$$15$$$. These coin types are available in abundance. Your goal is to find the minimum number of these coins required such that their total value sums up to exactl...
1,200
true
true
false
true
false
false
true
false
false
false
679
1673C
You are given a positive integer $$$n$$$. Let's call some positive integer $$$a$$$ without leading zeroes palindromic if it remains the same after reversing the order of its digits. Find the number of distinct ways to express $$$n$$$ as a sum of positive palindromic integers. Two ways are considered different if the fr...
1,500
true
false
false
true
false
false
true
false
false
false
2,233
1399A
You are given the array $$$a$$$ consisting of $$$n$$$ positive (greater than zero) integers. In one move, you can choose two indices $$$i$$$ and $$$j$$$ ($$$i e j$$$) such that the absolute difference between $$$a_i$$$ and $$$a_j$$$ is no more than one ($$$a_i - a_j le 1$$$) and remove the smallest of these two elemen...
800
false
true
false
false
false
false
false
false
true
false
3,679
1267K
Karl is developing a key storage service. Each user has a positive integer key. Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one. K...
2,100
true
false
false
false
false
false
false
false
false
false
4,353
1307D
Bessie is out grazing on the farm, which consists of $$$n$$$ fields connected by $$$m$$$ bidirectional roads. She is currently at field $$$1$$$, and will return to her home at field $$$n$$$ at the end of the day. The Cowfederation of Barns has ordered Farmer John to install one extra bidirectional road. The farm has $$...
1,900
false
true
false
false
true
false
false
true
true
true
4,153
351C
Problem - 351C - 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,500
false
false
false
true
false
false
false
false
false
false
8,428
700A
On vacations _n_ pupils decided to go on excursion and gather all together. They need to overcome the path with the length _l_ meters. Each of the pupils will go with the speed equal to _v_1. To get to the excursion quickly, it was decided to rent a bus, which has seats for _k_ people (it means that it can't fit more t...
1,900
true
false
false
false
false
false
false
true
false
false
7,025
1986C
Let's consider the following simple problem. You are given a string $$$s$$$ of length $$$n$$$, consisting of lowercase Latin letters, as well as an array of indices $$$ind$$$ of length $$$m$$$ ($$$1 leq ind_i leq n$$$) and a string $$$c$$$ of length $$$m$$$, consisting of lowercase Latin letters. Then, in order, you pe...
1,100
false
true
false
false
true
false
false
false
true
false
363
1906M
You are given a regular $$$N$$$-sided polygon. Label one arbitrary side as side $$$1$$$, then label the next sides in clockwise order as side $$$2$$$, $$$3$$$, $$$dots$$$, $$$N$$$. There are $$$A_i$$$ special points on side $$$i$$$. These points are positioned such that side $$$i$$$ is divided into $$$A_i + 1$$$ segmen...
1,700
true
true
false
false
false
false
false
false
false
false
865
852F
Problem - 852F - Codeforces =============== xa0 ]( "Mirror of Bubble Cup X Finals on Codeforces") , where is the multiplicative order of the integer _a_ modulo _Q_, see notes for definition. Output You should output the array _A_ from left to right. Example Input 2 2 2 7 Output 1 2 Note The multiplicativ...
2,200
true
false
false
false
false
false
false
false
false
false
6,338
1528D
There are $$$n$$$ cities in Shaazzzland, numbered from $$$0$$$ to $$$n-1$$$. Ghaazzzland, the immortal enemy of Shaazzzland, is ruled by AaParsa. As the head of the Ghaazzzland's intelligence agency, AaParsa is carrying out the most important spying mission in Ghaazzzland's history on Shaazzzland. AaParsa has planted $...
2,500
false
false
false
false
false
true
false
false
false
true
3,020
1111E
You are given a tree with $$$n$$$ nodes and $$$q$$$ queries. Every query starts with three integers $$$k$$$, $$$m$$$ and $$$r$$$, followed by $$$k$$$ nodes of the tree $$$a_1, a_2, ldots, a_k$$$. To answer a query, assume that the tree is rooted at $$$r$$$. We want to divide the $$$k$$$ given nodes into at most $$$m$$$...
2,500
false
false
false
true
true
false
false
false
false
true
5,137
1281A
We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning...
800
false
false
true
false
false
false
false
false
false
false
4,288
145C
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence _a_ consisting of _n_ integers. The subsequence of the sequence _a_ is such subs...
2,100
true
false
false
true
false
false
false
false
false
false
9,293
356D
When you were a child you must have been told a puzzle of bags and coins. Anyway, here's one of its versions: A horse has three bags. The first bag has one coin, the second bag has one coin and the third bag has three coins. In total, the horse has three coins in the bags. How is that possible? The answer is quite simp...
2,700
false
true
false
true
false
true
false
false
false
false
8,408
66E
Little Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the morning he should leave the house and go to some post office. In the office he receives a portion of letters and a car. Then ...
2,000
false
false
false
true
true
false
false
false
false
false
9,637
1991B
You are given an array $$$b$$$ of $$$n - 1$$$ integers. An array $$$a$$$ of $$$n$$$ integers is called good if $$$b_i = a_i , & , a_{i + 1}$$$ for $$$1 le i le n-1$$$, where $$$&$$$ denotes the xa0— the number of test cases. The description of test cases follows. The first line of each test case contains a single integ...
1,100
false
true
false
false
false
true
false
false
false
false
327
1131G
Semyon participates in the most prestigious competition of the world ocean for the title of the most dangerous shark. During this competition sharks compete in different subjects: speed swimming, masking, map navigation and many others. Now Semyon is taking part in «destruction» contest. During it, $$$m$$$ dominoes are...
2,700
false
false
false
true
true
false
false
false
false
false
5,062
1915C
Calin has $$$n$$$ buckets, the $$$i$$$-th of which contains $$$a_i$$$ wooden squares of side length $$$1$$$. Can Calin build a square using all the given squares? Input The first line contains a single integer $$$t$$$ ($$$1 leq t leq 10^4$$$)xa0— the number of test cases. The first line of each test case contains a sin...
800
false
false
true
false
false
false
false
true
false
false
808
1907G
In the end of the day, Anna needs to turn off the lights in the office. There are $$$n$$$ lights and $$$n$$$ light switches, but their operation scheme is really strange. The switch $$$i$$$ changes the state of light $$$i$$$, but it also changes the state of some other light $$$a_i$$$ (change the state means that if th...
2,200
false
true
true
false
false
true
true
false
false
true
858
1606C
In Berland, $$$n$$$ different types of banknotes are used. Banknotes of the $$$i$$$-th type have denomination $$$10^{a_i}$$$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $$$1$$$. Let's denote $$$f(s)$$$ as the minimum number of banknotes required to repres...
1,400
false
true
false
false
false
false
false
false
false
false
2,627
1691F
You are given a tree $$$G$$$ with $$$n$$$ vertices and an integer $$$k$$$. The vertices of the tree are numbered from $$$1$$$ to $$$n$$$. For a vertex $$$r$$$ and a subset $$$S$$$ of vertices of $$$G$$$, such that $$$S = k$$$, we define $$$f(r, S)$$$ as the size of the smallest rooted subtree containing all vertices in...
2,500
true
false
false
true
false
false
false
false
false
false
2,131
402A
You have _a_ nuts and lots of boxes. The boxes have a wonderful feature: if you put _x_ (_x_u2009≥u20090) divisors (the spacial bars that can divide a box) to it, you get a box, divided into _x_u2009+u20091 sections. You are minimalist. Therefore, on the one hand, you are against dividing some box into more than _k_ se...
1,100
true
true
false
false
false
false
false
false
false
false
8,217
1580F
Problem - 1580F - 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 - ...
3,300
true
false
false
false
false
false
false
false
false
false
2,728
1379C
Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $$$n$$$ flowers. Vladimir went to a flower shop, and he was amazed to see that there are $$$m$$$ types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladimir wants to choo...
2,000
false
true
false
true
true
false
true
true
true
false
3,776
1209E1
This is an easier version of the next problem. The difference is only in constraints. You are given a rectangular $$$n imes m$$$ matrix $$$a$$$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform ...
2,000
false
true
false
true
false
false
true
false
true
false
4,642
490E
Peter wrote on the board a strictly increasing sequence of positive integers _a_1,u2009_a_2,u2009...,u2009_a__n_. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit. Restore the the original sequence knowing digits remaining ...
2,000
false
true
true
false
false
false
true
true
false
false
7,873
935A
Fafa owns a company that works on huge projects. There are _n_ employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees. Fafa finds doing this every time is very tiring for him. So, he decided to choose the best _l_ emp...
800
false
false
true
false
false
false
true
false
false
false
5,964
1138A
Arkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers $$$n$$$ pieces of sushi aligned in a row, and a customer has to choose a continuous subsegment of these sushi to buy. The pieces of sushi are of two types: either with tuna or with eel. Let's denote the type of the $$$i$$...
900
false
true
true
false
false
false
false
true
false
false
5,036
770C
Now you can take online courses in the Berland State University! Polycarp needs to pass _k_ main online courses of his specialty to get a diploma. In total _n_ courses are availiable for the passage. The situation is complicated by the dependence of online courses, for each course there is a list of those that must be ...
1,500
false
false
true
false
false
false
false
false
false
true
6,700
1998D
MOOOOOOOOOOOOOOOOO — Bessie the Cow, The Art of Racing on Islands Two of Farmer John's cows, Bessie and Elsie, are planning to race on $$$n$$$ islands. There are $$$n - 1$$$ main bridges, connecting island $$$i$$$ to island $$$i + 1$$$ for all $$$1 leq i leq n - 1$$$. Additionally, there are $$$m$$$ alternative bridges...
2,100
false
true
false
true
true
false
false
false
false
true
274
1667D
You are given a tree (connected, undirected, acyclic graph) with $$$n$$$ vertices. Two edges are adjacent if they share exactly one endpoint. In one move you can remove an arbitrary edge, if that edge is adjacent to an even number of remaining edges. Remove all of the edges, or determine that it is impossible. If there...
2,900
false
false
false
true
false
true
false
false
false
false
2,270
76C
Scientists of planet Olympia are conducting an experiment in mutation of primitive organisms. Genome of organism from this planet can be represented as a string of the first _K_ capital English letters. For each pair of types of genes they assigned _a__i_,u2009_j_ — a risk of disease occurence in the organism provided ...
2,700
true
false
false
true
false
false
false
false
false
false
9,584