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
924F
We call a positive integer _x_ a _k_-beautiful integer if and only if it is possible to split the multiset of its digits in the decimal representation into two subsets such that the difference between the sum of digits in one subset and the sum of digits in the other subset is less than or equal to _k_. Each digit shou...
3,200
false
false
false
true
false
false
false
false
false
false
6,012
794A
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes. Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line, where the _i_-th safe fr...
800
false
false
true
false
false
false
true
false
false
false
6,600
1725E
In the country of Dengkleknesia, there are $$$N$$$ factories numbered from $$$1$$$ to $$$N$$$. Factory $$$i$$$ has an electrical coefficient of $$$A_i$$$. There are also $$$N-1$$$ power lines with the $$$j$$$-th power line connecting factory $$$U_j$$$ and factory $$$V_j$$$. It can be guaranteed that each factory in Den...
2,500
true
false
false
true
true
false
false
false
false
false
1,942
706B
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in _n_ different shops in the city. It's known that the price of one bottle in the shop _i_ is equal to _x__i_ coins. Vasiliy plans to buy his favorite d...
1,100
false
false
true
true
false
false
false
true
false
false
6,998
580D
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were _n_ dishes. Kefa knows that he needs exactly _m_ dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the _i_-th dish gives him _a__i_ units of s...
1,800
false
false
false
true
false
false
false
false
false
false
7,525
638D
A super computer has been built in the Turtle Academy of Sciences. The computer consists of _n_·_m_·_k_ CPUs. The architecture was the paralellepiped of size _n_u2009×u2009_m_u2009×u2009_k_, split into 1u2009×u20091u2009×u20091 cells, each cell contains exactly one CPU. Thus, each CPU can be simultaneously identified a...
1,800
false
false
false
false
false
false
true
false
false
true
7,258
1936D
You are given two arrays $$$a$$$ and $$$b$$$ of size $$$n$$$ along with a fixed integer $$$v$$$. An interval $$$$$$. You are given $$$q$$$ queries of two types: "1 i x": assign $$$b_i := x$$$; "2 l r": find the minimum beauty among all good intervals $$$[l_0,r_0]$$$ satisfying $$$l le l_0 le r_0 le r$$$. If there is ...
3,100
false
true
false
false
true
false
false
true
false
false
665
1851F
Lisa was kidnapped by martians! It okay, because she has watched a lot of TV shows about aliens, so she knows what awaits her. Let's call integer martian if it is a non-negative integer and strictly less than $$$2^k$$$, for example, when $$$k = 12$$$, the numbers $$$51$$$, $$$1960$$$, $$$0$$$ are martian, and the numbe...
1,800
true
true
false
false
false
false
false
false
false
false
1,169
626B
Catherine has a deck of _n_ cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not necessarily adjacent) ...
1,300
true
false
false
true
false
true
false
false
false
false
7,327
1017C
Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number! The only thing Mrs. Smith remembered was that any permutation of $$$n$$$ can be a secret phone number. Only those permutations that minimize secret value might be the phone of her husband. The sequence of $$$n$$$ integers i...
1,600
false
true
false
false
false
true
false
false
false
false
5,603
251B
Little Petya likes permutations a lot. Recently his mom has presented him permutation _q_1,u2009_q_2,u2009...,u2009_q__n_ of length _n_. A permutation _a_ of length _n_ is a sequence of integers _a_1,u2009_a_2,u2009...,u2009_a__n_ (1u2009≤u2009_a__i_u2009≤u2009_n_), all integers there are distinct. There is only one th...
1,800
true
false
true
false
false
false
false
false
false
false
8,830
2014H
At such times archery was always the main sport of the day, for the Nottinghamshire yeomen were the best hand at the longbow in all merry England, but this year the Sheriff hesitated... Sheriff of Nottingham has organized a tournament in archery. It's the final round and Robin Hood is playing against Sheriff! There are...
1,900
false
true
false
false
true
false
false
false
false
false
164
2006A
Iris has a tree rooted at vertex $$$1$$$. Each vertex has a value of $$$mathtt 0$$$ or $$$mathtt 1$$$. Let's consider a leaf of the tree (the vertex $$$1$$$ is never considered a leaf) and define its weight. Construct a string formed by the values of the vertices on the path starting at the root and ending in this leaf...
1,700
false
true
false
false
false
true
false
false
false
true
217
869B
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense, and arise again from the flames and ashes of its predecessorxa0— as is known to many, the phoenix does it like this. The phoenix has a rather long lifespan, and reincarnates itself once every _a_! years. Here _a_! deno...
1,100
true
false
false
false
false
false
false
false
false
false
6,265
436A
The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. One day, Om Nom visited his friend Evan. Evan has _n_ candies of two types (fruit drops and caramel drops), the _i_-th candy hangs at the height of _h__i_ centimeters abo...
1,500
false
true
false
false
false
false
false
false
false
false
8,097
1509A
Sayaka Saeki is a member of the student council, which has $$$n$$$ other members (excluding Sayaka). The $$$i$$$-th member has a height of $$$a_i$$$ millimeters. It's the end of the school year and Sayaka wants to take a picture of all other members of the student council. Being the hard-working and perfectionist girl ...
800
false
false
false
false
false
true
false
false
false
false
3,130
118A
Problem - 118A - 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
9,416
1611G
Polycarp has a rectangular field of $$$n imes m$$$ cells (the size of the $$$n cdot m$$$ field does not exceed $$$10^6$$$ cells, $$$m ge 2$$$), in each cell of which there can be candy. There are $$$n$$$ rows and $$$m$$$ columns in the field. Let's denote a cell with coordinates $$$x$$$ vertically and $$$y$$$ horizont...
2,500
false
true
false
false
true
false
false
false
false
false
2,584
1829F
A snowflake graph is generated from two integers $$$x$$$ and $$$y$$$, both greater than $$$1$$$, as follows: Start with one central vertex. Connect $$$x$$$ new vertices to this central vertex. Connect $$$y$$$ new vertices to each of these $$$x$$$ vertices. For example, below is a snowflake graph for $$$x=5$$$ and $$...
1,300
true
false
false
false
false
false
false
false
false
true
1,309
385E
Our bear's forest has a checkered field. The checkered field is an _n_u2009×u2009_n_ table, the rows are numbered from 1 to _n_ from top to bottom, the columns are numbered from 1 to _n_ from left to right. Let's denote a cell of the field on the intersection of row _x_ and column _y_ by record (_x_,u2009_y_). Each cel...
2,300
true
false
false
false
false
false
false
false
false
false
8,287
627B
A factory produces thimbles in bulk. Typically, it can produce up to _a_ thimbles a day. However, some of the machinery is defective, so it can currently only produce _b_ thimbles each day. The factory intends to choose a _k_-day period to do maintenance and construction; it cannot produce any thimbles during this time...
1,700
false
false
false
false
true
false
false
false
false
false
7,320
68B
Problem - 68B - Codeforces =============== xa0 _k_ percent of it is lost. That is, if _x_ units were transferred from one accumulator to the other, amount of energy in the first one decreased by _x_ units and in other increased by units. Your task is to help Petya find what maximum equal amount of ene...
1,600
false
false
false
false
false
false
false
true
false
false
9,630
978A
Petya has an array $$$a$$$ consisting of $$$n$$$ integers. He wants to remove duplicate (equal) elements. Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed. Input The first line contains a single integer $$...
800
false
false
true
false
false
false
false
false
false
false
5,818
480E
Petya's been bored at work and he is killing the time by watching the parking lot at the office. The parking lot looks from above like an _n_u2009×u2009_m_ table (a cell of the table corresponds to a single parking spot). Some spots in the parking lot are taken, others are empty. Petya watches cars riding into the park...
2,800
false
false
false
false
true
false
false
false
false
false
7,910
770A
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to _n_, the password should consist onl...
800
false
false
true
false
false
false
false
false
false
false
6,702
1218I
For her birthday Alice received an interesting gift from her friends – The Light Square. The Light Square game is played on an $$$N imes N$$$ lightbulbs square board with a magical lightbulb bar of size $$$N imes 1$$$ that has magical properties. At the start of the game some lights on the square board and magical ba...
2,100
false
true
false
false
false
false
false
false
false
false
4,576
253E
Let's consider a network printer that functions like that. It starts working at time 0. In each second it can print one page of a text. At some moments of time the printer receives printing tasks. We know that a printer received _n_ tasks. Let's number the tasks by consecutive integers from 1 to _n_. Then the task numb...
2,200
false
false
true
false
true
false
false
true
true
false
8,820
1272C
Recently, Norge found a string $$$s = s_1 s_2 ldots s_n$$$ consisting of $$$n$$$ lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string $$$s$$$. Yes, all $$$frac{n (n + 1)}{2}$$$ of them! A substring of $$$s$$$ is a non-empty string $$$x = s[a ldots b] = s_{...
1,200
false
false
true
true
false
false
false
false
false
false
4,327
652E
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience. In that country there are _n_ islands and _m_ bridges between them, so you can travel from any island to any other. In the middle of some bridges are lying ancient powerful...
2,300
false
false
false
false
false
false
false
false
false
true
7,206
1213A
You are given $$$n$$$ chips on a number line. The $$$i$$$-th chip is placed at the integer coordinate $$$x_i$$$. Some chips can have equal coordinates. You can perform each of the two following types of moves any (possibly, zero) number of times on any chip: Move the chip $$$i$$$ by $$$2$$$ to the left or $$$2$$$ to t...
900
true
false
false
false
false
false
false
false
false
false
4,619
1205F
Define the beauty of a permutation of numbers from $$$1$$$ to $$$n$$$ $$$(p_1, p_2, dots, p_n)$$$ as number of pairs $$$(L, R)$$$ such that $$$1 le L le R le n$$$ and numbers $$$p_L, p_{L+1}, dots, p_R$$$ are consecutive $$$R-L+1$$$ numbers in some order. For example, the beauty of the permutation $$$(1, 2, 5, 3, 4)$$$...
3,400
true
false
false
false
false
true
false
false
false
false
4,664
1095F
You are given an undirected graph consisting of $$$n$$$ vertices. A number is written on each vertex; the number on vertex $$$i$$$ is $$$a_i$$$. Initially there are no edges in the graph. You may add some edges to this graph, but you have to pay for them. The cost of adding an edge between vertices $$$x$$$ and $$$y$$$ ...
1,900
false
true
false
false
false
false
false
false
false
true
5,232
1311D
You are given three integers $$$a le b le c$$$. In one move, you can add $$$+1$$$ or $$$-1$$$ to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. Note that you cann...
2,000
true
false
false
false
false
false
true
false
false
false
4,140
1184E3
Problem - 1184E3 - 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,400
false
false
false
false
true
false
false
false
false
true
4,781
1898A
Milica has a string $$$s$$$ of length $$$n$$$, consisting only of characters A and B. She wants to modify $$$s$$$ so it contains exactly $$$k$$$ instances of B. In one operation, she can do the following: Select an integer $$$i$$$ ($$$1 leq i leq n$$$) and a character $$$c$$$ ($$$c$$$ is equal to either A or B). Then...
800
false
false
true
false
false
false
true
false
false
false
928
798E
Mike has discovered a new way to encode permutations. If he has a permutation _P_u2009=u2009[_p_1,u2009_p_2,u2009...,u2009_p__n_], he will encode it in the following way: Denote by _A_u2009=u2009[_a_1,u2009_a_2,u2009...,u2009_a__n_] a sequence of length _n_ which will represent the code of the permutation. For each _i_...
3,000
false
false
false
false
true
true
false
false
true
true
6,577
150B
Problem - 150B - 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,600
true
false
false
false
false
false
false
false
false
true
9,275
1582F2
This is a harder version of the problem with bigger constraints. Korney Korneevich dag up an array $$$a$$$ of length $$$n$$$. Korney Korneevich has recently read about the operation elements. A sequence $$$s_1, s_2, ldots , s_m$$$ is called increasing if $$$s_1 < s_2 < ldots < s_m$$$. Input The first line contains a si...
2,400
false
true
false
true
false
false
true
true
false
false
2,719
1329D
Dreamoon likes strings. Today he created a game about strings: String $$$s_1, s_2, ldots, s_n$$$ is beautiful if and only if for each $$$1 le i < n, s_i e s_{i+1}$$$. Initially, Dreamoon has a string $$$a$$$. In each step Dreamoon can choose a beautiful substring of $$$a$$$ and remove it. Then he should concatenate th...
3,100
false
false
false
false
true
true
false
false
false
false
4,062
1566G
You are given an undirected weighted graph, consisting of $$$n$$$ vertices and $$$m$$$ edges. Some queries happen with this graph: Delete an existing edge from the graph. Add a non-existing edge to the graph. At the beginning and after each query, you should find four different vertices $$$a$$$, $$$b$$$, $$$c$$$, $$$...
3,100
false
true
true
false
true
true
false
false
false
true
2,806
519E
A and B are preparing themselves for programming contests. The University where A and B study is a set of rooms connected by corridors. Overall, the University has _n_ rooms connected by _n_u2009-u20091 corridors so that you can get from any room to any other one by moving along the corridors. The rooms are numbered fr...
2,100
false
false
false
true
true
false
false
true
false
false
7,758
1624F
This problem is interactive. We decided to play a game with you and guess the number $$$x$$$ ($$$1 le x < n$$$), where you know the number $$$n$$$. You can make queries like this: + c: this command assigns $$$x = x + c$$$ ($$$1 le c < n$$$) and then returns you the value $$$lfloorfrac{x}{n} floor$$$ ($$$x$$$ divide by...
2,000
false
false
false
false
false
true
false
true
false
false
2,495
618G
Your friend recently gave you some slimes for your birthday. You have a very large amount of slimes with value 1 and 2, and you decide to invent a game using these slimes. You initialize a row with _n_ empty spaces. You also choose a number _p_ to be used in the game. Then, you will perform the following steps while th...
3,300
true
false
false
true
false
false
false
false
false
false
7,358
1539A
There are $$$n$$$ people participating in some contest, they start participating in $$$x$$$ minutes intervals. That means the first participant starts at time $$$0$$$, the second participant starts at time $$$x$$$, the thirdxa0— at time $$$2 cdot x$$$, and so on. Duration of contest is $$$t$$$ minutes for each particip...
1,000
true
true
false
false
false
false
false
false
false
false
2,948
1108C
You have a garland consisting of $$$n$$$ lamps. Each lamp is colored red, green or blue. The color of the $$$i$$$-th lamp is $$$s_i$$$ ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that th...
1,300
true
true
false
false
false
false
true
false
false
false
5,160
377B
Soon there will be held the world's largest programming contest, but the testing system still has _m_ bugs. The contest organizer, a well-known university, has no choice but to attract university students to fix all the bugs. The university has _n_ students able to perform such work. The students realize that they are ...
1,900
false
true
false
false
true
false
false
true
true
false
8,323
77A
The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us ...
1,400
false
false
true
false
false
false
true
false
false
false
9,580
1935B
In the Master's Assistance Center, Nyam-Nyam was given a homework assignment in informatics. There is an array $$$a$$$ of length $$$n$$$, and you want to divide it into $$$k > 1$$$ subsegments$$$^{dagger}$$$ in such a way that the $$$operatorname{MEX} ^{ddagger}$$$ on each subsegment is equal to the same integer. Help ...
1,200
false
false
false
false
false
true
false
false
false
false
673
519B
A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed _n_ compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix s...
1,100
false
false
true
false
true
false
false
false
true
false
7,761
1580A
CQXYM found a rectangle $$$A$$$ of size $$$n imes m$$$. There are $$$n$$$ rows and $$$m$$$ columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation. A rectangle $$$M$$$ size of $$$a imes b...
1,700
false
true
true
true
true
false
true
false
false
false
2,733
372C
A festival will be held in a town's main street. There are _n_ sections in the main street. The sections are numbered 1 through _n_ from left to right. The distance between each adjacent sections is 1. In the festival _m_ fireworks will be launched. The _i_-th (1u2009≤u2009_i_u2009≤u2009_m_) launching is on time _t__i_...
2,100
true
false
false
true
true
false
false
false
false
false
8,341
1423J
Problem - 1423J - Codeforces =============== xa0 ]( "Mirror of Bubble Cup 13 Finals on Codeforces") =m$$$? Help Jerry Mao solve the long standing problem! Input The first line contains a single integer $$$t$$$ $$$(1 leq t leq 5cdot 10^5)$$$ - number of test cases. On next line there are $$$t$$$ numbers, $$...
2,400
true
false
false
true
false
true
false
false
false
false
3,554
175C
Vasya plays the Geometry Horse. The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value. There are _n_ types of geometric figures. The number of figures of type _k__i_ and figure cost _c__i_...
1,600
false
true
true
false
false
false
false
false
true
false
9,163
1746C
You are given a permutation $$$a$$$ of size $$$n$$$ and you should perform $$$n$$$ operations on it. In the $$$i$$$-th operation, you can choose a non-empty suffix of $$$a$$$ and increase all of its elements by $$$i$$$. How can we perform the operations to minimize the number of inversions in the final array? Note that...
1,300
true
true
true
false
false
true
false
false
false
false
1,808
241F
The Old City is a rectangular city represented as an _m_u2009×u2009_n_ grid of blocks. This city contains many buildings, straight two-way streets and junctions. Each junction and each building is exactly one block. All the streets have width of one block and are either vertical or horizontal. There is a junction on bo...
2,300
false
false
true
false
false
false
true
false
false
false
8,870
126E
Doctor prescribed medicine to his patient. The medicine is represented by pills. Each pill consists of a shell and healing powder. The shell consists of two halves; each half has one of four colors — blue, red, white or yellow. The doctor wants to put 28 pills in a rectangular box 7u2009×u20098 in size. Besides, each p...
2,900
false
false
false
false
false
false
true
false
false
false
9,373
1781A
Vika's house has a room in a shape of a rectangular parallelepiped (also known as a rectangular cuboid). Its floor is a rectangle of size $$$w imes d$$$, and the ceiling is right above at the constant height of $$$h$$$. Let's introduce a coordinate system on the floor so that its corners are at points $$$(0, 0)$$$, $$...
800
true
false
false
false
false
false
false
false
false
false
1,588
9E
Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to any other cycles. A f...
2,300
false
false
false
false
false
false
false
false
false
true
9,946
1151F
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her. Given an array $$$a$$$ of length $$$n$$$, consisting only of the numbers $$$0$$$ and $$$1$$$, and the number $$$k$$$. Exactly $$$k$$$ times the followi...
2,300
false
false
false
true
false
false
false
false
false
false
4,957
1906E
You are currently researching the Merge Sort algorithm. Merge Sort is a sorting algorithm that is based on the principle of Divide and Conquer. It works by dividing an array into two subarrays of equal length, sorting each subarrays, then merging the sorted subarrays back together to form the final sorted array. You ar...
1,900
false
false
false
true
false
true
false
false
false
false
873
894E
Ralph is going to collect mushrooms in the Mushroom Forest. There are _m_ directed paths connecting _n_ trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the mushrooms on the path. The Mushroom Forest has a magical fertile ground where mushrooms grow at a fantasti...
2,100
false
false
false
true
false
false
false
false
false
true
6,171
855F
Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an attack on Hogwarts school. Hogwarts' entrance can be imagined as a straight line (x-axis) from 1 to 105. Nagini is launching various snakes at the Hogwarts entrance. Each snake lands pa...
3,100
false
false
false
false
true
false
false
true
false
false
6,322
1868D
A pseudotree is a connected graph which has exactly one cycle and no self-loops. Note that a pseudotree may contain multiple-edges. It can be shown that a pseudotree with $$$n$$$ vertices always contains $$$n$$$ edges. After deleting all edges on the cycle in the pseudotree, a forest$$$^{dagger}$$$ will be formed. It c...
3,000
false
true
true
false
false
true
false
false
false
true
1,064
630G
Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting ...
1,600
true
false
false
false
false
false
false
false
false
false
7,298
486A
u2009=u2009u2009-u20091u2009+u20092u2009-u20093u2009+u2009..u2009+u2009(u2009-u20091)_n__n_ Your task is to calculate _f_(_n_) for a given integer _n_. Input The single line contains the positive integer _n_ (1u2009≤u2009_n_u2009≤u20091015). Output Print _f_(_n_) in a single line. Note _f_(4)u2009=u2009u2009-u20091u200...
800
true
false
true
false
false
false
false
false
false
false
7,895
1000B
Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $$$0$$$ and turn power off at moment $$$M$$$. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unf...
1,500
false
true
false
false
false
false
false
false
false
false
5,704
1388A
Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task. Recently, out of blue Captain Flint has been interested in mat...
800
true
true
false
false
false
false
true
false
false
false
3,733
1178G
You are given a rooted tree on $$$n$$$ vertices. The vertices are numbered from $$$1$$$ to $$$n$$$; the root is the vertex number $$$1$$$. Each vertex has two integers associated with it: $$$a_i$$$ and $$$b_i$$$. We denote the set of all ancestors of $$$v$$$ (including $$$v$$$ itself) by $$$R(v)$$$. The awesomeness of ...
3,000
false
false
false
false
true
false
false
false
false
false
4,823
191E
It is dark times in Berland. Berlyand opposition, funded from a neighboring state, has organized a demonstration in Berland capital Bertown. Through the work of intelligence we know that the demonstrations are planned to last for _k_ days. Fortunately, Berland has a special police unit, which can save the country. It h...
2,200
false
false
false
false
true
false
false
true
false
false
9,073
2003E2
This is a hard version of this problem. The differences between the versions are the constraint on $$$m$$$ and $$$r_i < l_{i + 1}$$$ holds for each $$$i$$$ from $$$1$$$ to $$$m - 1$$$ in the easy version. You can make hacks only if both versions of the problem are solved. Turtle gives you $$$m$$$ intervals $$$[l_1, r_1...
2,700
true
true
false
true
true
false
true
false
false
false
233
1167B
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You m...
1,400
true
false
false
false
false
false
true
false
false
false
4,882
1818A
In a debate club with $$$n$$$ members, including yourself (member $$$1$$$), there are $$$k$$$ opinions to be discussed in sequence. During each discussion, members express their agreement or disagreement with the opinion. Let's define $$$Y$$$ as the number of members who agree and $$$N$$$ as the number of members who d...
800
false
true
true
false
false
false
false
false
false
false
1,367
1466A
Argus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for Io. There are $$$n$$$ trees growing along the river, where Argus tends Io. For this problem, the riv...
800
true
false
false
false
false
false
true
false
false
false
3,366
1572B
You are given a sequence $$$a$$$ of length $$$n$$$ consisting of $$$0$$$s and $$$1$$$s. You can perform the following operation on this sequence: Pick an index $$$i$$$ from $$$1$$$ to $$$n-2$$$ (inclusive). Change all of $$$a_{i}$$$, $$$a_{i+1}$$$, $$$a_{i+2}$$$ to $$$a_{i} oplus a_{i+1} oplus a_{i+2}$$$ simultaneous...
2,500
false
true
false
false
false
true
true
false
false
false
2,781
1368B
# Codeforces Subsequences Input file: standard input Output file: standard output Time limit: 2 seconds Memory limit: 512 megabytes Karl likes Codeforces and subsequences. He wants to find a string of lowercase English letters that contains at least k subsequences codeforces . Out of all possible strings, Karl wants...
1,500
true
true
false
false
false
true
true
false
false
false
3,835
2036F
Alice has been giving gifts to Bob for many years, and she knows that what he enjoys the most is performing $$$. Therefore, this year for his birthday, she gifted him a super-powerful "XORificator 3000", the latest model. Bob was very pleased with the gift, as it allowed him to instantly compute the XOR of all interest...
1,900
false
false
false
true
false
false
false
false
false
false
47
982B
In the Bus of Characters there are $$$n$$$ rows of seat, each having $$$2$$$ seats. The width of both seats in the $$$i$$$-th row is $$$w_i$$$ centimeters. All integers $$$w_i$$$ are distinct. Initially the bus is empty. On each of $$$2n$$$ stops one passenger enters the bus. There are two types of passengers: an intr...
1,300
false
true
true
false
true
false
false
false
false
false
5,791
1332F
Eric is the teacher of graph theory class. Today, Eric teaches independent set and edge-induced subgraph. Given a graph $$$G=(V,E)$$$, an independent set is a subset of vertices $$$V' subset V$$$ such that for every pair $$$u,v in V'$$$, $$$(u,v) ot in E$$$ (i.e. no edge in $$$E$$$ connects two vertices from $$$V'$$$)...
2,500
false
false
false
true
false
false
false
false
false
false
4,045
1374C
You are given a bracket sequence $$$s$$$ of length $$$n$$$, where $$$n$$$ is even (divisible by two). The string $$$s$$$ consists of $$$frac{n}{2}$$$ opening brackets '(' and $$$frac{n}{2}$$$ closing brackets ')'. In one move, you can choose exactly one bracket and move it to the beginning of the string or to the end o...
1,000
false
true
false
false
false
false
false
false
false
false
3,792
492C
Vanya wants to pass _n_ exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least _avg_. The exam grade cannot exceed _r_. Vanya has passed the exams and got grade _a__i_ for the _i_-th exam. To increase the grade for the _i_-th exam by 1 point, Vanya mu...
1,400
false
true
false
false
false
false
false
false
true
false
7,866
1779E
This is an interactive problem. Anya has gathered $$$n$$$ chess experts numbered from $$$1$$$ to $$$n$$$ for which the following properties hold: For any pair of players one of the players wins every game against the other (and no draws ever occur); Transitivity does not necessarily holdxa0— it might happen that $$$A...
2,400
false
true
false
false
false
true
false
false
true
true
1,598
1165B
Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly $$$1$$$ problem, during the second day — exactly $$$2$$$ problems, during the third day — exactly $$$3$$$ problems, and so on. During the $$$k$$$-th day he should solve $$$k$$$ problems. Polycarp...
1,000
false
true
false
false
true
false
false
false
true
false
4,895
36C
Problem - 36C - Codeforces =============== xa0 and Codeforces Beta Round #36") ") ") ") ") ") . You will be given the order in which Petya washes the bowls. Determine the height of the construction, i.e. the distance from the bottom of the lowest bowl to the top of the highest one. Inp...
2,200
false
false
true
false
false
false
false
false
false
false
9,816
1402B
The government of Treeland wants to build a new road network. There are $$$2N$$$ cities in Treeland. The unfinished plan of the road network already contains $$$N$$$ road segments, each of which connects two cities with a straight line. No two road segments have a common point (including their endpoints). Your task is ...
2,900
false
false
false
false
false
false
false
false
true
false
3,658
1714D
You are given some text $$$t$$$ and a set of $$$n$$$ strings $$$s_1, s_2, dots, s_n$$$. In one step, you can choose any occurrence of any string $$$s_i$$$ in the text $$$t$$$ and color the corresponding characters of the text in red. For example, if $$$t= exttt{bababa}$$$ and $$$s_1= exttt{ba}$$$, $$$s_2= exttt{aba}$$$...
1,600
false
true
false
true
true
false
true
false
false
false
1,997
144E
The secondary diagonal of a square matrix is a diagonal going from the top right to the bottom left corner. Let's define an _n_-degree staircase as a square matrix _n_u2009×u2009_n_ containing no squares above the secondary diagonal (the picture below shows a 5-degree staircase). The squares of the _n_-degree staircase...
2,200
false
true
false
false
true
false
false
false
false
false
9,296
1703C
Luca has a cypher made up of a sequence of $$$n$$$ wheels, each with a digit $$$a_i$$$ written on it. On the $$$i$$$-th wheel, he made $$$b_i$$$ moves. Each move is one of two types: up move (denoted by $$$ exttt{U}$$$): it increases the $$$i$$$-th digit by $$$1$$$. After applying the up move on $$$9$$$, it becomes $$...
800
false
false
true
false
false
false
true
false
false
false
2,060
28E
How horrible! The empire of galactic chickens tries to conquer a beautiful city "Z", they have built a huge incubator that produces millions of chicken soldiers a day, and fenced it around. The huge incubator looks like a polygon on the plane _Oxy_ with _n_ vertices. Naturally, DravDe can't keep still, he wants to dest...
2,800
true
false
false
false
false
false
false
false
false
false
9,854
1779C
Baltic, a famous chess player who is also a mathematician, has an array $$$a_1,a_2, ldots, a_n$$$, and he can perform the following operation several (possibly $$$0$$$) times: Choose some index $$$i$$$ ($$$1 leq i leq n$$$); multiply $$$a_i$$$ with $$$-1$$$, that is, set $$$a_i := -a_i$$$. Baltic's favorite number is...
1,600
false
true
false
false
true
false
false
false
false
false
1,600
1927A
You have a horizontal strip of $$$n$$$ cells. Each cell is either white or black. You can choose a continuous segment of cells once and paint them all white. After this action, all the black cells in this segment will become white, and the white ones will remain white. What is the minimum length of the segment that nee...
800
false
true
false
false
false
false
false
false
false
false
730
278A
The circle line of the Berland subway has _n_ stations. We know the distances between all pairs of neighboring stations: _d_1 is the distance between the 1-st and the 2-nd station; _d_2 is the distance between the 2-nd and the 3-rd station;... _d__n_u2009-u20091 is the distance between the _n_u2009-u20091-th and t...
800
false
false
true
false
false
false
false
false
false
false
8,722
865D
Problem - 865D - 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
true
false
false
true
true
false
false
false
false
6,278
1887E
Alice suggested Bob to play a game. Bob didn't like this idea, but he couldn't refuse Alice, so he asked you to write a program that would play instead of him. The game starts with Alice taking out a grid sheet of size $$$n imes n$$$, the cells of which are initially not colored. After that she colors some $$$2n$$$ ce...
3,100
false
false
false
false
false
true
false
true
false
true
968
1045E
On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti...
3,200
false
false
false
false
false
true
false
false
false
false
5,466
1559D2
This is the hard version of the problem. The only difference between the two versions is the constraint on $$$n$$$. You can make hacks only if all versions of the problem are solved. A forest is an undirected graph without cycles (not necessarily connected). Mocha and Diana are friends in Zhijiang, both of them have a ...
2,500
false
true
false
false
false
true
true
false
false
true
2,832
1455G
Polycarp is editing a complicated computer program. First, variable $$$x$$$ is declared and assigned to $$$0$$$. Then there are instructions of two types: 1. set $$$y$$$ $$$v$$$xa0— assign $$$x$$$ a value $$$y$$$ or spend $$$v$$$ burles to remove that instruction (thus, not reassign $$$x$$$); 2. if $$$y$$$ $$$dots$$$ e...
2,900
false
false
false
true
true
false
false
false
false
false
3,396
1516A
Given an array $$$a$$$ of length $$$n$$$, you can do at most $$$k$$$ operations of the following type on it: choose $$$2$$$ different elements in the array, add $$$1$$$ to the first, and subtract $$$1$$$ from the second. However, all the elements of $$$a$$$ have to remain non-negative after this operation. What is lex...
800
false
true
false
false
false
false
false
false
false
false
3,082
1571G
A squad of $$$n$$$ warriors is defending a castle from a dragon attack. There are $$$m$$$ barricades between the castle and the dragon. The warriors are numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th warrior knows $$$k_i$$$ attacks: the $$$j$$$-th of them deals $$$a_{i,j}$$$ damage to the dragon and can only be appli...
2,500
false
false
false
true
true
false
false
false
false
false
2,786
1082G
Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of $$$n$$$ vertices and $$$m$$$ edges. The weight of the $$$i$$$-th vertex is $$$a_i$$$. The weight of the $$$i$$$-th edge is $$$w_i$$$. A subgraph of a graph is some set of the graph vertices and some set of the graph edges. The set...
2,400
false
false
false
false
false
false
false
false
false
true
5,309
1091B
Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $$$T$$$, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at $$$n$$$ obelisks. These clues were in an ancient language, and he has only decrypted ...
1,200
false
true
true
false
false
true
true
false
false
false
5,258