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
1796E
Monocarp has a tree, consisting of $$$n$$$ vertices. He is going to select some vertex $$$r$$$ and perform the following operations on each vertex $$$v$$$ from $$$1$$$ to $$$n$$$: set $$$d_v$$$ equal to the distance from $$$v$$$ to $$$r$$$ (the number of edges on the shortest path); color $$$v$$$ some color. A nice c...
2,500
false
true
false
true
false
false
false
false
false
false
1,498
1951D
Alice has $$$n$$$ coins and wants to shop at Bob's jewelry store. Today, although Bob has not set up the store yet, Bob wants to make sure Alice will buy exactly $$$k$$$ jewels. To set up the store, Bob can erect at most $$$60$$$ stalls (each containing an unlimited amount of jewels) and set the price per jewel for eac...
2,000
true
true
false
false
false
true
false
false
false
false
571
1401B
You are given two sequences $$$a_1, a_2, dots, a_n$$$ and $$$b_1, b_2, dots, b_n$$$. Each element of both sequences is either $$$0$$$, $$$1$$$ or $$$2$$$. The number of elements $$$0$$$, $$$1$$$, $$$2$$$ in the sequence $$$a$$$ is $$$x_1$$$, $$$y_1$$$, $$$z_1$$$ respectively, and the number of elements $$$0$$$, $$$1$$$...
1,100
true
true
false
false
false
true
false
false
false
false
3,664
852D
The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities. After exploring the map of Serbia for a while, the competitors came up with the following facts: the country has _V_ cities which are indexed with numbers from 1 to _V_, and ...
2,100
false
false
false
false
false
false
false
true
false
false
6,340
1792B
Eve is a beginner stand-up comedian. Her first show gathered a grand total of two spectators: Alice and Bob. Eve prepared $$$a_1 + a_2 + a_3 + a_4$$$ jokes to tell, grouped by their type: type 1: both Alice and Bob like them; type 2: Alice likes them, but Bob doesn't; type 3: Bob likes them, but Alice doesn't; type...
1,200
true
true
false
false
false
false
false
false
false
false
1,526
225E
Problem - 225E - 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,100
true
false
false
false
false
false
false
false
false
false
8,936
1718C
Tonya was given an array of $$$a$$$ of length $$$n$$$ written on a postcard for his birthday. For some reason, the postcard turned out to be a cyclic array, so the index of the element located strictly to the right of the $$$n$$$-th is $$$1$$$. Tonya wanted to study it better, so he bought a robot "Burenka-179". A prog...
2,400
true
true
false
false
true
false
false
false
false
false
1,972
1789C
Toxel likes arrays. Before traveling to the Paldea region, Serval gave him an array $$$a$$$ as a gift. This array has $$$n$$$ pairwise distinct elements. In order to get more arrays, Toxel performed $$$m$$$ operations with the initial array. In the $$$i$$$-th operation, he modified the $$$p_{i}$$$-th element of the $$$...
1,500
true
false
true
true
false
false
false
false
false
false
1,546
846F
Problem - 846F - Codeforces =============== xa0 . If _l_u2009>u2009_r_, then you swap values of _l_ and _r_. You have to calculate the expected value of the number of unique elements in segment of the array from index _l_ to index _r_, inclusive (1-indexed). Input The first line contains one integer numbe...
1,800
true
false
false
false
true
false
false
false
false
false
6,372
457E
There is a computer network consisting of _n_ nodes numbered 1 through _n_. There are links in the network that connect pairs of nodes. A pair of nodes may have multiple links between them, but no node has a link to itself. Each link supports unlimited bandwidth (in either direction), however a link may only transmit i...
3,000
true
false
false
false
false
true
false
false
false
false
8,008
1728B
Problem - 1728B - 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 - ...
800
false
true
false
false
false
true
false
false
false
false
1,924
2035G1
The differences between the easy and hard versions are the constraints on $$$n$$$ and the sum of $$$n$$$. In this version, $$$n leq 3000$$$ and the sum of $$$n$$$ does not exceed $$$10^4$$$. You can only make hacks if both versions are solved. Well, well, well, let's see how Bessie is managing her finances. She seems t...
3,300
false
false
false
true
false
false
false
false
false
false
55
1138B
Polycarp is a head of a circus troupe. There are $$$n$$$xa0— an even numberxa0— artists in the troupe. It is known whether the $$$i$$$-th artist can perform as a clown (if yes, then $$$c_i = 1$$$, otherwise $$$c_i = 0$$$), and whether they can perform as an acrobat (if yes, then $$$a_i = 1$$$, otherwise $$$a_i = 0$$$)....
1,800
true
true
false
false
false
false
true
false
false
false
5,035
555A
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of _n_ matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to _n_. A matryoshka with a smaller number can ...
1,500
false
false
true
false
false
false
false
false
false
false
7,615
1969D
Alice and Bob are playing a game in the shop. There are $$$n$$$ items in the shop; each item has two parameters: $$$a_i$$$ (item price for Alice) and $$$b_i$$$ (item price for Bob). Alice wants to choose a subset (possibly empty) of items and buy them. After that, Bob does the following: if Alice bought less than $$$k...
1,900
true
true
false
false
true
false
false
false
true
false
489
1223E
You are given a weighted tree consisting of $$$n$$$ vertices. Recall that a tree is a connected graph without cycles. Vertices $$$u_i$$$ and $$$v_i$$$ are connected by an edge with weight $$$w_i$$$. Let's define the $$$k$$$-coloring of the tree as an assignment of exactly $$$k$$$ colors to each vertex, so that each col...
2,100
false
false
false
true
false
false
false
false
true
false
4,555
1037H
Some programming website is establishing a secure communication protocol. For security reasons, they want to choose several more or less random strings. Initially, they have a string $$$s$$$ consisting of lowercase English letters. Now they want to choose $$$q$$$ strings using the following steps, and you are to help t...
3,200
false
false
false
false
true
false
false
false
false
false
5,509
620B
Problem - 620B - Codeforces =============== xa0 ]( "Educational Codeforces Round 6") — the first and the last number typed by Max. Output Print the only integer _a_ — the total number of printed segments. Examples Input 1 3 Output 12 Input 10 15 Output 39
1,000
false
false
true
false
false
false
false
false
false
false
7,356
774I
Stepan has a set of _n_ strings. Also, he has a favorite string _s_. Stepan wants to do the following. He will take some strings of his set and write them down one after another. It is possible that he will take some strings more than once, and will not take some of them at all. Your task is to determine the minimum nu...
2,300
false
false
false
true
false
false
false
false
false
false
6,673
1505G
Problem - 1505G - Codeforces =============== xa0 . The next $$$N$$$ lines contain $$$5$$$ space-separated integers each. The first three integers will be between 0 and 2, inclusive. The last two integers will be between 0 and 3, inclusive. The sum of the first three integers will be equal to the sum of th...
2,600
false
false
true
false
false
false
false
false
false
false
3,146
1720C
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 815 (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,200
false
true
true
false
false
false
false
false
false
false
1,963
413A
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in _n_ steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer i...
1,200
false
false
true
false
false
false
false
false
false
false
8,174
1896B
You are given a string $$$s$$$ of length $$$n$$$ consisting of characters $$$ exttt{A}$$$ and $$$ exttt{B}$$$. You are allowed to do the following operation: Choose an index $$$1 le i le n - 1$$$ such that $$$s_i = exttt{A}$$$ and $$$s_{i + 1} = exttt{B}$$$. Then, swap $$$s_i$$$ and $$$s_{i+1}$$$. You are only allow...
900
false
true
false
false
false
false
false
false
false
false
936
774H
Stepan had a favorite string _s_ which consisted of the lowercase letters of the Latin alphabet. After graduation, he decided to remember it, but it was a long time ago, so he can't now remember it. But Stepan remembers some information about the string, namely the sequence of integers _c_1,u2009_c_2,u2009...,u2009_c__...
2,200
false
false
false
false
false
true
false
false
false
false
6,674
1295A
You have a large electronic screen which can display up to $$$998244353$$$ decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of $$$7$$$ segments which can be turned on and off to compose different digits. The following picture describes how...
900
false
true
false
false
false
false
false
false
false
false
4,223
1557B
Moamen has an array of $$$n$$$ distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once: 1. Split the array into exactly $$$k$$$ non-empty subarrays such that each element belongs to exactly one subarray. 2. Reorder these subarrays arbitrary. 3. Merg...
1,100
false
true
false
false
false
false
false
false
true
false
2,846
779C
Igor found out discounts in a shop and decided to buy _n_ items. Discounts at the store will last for a week and Igor knows about each item that its price now is _a__i_, and after a week of discounts its price will be _b__i_. Not all of sellers are honest, so now some products could be more expensive than after a week ...
1,200
false
true
false
false
false
true
false
false
true
false
6,649
595B
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly _n_ digits. Also Pasha has a number _k_ and two sequences of length _n_u2009/u2009_k_ (_n_ is divisible by _k_) _a_1,u2009_a_2,u2009...,u2009_a__n_u2009/u2009_k_ and _b_1,u2009_b_2,u20...
1,600
true
false
false
false
false
false
false
true
false
false
7,466
1975B
Mocha likes arrays, so before her departure, 378QAQ gave her an array $$$a$$$ consisting of $$$n$$$ positive integers as a gift. Mocha thinks that $$$a$$$ is beautiful if there exist two numbers $$$i$$$ and $$$j$$$ ($$$1leq i,jleq n$$$, $$$i eq j$$$) such that for all $$$k$$$ ($$$1 leq k leq n$$$), $$$a_k$$$ is divisib...
1,000
true
true
false
false
false
false
true
false
true
false
441
2008G
Sakurako has prepared a task for you: She gives you an array of $$$n$$$ integers and allows you to choose $$$i$$$ and $$$j$$$ such that $$$i eq j$$$ and $$$a_i ge a_j$$$, and then assign $$$a_i = a_i - a_j$$$ or $$$a_i = a_i + a_j$$$. You can perform this operation any number of times for any $$$i$$$ and $$$j$$$, as l...
1,800
true
true
false
false
false
false
false
true
false
false
202
1152C
Problem - 1152C - 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,800
true
false
false
false
false
false
true
false
false
false
4,954
1479A
This is an interactive problem. Homer likes arrays a lot and he wants to play a game with you. Homer has hidden from you a permutation $$$a_1, a_2, dots, a_n$$$ of integers $$$1$$$ to $$$n$$$. You are asked to find any index $$$k$$$ ($$$1 leq k leq n$$$) which is a local minimum. For an array $$$a_1, a_2, dots, a_n$$$,...
1,700
false
false
false
false
false
false
false
true
false
false
3,281
2002F2
This is the hard version of the problem. In this version, it is not guaranteed that $$$n=m$$$, and the time limit is higher. You can make hacks only if both versions of the problem are solved. In the court of the Blue King, Lelle and Flamm are having a performance match. The match consists of several rounds. In each ro...
2,800
true
false
false
true
false
false
true
false
false
false
242
1096G
All bus tickets in Berland have their numbers. A number consists of $$$n$$$ digits ($$$n$$$ is even). Only $$$k$$$ decimal digits $$$d_1, d_2, dots, d_k$$$ can be used to form ticket numbers. If $$$0$$$ is among these digits, then numbers may have leading zeroes. For example, if $$$n = 4$$$ and only digits $$$0$$$ and ...
2,400
false
false
false
true
false
false
false
false
false
false
5,225
1861D
You are given an array $$$a$$$ of length $$$n$$$, consisting of positive integers. You can perform the following operation on this array any number of times (possibly zero): choose three integers $$$l$$$, $$$r$$$ and $$$x$$$ such that $$$1 le l le r le n$$$, and multiply every $$$a_i$$$ such that $$$l le i le r$$$ by ...
1,800
false
true
false
true
false
false
false
false
false
false
1,116
1199B
Problem - 1199B - 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
false
false
false
false
false
false
false
false
false
4,702
837G
Problem - 837G - Codeforces =============== xa0 (1u2009≤u2009_i_u2009≤u2009_n_) is characterized by parameters: _x_1,u2009_x_2,u2009_y_1,u2009_a_,u2009_b_,u2009_y_2 and take values: _y_1, if _x_u2009≤u2009_x_1. _a_·_x_u2009+u2009_b_, if _x_1u2009<u2009_x_u2009≤u2009_x_2. _y_2, if _x_u2009>u2009_x_2. Th...
2,500
false
false
false
false
true
false
false
false
false
false
6,415
220E
Problem - 220E - 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
false
false
false
false
true
false
false
false
false
false
8,955
1712D
— I want people to stop gifting each other arrays. O_o and Another Young Boy An array of $$$n$$$ positive integers $$$a_1,a_2,ldots,a_n$$$ fell down on you from the skies, along with a positive integer $$$k le n$$$. You can apply the following operation at most $$$k$$$ times: Choose an index $$$1 le i le n$$$ and an i...
2,000
false
true
false
false
true
true
false
true
false
false
2,010
293D
Problem - 293D - Codeforces =============== xa0 inside or on the border of the polygon and then draws a square with two opposite vertices lying in the chosen points, what will the expectation of this square's area be? A pair of distinct points is chosen uniformly among all pairs of distinct points, locate...
2,700
true
false
false
false
false
false
false
false
false
false
8,658
1906H
You meet two new friends who are twins. The name of the elder twin is $$$A$$$, which consists of $$$N$$$ characters. While the name of the younger twin is $$$B$$$, which consists of $$$M$$$ characters. It is known that $$$N leq M$$$. You want to call each of them with a nickname. For the elder twin, you want to pick an...
2,200
false
false
false
true
false
false
false
false
false
false
870
1781G
In this problem, we will be working with rooted binary trees. A tree is called a rooted binary tree if it has a fixed root and every vertex has at most two children. Let's assign a colorxa0— white or bluexa0— to each vertex of the tree, and call this assignment a coloring of the tree. Let's call a coloring diverse if e...
3,200
false
false
false
false
false
true
false
false
false
false
1,582
457A
Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number , in particular that _q_2u2009=u2009_q_u2009+u20091, and she thinks it would make a good base for her new unique system. She called it "golden system". In golden system the n...
1,700
true
false
false
false
false
false
false
false
false
false
8,012
1846E1
This is a simple version of the problem. The only difference is that in this version $$$n le 10^6$$$. One winter morning, Rudolf was looking thoughtfully out the window, watching the falling snowflakes. He quickly noticed a certain symmetry in the configuration of the snowflakes. And like a true mathematician, Rudolf c...
1,300
true
false
true
false
false
false
true
false
false
false
1,204
1250J
The Berland Army is preparing for a large military parade. It is already decided that the soldiers participating in it will be divided into $$$k$$$ rows, and all rows will contain the same number of soldiers. Of course, not every arrangement of soldiers into $$$k$$$ rows is suitable. Heights of all soldiers in the same...
1,800
false
true
false
false
false
false
false
true
false
false
4,446
856B
Problem - 856B - Codeforces =============== xa0 . Each of the following _n_ lines contains one non-empty wordxa0— elements of _S_. All words in _S_ are different. It is guaranteed that the total length of all words in one input data doesn't exceed 106. Output For each test case print one line that contain...
2,300
false
false
false
true
false
false
false
false
false
false
6,319
1657D
Monocarp is playing a strategy game. In the game, he recruits a squad to fight monsters. Before each battle, Monocarp has $$$C$$$ coins to spend on his squad. Before each battle starts, his squad is empty. Monocarp chooses one type of units and recruits no more units of that type than he can recruit with $$$C$$$ coins....
2,000
true
true
false
false
false
false
true
true
true
false
2,342
1062D
You are given a positive integer $$$n$$$ greater or equal to $$$2$$$. For every pair of integers $$$a$$$ and $$$b$$$ ($$$2 le a, b le n$$$), you can transform $$$a$$$ into $$$b$$$ if and only if there exists an integer $$$x$$$ such that $$$1 < x$$$ and ($$$a cdot x = b$$$ or $$$b cdot x = a$$$), where $$$x$$$ denotes t...
1,800
true
false
true
false
false
false
false
false
false
true
5,399
282D
Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games! Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games. BitLGM and BitA...
2,100
false
false
false
true
false
false
false
false
false
false
8,705
1519D
Problem - 1519D - 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,600
true
false
true
true
false
false
true
false
false
false
3,066
1454D
You are given an integer $$$n$$$ ($$$n > 1$$$). Your task is to find a sequence of integers $$$a_1, a_2, ldots, a_k$$$ such that: each $$$a_i$$$ is strictly greater than $$$1$$$; $$$a_1 cdot a_2 cdot ldots cdot a_k = n$$$ (i.xa0e. the product of this sequence is $$$n$$$); $$$a_{i + 1}$$$ is divisible by $$$a_i$$$ fo...
1,300
true
false
false
false
false
true
false
false
false
false
3,405
678D
Problem - 678D - Codeforces =============== xa0 ]( "Educational Codeforces Round 13") u2009=u2009_Ax_u2009+u2009_B_. Let's define _g_(0)(_x_)u2009=u2009_x_ and _g_(_n_)(_x_)u2009=u2009_f_(_g_(_n_u2009-u20091)(_x_)) for _n_u2009>u20090. For the given integer values _A_, _B_, _n_ and _x_ find the value of _g...
1,700
true
false
false
false
false
false
false
false
false
false
7,113
78A
Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 sylla...
800
false
false
true
false
false
false
false
false
false
false
9,575
1671A
Problem - 1671A - 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 - ...
800
false
false
true
false
false
false
false
false
false
false
2,251
703E
After playing with her beautiful array, Mishka decided to learn some math. After learning how to multiply, divide and what is divisibility, she is now interested in solving the following problem. You are given integer _k_ and array _a_1,u2009_a_2,u2009...,u2009_a__n_ of _n_ integers. You are to find non-empty subsequen...
2,600
false
false
false
true
false
false
false
false
false
false
7,007
1763A
You are given an array $$$a$$$ of length $$$n$$$. You can perform the following operation several (possibly, zero) times: Choose $$$i$$$, $$$j$$$, $$$b$$$: Swap the $$$b$$$-th digit in the binary representation of $$$a_i$$$ and $$$a_j$$$. Find the maximum possible value of $$$max(a) - min(a)$$$. In a binary representa...
800
true
true
false
false
false
true
false
false
false
false
1,733
1470C
This is an interactive problem. $$$n$$$ people sitting in a circle are trying to shuffle a deck of cards. The players are numbered from $$$1$$$ to $$$n$$$, so that players $$$i$$$ and $$$i+1$$$ are neighbours (as well as players $$$1$$$ and $$$n$$$). Each of them has exactly $$$k$$$ cards, where $$$k$$$ is even. The le...
2,500
false
false
false
false
false
true
true
true
false
false
3,330
1244E
You are given a sequence $$$a_1, a_2, dots, a_n$$$ consisting of $$$n$$$ integers. You may perform the following operation on this sequence: choose any element and either increase or decrease it by one. Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you...
2,000
false
true
false
false
false
true
false
true
true
false
4,477
2018D
You are given an array $$$a_1, a_2, ldots, a_n$$$ of positive integers. You can color some elements of the array red, but there cannot be two adjacent red elements (i.e., for $$$1 leq i leq n-1$$$, at least one of $$$a_i$$$ and $$$a_{i+1}$$$ must not be red). Your score is the maximum value of a red element, plus the m...
2,200
false
true
true
true
true
false
false
false
true
false
160
648C
Statement is not available on English language Вам задано прямоугольное клетчатое поле, состоящее из _n_ строк и _m_ столбцов. Поле содержит цикл из символов «*», такой что: цикл можно обойти, посетив каждую его клетку ровно один раз, перемещаясь каждый раз вверх/вниз/вправо/влево на одну клетку; цикл не содержит сам...
1,100
false
false
false
false
false
true
false
false
false
true
7,225
1411F
According to a legend the Hanoi Temple holds a permutation of integers from $$$1$$$ to $$$n$$$. There are $$$n$$$ stones of distinct colors lying in one line in front of the temple. Monks can perform the following operation on stones: choose a position $$$i$$$ ($$$1 le i le n$$$) and cyclically shift stones at position...
3,000
true
true
false
false
false
false
false
false
false
false
3,616
24B
Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. At the conclusion of the championship the driver with most points is the cha...
1,500
false
false
true
false
false
false
false
false
false
false
9,877
780G
Andryusha has found a perplexing arcade machine. The machine is a vertically adjusted board divided into square cells. The board has _w_ columns numbered from 1 to _w_ from left to right, and _h_ rows numbered from 1 to _h_ from the bottom to the top. Further, there are barriers in some of board rows. There are _n_ bar...
2,700
false
false
false
true
true
false
false
false
false
false
6,642
1174A
Problem - 1174A - 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
false
true
false
false
false
true
false
false
true
false
4,851
725E
Alfred wants to buy a toy moose that costs _c_ dollars. The store doesn’t give change, so he must give the store exactly _c_ dollars, no more and no less. He has _n_ coins. To make _c_ dollars from his coins, he follows the following algorithm: let _S_ be the set of coins being used. _S_ is initially empty. Alfred repe...
2,600
false
true
false
false
false
false
true
false
false
false
6,903
164A
Life is not easy for the perfectly common variable named Vasya. Wherever it goes, it is either assigned a value, or simply ignored, or is being used! Vasya's life goes in states of a program. In each state, Vasya can either be used (for example, to calculate the value of another variable), or be assigned a value, or ig...
1,700
false
false
false
false
false
false
false
false
false
true
9,210
1147D
You are given a string $$$s$$$ consisting of characters "1", "0", and "?". The first character of $$$s$$$ is guaranteed to be "1". Let $$$m$$$ be the number of characters in $$$s$$$. Count the number of ways we can choose a pair of integers $$$a, b$$$ that satisfies the following: $$$1 leq a < b < 2^m$$$ When written...
2,400
false
false
false
false
false
false
false
false
false
true
4,980
1621A
You have an $$$n imes n$$$ chessboard and $$$k$$$ rooks. Rows of this chessboard are numbered by integers from $$$1$$$ to $$$n$$$ from top to bottom and columns of this chessboard are numbered by integers from $$$1$$$ to $$$n$$$ from left to right. The cell $$$(x, y)$$$ is the cell on the intersection of row $$$x$$$ a...
800
false
false
false
false
false
true
false
false
false
false
2,520
180A
In this problem you have to implement an algorithm to defragment your hard disk. The hard disk consists of a sequence of clusters, numbered by integers from 1 to _n_. The disk has _m_ recorded files, the _i_-th file occupies clusters with numbers _a__i_,u20091, _a__i_,u20092, ..., _a__i_,u2009_n__i_. These clusters are...
1,800
false
false
true
false
false
false
false
false
false
false
9,122
849A
Where do odds begin, and where do they end? Where does hope emerge, and will they ever break? Given an integer sequence _a_1,u2009_a_2,u2009...,u2009_a__n_ of length _n_. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with ...
1,000
false
false
true
false
false
false
false
false
false
false
6,353
1194B
You are given a picture consisting of $$$n$$$ rows and $$$m$$$ columns. Rows are numbered from $$$1$$$ to $$$n$$$ from the top to the bottom, columns are numbered from $$$1$$$ to $$$m$$$ from the left to the right. Each cell is painted either black or white. You think that this picture is not interesting enough. You co...
1,300
false
false
true
false
false
false
false
false
false
false
4,735
852G
Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is tape-player with a hand-written message "Play Me". He finds a tape in his own back pocket. After putting the tape in the tape-player, he sees a key hanging from a ceiling, chained to some kind of a machine, which is conn...
1,700
false
false
true
false
false
false
false
false
false
false
6,337
147B
A smile house is created to raise the mood. It has _n_ rooms. Some of the rooms are connected by doors. For each two rooms (number _i_ and _j_), which are connected by a door, Petya knows their value _c__ij_ — the value which is being added to his mood when he moves from room _i_ to room _j_. Petya wondered whether he ...
2,500
false
false
false
false
false
false
false
true
false
true
9,287
1431D
Your University has a large auditorium and today you are on duty there. There will be $$$n$$$ lectures todayxa0— all from different lecturers, and your current task is to choose in which order $$$ord$$$ they will happen. Each lecturer will use one marker to write something on a board during their lecture. Unfortunately...
1,500
false
true
false
false
false
false
false
false
false
false
3,506
844B
Problem - 844B - 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
true
false
false
false
false
false
false
false
false
false
6,385
1899E
Vlad found an array $$$a$$$ of $$$n$$$ integers and decided to sort it in non-decreasing order. To do this, Vlad can apply the following operation any number of times: Extract the first element of the array and insert it at the end; Swap that element with the previous one until it becomes the first or until it become...
1,300
false
true
true
false
false
false
false
false
true
false
918
176B
Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word _w_, let's split this word into two non-empty parts _x_ and _y_ so, that _w_u2009=u2009_xy_. A split operation is transforming word _w_u2009=u2009_xy_ into word _u_u2009=u...
1,700
false
false
false
true
false
false
false
false
false
false
9,158
435A
Problem - 435A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,000
false
false
true
false
false
false
false
false
false
false
8,102
1470D
Students of Winter Informatics School are going to live in a set of houses connected by underground passages. Teachers are also going to live in some of these houses, but they can not be accommodated randomly. For safety reasons, the following must hold: All passages between two houses will be closed, if there are no ...
2,200
false
true
false
false
false
true
false
false
false
true
3,329
54A
The Hedgehog likes to give presents to his friend, but no less he likes to receive them. Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he ch...
1,300
false
false
true
false
false
false
false
false
false
false
9,705
1914B
Monocarp is practicing for a big contest. He plans to solve $$$n$$$ problems to make sure he's prepared. Each of these problems has a difficulty level: the first problem has a difficulty level of $$$1$$$, the second problem has a difficulty level of $$$2$$$, and so on, until the last ($$$n$$$-th) problem, which has a d...
800
true
false
false
false
false
true
false
false
false
false
818
1530G
You have two strings $$$a$$$ and $$$b$$$ of equal length $$$n$$$ consisting of characters 0 and 1, and an integer $$$k$$$. You need to make strings $$$a$$$ and $$$b$$$ equal. In one step, you can choose any substring of $$$a$$$ containing exactly $$$k$$$ characters 1 (and arbitrary number of characters 0) and reverse i...
3,300
false
false
false
false
false
true
false
false
false
false
3,009
107D
Zeyad wants to commit _n_ crimes in Egypt and not be punished at the end. There are several types of crimes. For example, bribery is a crime but is not considered such when repeated twice. Therefore, bribery is not considered a crime when repeated an even number of times. Speeding is a crime, but is not considered such...
2,400
false
false
false
true
false
false
false
false
false
true
9,453
199A
Problem - 199A - 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...
900
false
false
true
false
false
true
true
false
false
false
9,046
1553B
You have a string $$$s$$$ and a chip, which you can place onto any character of this string. After placing the chip, you move it to the right several (maybe zero) times, i.xa0e. you perform the following operation several times: if the current position of the chip is $$$i$$$, you move it to the position $$$i + 1$$$. Of...
1,300
false
false
true
true
false
false
true
false
false
false
2,874
22A
Problem - 22A - 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...
800
false
false
false
false
false
false
true
false
false
false
9,888
1684F
You are given an array $$$a$$$ of $$$n$$$ integers. Also you are given $$$m$$$ subsegments of that array. The left and the right endpoints of the $$$j$$$-th segment are $$$l_j$$$ and $$$r_j$$$ respectively. You are allowed to make no more than one operation. In that operation you choose any subsegment of the array $$$a...
2,600
false
false
false
false
true
false
false
false
false
false
2,168
1949H
A newly discovered organism can be represented as a set of cells on an infinite grid. There is a coordinate system on the grid such that each cell has two integer coordinates x and y. A cell with coordinates x=a and y=b will be denoted as (a,b). Initially, the organism consists of a single cell (0,0). Then zero or more...
3,100
true
true
false
false
false
false
false
false
false
false
585
1495A
Diamond Miner is a game that is similar to Gold Miner, but there are $$$n$$$ miners instead of $$$1$$$ in this game. The mining area can be described as a plane. The $$$n$$$ miners can be regarded as $$$n$$$ points on the y-axis. There are $$$n$$$ diamond mines in the mining area. We can regard them as $$$n$$$ points o...
1,200
true
true
false
false
false
false
false
false
true
false
3,196
336B
Problem - 336B - 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,900
true
false
false
false
false
false
false
false
false
false
8,491
238A
Problem - 238A - 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
true
false
false
false
false
true
false
false
false
false
8,884
1070A
Problem - 1070A - 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,200
false
false
false
true
false
false
false
false
false
true
5,367
1227A
Your math teacher gave you the following problem: There are $$$n$$$ segments on the $$$x$$$-axis, $$$[l_1; r_1], [l_2; r_2], ldots, [l_n; r_n]$$$. The segment $$$[l; r]$$$ includes the bounds, i.e. it is a set of such $$$x$$$ that $$$l le x le r$$$. The length of the segment $$$[l; r]$$$ is equal to $$$r - l$$$. Two se...
1,100
true
false
false
false
false
false
false
false
false
false
4,544
274A
Problem - 274A - 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
false
false
false
false
false
true
true
false
8,739
1823F
You are given a tree consisting of $$$n$$$ vertices and $$$n - 1$$$ edges, and each vertex $$$v$$$ has a counter $$$c(v)$$$ assigned to it. Initially, there is a chip placed at vertex $$$s$$$ and all counters, except $$$c(s)$$$, are set to $$$0$$$; $$$c(s)$$$ is set to $$$1$$$. Your goal is to place the chip at vertex ...
2,600
true
false
false
true
false
false
false
false
false
true
1,338
251C
Little Petya likes positive integers a lot. Recently his mom has presented him a positive integer _a_. There's only one thing Petya likes more than numbers: playing with little Masha. It turned out that Masha already has a positive integer _b_. Petya decided to turn his number _a_ into the number _b_ consecutively perf...
2,000
false
true
false
true
false
false
false
false
false
false
8,829
351B
Jeff has become friends with Furik. Now these two are going to play one quite amusing game. At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of _n_ numbers: _p_1, _p_2, ..., _p__n_. Then the guys take turns to make moves, Jeff moves first. During his move, Jeff chooses t...
1,900
false
false
false
true
false
false
false
false
false
false
8,429
702B
Problem - 702B - Codeforces =============== xa0 that _a__i_u2009+u2009_a__j_ is a power of 2 (i. e. some integer _x_ exists so that _a__i_u2009+u2009_a__j_u2009=u20092_x_). Input The first line contains the single positive integer _n_ (1u2009≤u2009_n_u2009≤u2009105) — the number of integers. The second li...
1,500
true
false
true
false
true
false
true
false
false
false
7,016
1863H
There is a complete rooted binary tree, that is, a rooted tree in which each vertex has either $$$0$$$ or $$$2$$$ children. The root of the tree is vertex $$$1$$$. A node without children is called a leaf. Each leaf has a hunger value, we denote the hunger value of leaf $$$v$$$ by $$$h_v$$$. Each inner vertex of the tr...
3,500
false
false
false
true
false
false
false
false
false
false
1,099
1914E2
The easy and hard versions of this problem differ only in the constraints on the number of test cases and $$$n$$$. In the hard version, the number of test cases does not exceed $$$10^4$$$, and the sum of values of $$$n$$$ over all test cases does not exceed $$$2 cdot 10^5$$$. Furthermore, there are no additional constr...
1,400
false
true
false
false
false
false
false
false
true
false
814