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
475C
Problem - 475C - Codeforces =============== xa0 ]( "Bayan Contest Warm Up round + 50 tshirts!") . Then the brush is moved several times. Each time the brush is moved one unit right or down. The brush has been strictly inside the frame during the painting. The brush alters every cell it has covered at s...
2,100
false
true
false
false
false
true
true
false
false
false
7,932
386B
Everyone loves a freebie. Especially students. It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcoming exam. In the night before the exam on mathematical analysis _n_ ...
1,400
false
false
true
false
false
false
true
true
false
false
8,285
1372E
Omkar is building a house. He wants to decide how to make the floor plan for the last floor. Omkar's floor starts out as $$$n$$$ rows of $$$m$$$ zeros ($$$1 le n,m le 100$$$). Every row is divided into intervals such that every $$$0$$$ in the row is in exactly $$$1$$$ interval. For every interval for every row, Omkar c...
2,900
false
true
false
true
false
false
false
false
false
false
3,803
1817C
A polynomial $$$A(x)$$$ of degree $$$d$$$ is an expression of the form $$$A(x) = a_0 + a_1 x + a_2 x^2 + dots + a_d x^d$$$, where $$$a_i$$$ are integers, and $$$a_d eq 0$$$. Two polynomials $$$A(x)$$$ and $$$B(x)$$$ are called similar if there is an integer $$$s$$$ such that for any integer $$$x$$$ it holds that $$$$$...
2,400
true
false
false
false
false
false
false
false
false
false
1,371
665A
Buses run between the cities _A_ and _B_, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city _A_ departs every _a_ minutes and arrives to the city _B_ in a _t__a_ minutes, and a bus from the city _B_ departs every _b_ minutes and arrives to the city _A_ in a _t__b_ min...
1,600
false
false
true
false
false
false
false
false
false
false
7,161
1721B
The robot is placed in the top left corner of a grid, consisting of $$$n$$$ rows and $$$m$$$ columns, in a cell $$$(1, 1)$$$. In one step, it can move into a cell, adjacent by a side to the current one: $$$(x, y) ightarrow (x, y + 1)$$$; $$$(x, y) ightarrow (x + 1, y)$$$; $$$(x, y) ightarrow (x, y - 1)$$$; $$$(x...
1,000
false
false
true
false
false
false
false
false
false
false
1,958
1004D
Since Sonya has just learned the basics of matrices, she decided to play with them a little bit. Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The cells with equal numbers h...
2,300
false
false
true
false
false
true
true
false
false
false
5,665
1337A
Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears. These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now she...
800
true
false
false
false
false
true
false
false
false
false
4,016
1430D
You have a string $$$s$$$ consisting of $$$n$$$ characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer $$$i$$$ from $$$1$$$ to the length of the string $$$s$$$, then delete the character $$$s_i$$$ (the string length gets reduced ...
1,700
false
true
false
false
true
false
false
true
false
false
3,513
1780F
One day Kira found $$$n$$$ friends from Morioh and decided to gather them around a table to have a peaceful conversation. The height of friend $$$i$$$ is equal to $$$a_i$$$. It so happened that the height of each of the friends is unique. Unfortunately, there were only $$$3$$$ chairs in Kira's house, and obviously, it ...
2,300
false
false
false
true
true
false
true
false
true
false
1,590
269A
Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes. From the top view each magical box looks like a square with side length equal to 2_k_ (_k_ is an integer, _k_u2009≥u20090) units. A magical box _v_ can ...
1,600
true
true
false
false
false
false
false
false
false
false
8,758
1696E
We say an infinite sequence $$$a_{0}, a_{1}, a_2, ldots$$$ is non-increasing if and only if for all $$$ige 0$$$, $$$a_i ge a_{i+1}$$$. There is an infinite right and down grid. The upper-left cell has coordinates $$$(0,0)$$$. Rows are numbered $$$0$$$ to infinity from top to bottom, columns are numbered from $$$0$$$ to...
2,000
true
false
false
false
false
false
false
false
false
false
2,104
1928A
Bob has a rectangle of size $$$a imes b$$$. He tries to cut this rectangle into two rectangles with integer sides by making a cut parallel to one of the sides of the original rectangle. Then Bob tries to form some other rectangle from the two resulting rectangles, and he can rotate and move these two rectangles as he ...
800
true
false
false
false
false
false
false
false
false
false
723
1341A
Nastya just made a huge mistake and dropped a whole package of rice on the floor. Mom will come soon. If she sees this, then Nastya will be punished. In total, Nastya dropped $$$n$$$ grains. Nastya read that each grain weighs some integer number of grams from $$$a - b$$$ to $$$a + b$$$, inclusive (numbers $$$a$$$ and $...
900
true
false
false
false
false
false
false
false
false
false
4,001
1189B
You are given $$$n$$$ numbers $$$a_1, a_2, ldots, a_n$$$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors? For example, for the array $$$[1, 4, 5, 6, 7, 8]$$$, the arrangement on the left is valid, while arrangement on the right is not, as $$$5ge...
1,100
true
true
false
false
false
false
false
false
true
false
4,752
923D
Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: Note that a substring is one or more consecutive characters. For given queries, determine whether it is possible to obtain the target string from source. I...
2,500
false
false
true
false
false
true
false
false
false
false
6,020
914E
You are given a tree (a connected acyclic undirected graph) of _n_ vertices. Vertices are numbered from 1 to _n_ and each vertex is assigned a character from a to t. A path in the tree is said to be palindromic if at least one permutation of the labels in the path is a palindrome. For each vertex, output the number of ...
2,400
false
false
false
false
true
false
false
false
false
false
6,079
39F
Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much. One can get to the shore only by hills that are situated along a straight line that connects the little island with the shore. Let us assume that the hills are numbered from 1 to _n...
1,300
false
false
true
false
false
false
false
false
false
false
9,795
403D
The sequence of integer pairs (_a_1,u2009_b_1),u2009(_a_2,u2009_b_2),u2009...,u2009(_a__k_,u2009_b__k_) is beautiful, if the following statements are fulfilled: 1u2009≤u2009_a_1u2009≤u2009_b_1u2009<u2009_a_2u2009≤u2009_b_2u2009<u2009...u2009<u2009_a__k_u2009≤u2009_b__k_u2009≤u2009_n_, where _n_ is a given positive int...
2,300
false
false
false
true
false
false
false
false
false
false
8,212
845E
The capital of Berland looks like a rectangle of size _n_u2009×u2009_m_ of the square blocks of same size. Fire! It is known that _k_u2009+u20091 blocks got caught on fire (_k_u2009+u20091u2009≤u2009_n_·_m_). Those blocks are centers of ignition. Moreover positions of _k_ of these centers are known and one of these sta...
2,400
false
false
false
false
true
false
false
true
false
false
6,380
615C
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art. First, he wants to construct the running track with coating _t_. On planet AMI-1511 the coating of the tr...
2,000
false
true
false
true
false
false
false
false
false
false
7,378
1814B
A robot is placed in a cell $$$(0, 0)$$$ of an infinite grid. This robot has adjustable length legs. Initially, its legs have length $$$1$$$. Let the robot currently be in the cell $$$(x, y)$$$ and have legs of length $$$m$$$. In one move, it can perform one of the following three actions: jump into the cell $$$(x + m...
1,700
true
false
false
false
false
false
true
false
false
false
1,386
444E
DZY loves planting, and he enjoys solving tree problems. DZY has a weighted tree (connected undirected graph without cycles) containing _n_ nodes (they are numbered from 1 to _n_). He defines the function _g_(_x_,u2009_y_) (1u2009≤u2009_x_,u2009_y_u2009≤u2009_n_) as the longest edge in the shortest path between nodes _...
2,700
false
false
false
false
false
false
false
true
false
false
8,059
912A
During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals. Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow c...
800
false
false
true
false
false
false
false
false
false
false
6,096
1758D
You are given an integer $$$n$$$. Find a sequence of $$$n$$$ distinct integers $$$a_1, a_2, dots, a_n$$$ such that $$$1 leq a_i leq 10^9$$$ for all $$$i$$$ and $$$$$$max(a_1, a_2, dots, a_n) - min(a_1, a_2, dots, a_n)= sqrt{a_1 + a_2 + dots + a_n}.$$$$$$ It can be proven that there exists a sequence of distinct integer...
1,800
true
false
false
false
false
true
true
true
false
false
1,765
946E
Problem - 946E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,200
false
true
true
false
false
false
false
false
false
false
5,928
1366A
Problem - 1366A - 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,100
true
true
false
false
false
false
false
true
false
false
3,850
1555C
Alice and Bob are playing a game on a matrix, consisting of $$$2$$$ rows and $$$m$$$ columns. The cell in the $$$i$$$-th row in the $$$j$$$-th column contains $$$a_{i, j}$$$ coins in it. Initially, both Alice and Bob are standing in a cell $$$(1, 1)$$$. They are going to perform a sequence of moves to reach a cell $$$(...
1,300
false
false
true
true
false
true
true
false
false
false
2,859
833A
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. The game consists of multiple rounds. Its rules are very simple: in each round, a natural number _k_ is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is ...
1,700
true
false
false
false
false
false
false
false
false
false
6,434
1466G
Whoso in ignorance draws near to them and hears the Sirens' voice, he nevermore returns. Homer, Odyssey In the times of Jason and the Argonauts, it was well known that sirens use the sound of their songs to lure sailors into their demise. Yet only a few knew that every time sirens call a sailor by his name, his will we...
2,600
true
false
false
false
false
false
false
false
false
false
3,360
637C
During a New Year special offer the "Sudislavl Bars" offered _n_ promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ. As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as...
1,400
false
false
true
false
false
true
true
false
false
false
7,263
1858D
The teachers of the Summer Informatics School decided to plant $$$n$$$ trees in a row, and it was decided to plant only oaks and firs. To do this, they made a plan, which can be represented as a binary string $$$s$$$ of length $$$n$$$. If $$$s_i = 0$$$, then the $$$i$$$-th tree in the row should be an oak, and if $$$s_...
2,200
false
true
false
true
true
false
true
false
false
false
1,134
1144D
You are given an array $$$a$$$ consisting of $$$n$$$ integers. You can perform the following operations arbitrary number of times (possibly, zero): 1. Choose a pair of indices $$$(i, j)$$$ such that $$$i-j=1$$$ (indices $$$i$$$ and $$$j$$$ are adjacent) and set $$$a_i := a_i + a_i - a_j$$$; 2. Choose a pair of indices ...
1,400
false
true
false
false
false
true
false
false
false
false
5,002
1446C
For a given sequence of distinct non-negative integers $$$(b_1, b_2, dots, b_k)$$$ we determine if it is good in the following way: Consider a graph on $$$k$$$ nodes, with numbers from $$$b_1$$$ to $$$b_k$$$ written on them. For every $$$i$$$ from $$$1$$$ to $$$k$$$: find such $$$j$$$ ($$$1 le j le k$$$, $$$j eq i$$$...
2,100
false
false
false
true
true
false
false
true
false
false
3,445
1750F
Everyone was happy coding, until suddenly a power shortage happened and the best competitive programming site went down. Fortunately, a system administrator bought some new equipment recently, including some UPSs. Thus there are some servers that are still online, but we need all of them to be working in order to keep ...
2,700
true
false
false
true
false
false
false
false
false
false
1,780
584E
Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them obtain the required permutation by paying as little money as possible. More formally, we have two permutations, _p_ and _s_ of numbers from 1 to _n_. We can swap _p__i_ and _...
2,300
true
true
false
false
false
true
false
false
false
false
7,506
723F
You are given an undirected connected graph consisting of _n_ vertices and _m_ edges. There are no loops and no multiple edges in the graph. You are also given two distinct vertices _s_ and _t_, and two values _d__s_ and _d__t_. Your task is to build any spanning tree of the given graph (note that the graph is not weig...
2,300
false
true
true
false
false
false
false
false
false
true
6,915
381A
Sereja and Dima play a game. The rules of the game are very simple. The players have _n_ cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. Th...
800
false
true
true
false
false
false
false
false
false
false
8,305
1738B
Suppose $$$a_1, a_2, dots, a_n$$$ is a sorted integer sequence of length $$$n$$$ such that $$$a_1 leq a_2 leq dots leq a_n$$$. For every $$$1 leq i leq n$$$, the prefix sum $$$s_i$$$ of the first $$$i$$$ terms $$$a_1, a_2, dots, a_i$$$ is defined by $$$$$$ s_i = sum_{k=1}^i a_k = a_1 + a_2 + dots + a_i. $$$$$$ Now you ...
1,200
true
true
false
false
false
true
false
false
true
false
1,860
804D
Pasha is a good student and one of MoJaK's best friends. He always have a problem to think about. Today they had a talk about the following problem. We have a forest (acyclic undirected graph) with _n_ vertices and _m_ edges. There are _q_ queries we should answer. In each query two vertices _v_ and _u_ are given. Let ...
2,500
false
false
false
true
false
false
true
true
true
false
6,542
1032C
Little Paul wants to learn how to play piano. He already has a melody he wants to start with. For simplicity he represented this melody as a sequence $$$a_1, a_2, ldots, a_n$$$ of key numbers: the more a number is, the closer it is to the right end of the piano keyboard. Paul is very clever and knows that the essential...
1,700
false
false
false
true
false
true
false
false
false
false
5,540
68D
Recently Petya has become keen on physics. Anna V., his teacher noticed Petya's interest and gave him a fascinating physical puzzle — a half-decay tree. A half-decay tree is a complete binary tree with the height _h_. The height of a tree is the length of the path (in edges) from the root to a leaf in the tree. While s...
2,500
true
false
false
true
true
false
false
false
false
false
9,628
440C
. Output Print expected minimal number of digits 1.
1,800
false
false
false
false
false
false
true
false
false
false
8,077
1537E2
This is the hard version of the problem. The only difference is the constraints on $$$n$$$ and $$$k$$$. You can make hacks only if all versions of the problem are solved. You have a string $$$s$$$, and you can do two types of operations on it: Delete the last character of the string. Duplicate the string: $$$s:=s+s$$...
2,200
false
true
false
false
true
false
false
true
false
false
2,957
1896D
You are given a $$$1$$$-indexed array $$$a$$$ of length $$$n$$$ where each element is $$$1$$$ or $$$2$$$. Process $$$q$$$ queries of the following two types: "1 s": check if there exists a subarray$$$^{dagger}$$$ of $$$a$$$ whose sum equals to $$$s$$$. "2 i v": change $$$a_i$$$ to $$$v$$$. $$$^{dagger}$$$ An array $$...
1,700
true
false
false
false
true
false
false
true
false
false
934
305B
Problem - 305B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,700
true
false
true
false
false
false
true
false
false
false
8,615
1783C
You are participating in Yet Another Tournament. There are $$$n + 1$$$ participants: you and $$$n$$$ other opponents, numbered from $$$1$$$ to $$$n$$$. Each two participants will play against each other exactly once. If the opponent $$$i$$$ plays against the opponent $$$j$$$, he wins if and only if $$$i > j$$$. When th...
1,700
false
true
false
false
false
false
false
true
true
false
1,577
545B
Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance: We will define the distance between two strings _s_ and _t_ of the same length consisting of digits zero and one as the ...
1,100
false
true
false
false
false
false
false
false
false
false
7,661
342D
Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles. A puzzle is a 3u2009×u2009_n_ table with forbidden cells (black squares) containing dominoes (colored rectangles on the picture). A puzzle is called correct if it meets...
2,100
false
false
false
true
false
false
false
false
false
false
8,465
815B
Karen has just arrived at school, and she has a math test today! The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points. There are _n_...
2,200
true
false
false
false
false
true
true
false
false
false
6,499
1028F
Consider a set of points $$$A$$$, initially it is empty. There are three types of queries: 1. Insert a point $$$(x_i, y_i)$$$ to $$$A$$$. It is guaranteed that this point does not belong to $$$A$$$ at this moment. 2. Remove a point $$$(x_i, y_i)$$$ from $$$A$$$. It is guaranteed that this point belongs to $$$A$$$ at th...
2,900
false
false
false
false
false
false
true
false
false
false
5,564
2005D
You are given two arrays $$$a_1, a_2, ldots, a_n$$$ and $$$b_1, b_2, ldots, b_n$$$. You must perform the following operation exactly once: choose any indices $$$l$$$ and $$$r$$$ such that $$$1 le l le r le n$$$; swap $$$a_i$$$ and $$$b_i$$$ for all $$$i$$$ such that $$$l leq i leq r$$$. Find the maximum possible valu...
2,400
false
false
true
false
true
false
true
true
false
false
220
1176F
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game. The boss battle consists of $$$n$$$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $$$c_i$$$ and damage $$$d_i$$$. You may play some of your cards d...
2,100
false
false
true
true
false
false
false
false
true
false
4,833
573A
Problem - 573A - 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
true
false
false
false
false
false
false
false
7,559
580C
Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of _n_ vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the ver...
1,500
false
false
false
false
false
false
false
false
false
true
7,526
1957F2
This is the hard version of the problem. The difference between the two versions of this problem is the constraint on $$$k$$$. You can make hacks only if all versions of the problem are solved. You are given an undirected tree of $$$n$$$ nodes. Each node $$$v$$$ has a value $$$a_v$$$ written on it. You have to answer q...
2,700
false
false
false
false
true
false
false
true
false
false
527
447A
Problem - 447A - 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...
800
false
false
true
false
false
false
false
false
false
false
8,051
1863D
There is an $$$n imes m$$$ board divided into cells. There are also some dominoes on this board. Each domino covers two adjacent cells (that is, two cells that share a side), and no two dominoes overlap. Piet thinks that this board is too boring and it needs to be painted. He will paint the cells of the dominoes black ...
1,400
false
true
false
false
false
true
false
false
false
false
1,103
1322F
Mayor of city M. decided to launch several new metro lines during 2020. Since the city has a very limited budget, it was decided not to dig new tunnels but to use the existing underground network. The tunnel system of the city M. consists of $$$n$$$ metro stations. The stations are connected with $$$n - 1$$$ bidirectio...
3,500
false
false
false
true
false
false
false
false
false
false
4,102
240E
A country named Berland has _n_ cities. They are numbered with integers from 1 to _n_. City with index 1 is the capital of the country. Some pairs of cities have monodirectional roads built between them. However, not all of them are in good condition. For each road we know whether it needs repairing or not. If a road n...
2,800
false
true
false
false
false
false
false
false
false
true
8,877
1044C
You are given $$$n$$$ points on the plane. The polygon formed from all the $$$n$$$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $$$1$$$ to $$$n$$$, in clockwise order. We define the distance betwee...
2,100
false
false
false
true
false
false
false
false
false
false
5,474
229B
Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet. Overall the galaxy has _n...
1,700
false
false
false
false
true
false
false
true
false
true
8,922
1550A
Let's call an array $$$a$$$ consisting of $$$n$$$ positive (greater than $$$0$$$) integers beautiful if the following condition is held for every $$$i$$$ from $$$1$$$ to $$$n$$$: either $$$a_i = 1$$$, or at least one of the numbers $$$a_i - 1$$$ and $$$a_i - 2$$$ exists in the array as well. For example: the array $$$...
800
true
true
false
false
false
false
false
false
false
false
2,898
1609D
William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies. The conference has $$$n$$$ participants, who are initially unfamiliar with each other. William can intro...
1,600
false
true
true
false
false
false
false
false
false
true
2,605
492D
Vanya and his friend Vova play a computer game where they need to destroy _n_ monsters to pass a level. Vanya's character performs attack with frequency _x_ hits per second and Vova's character performs attack with frequency _y_ hits per second. Each character spends fixed time to raise a weapon and then he hits (the t...
1,800
true
false
true
false
false
false
false
true
true
false
7,865
1474F
Igor had a sequence $$$d_1, d_2, dots, d_n$$$ of integers. When Igor entered the classroom there was an integer $$$x$$$ written on the blackboard. Igor generated sequence $$$p$$$ using the following algorithm: 1. initially, $$$p = [x]$$$; 2. for each $$$1 leq i leq n$$$ he did the following operation $$$d_i$$$ times: ...
3,000
true
false
false
true
false
false
false
false
false
false
3,305
163B
As you know, lemmings like jumping. For the next spectacular group jump _n_ lemmings gathered near a high rock with _k_ comfortable ledges on it. The first ledge is situated at the height of _h_ meters, the second one is at the height of 2_h_ meters, and so on (the _i_-th ledge is at the height of _i_·_h_ meters). The ...
2,000
false
false
false
false
false
false
false
true
false
false
9,214
746E
Eugeny has _n_ cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and that all these numbers would be distinct. Nikolay has _m_ cards, distinct numbers from 1 to _m_ are writ...
1,900
true
true
true
false
false
false
false
false
false
false
6,813
1475E
Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $$$n$$$ different bloggers. Blogger numbered $$$i$$$ has $$$a_i$$$ followers. Since Masha has a limited budget, she can only sign a contract with $$$k$$$ differ...
1,600
true
false
false
false
false
false
false
false
true
false
3,300
766E
Mahmoud and Ehab live in a country with _n_ cities numbered from 1 to _n_ and connected by _n_u2009-u20091 undirected roads. It's guaranteed that you can reach any city from any other using these roads. Each city has a number _a__i_ attached to it. We define the distance from city _x_ to city _y_ as the xor of numbers ...
2,100
true
false
false
true
true
true
false
false
false
false
6,719
1375F
This is an interactive problem. Anton and Harris are playing a game to decide which of them is the king of problemsetting. There are three piles of stones, initially containing $$$a$$$, $$$b$$$, and $$$c$$$ stones, where $$$a$$$, $$$b$$$, and $$$c$$$ are distinct positive integers. On each turn of the game, the followi...
2,600
true
false
false
false
false
true
false
false
false
false
3,782
838D
There is an airplane which has _n_ rows from front to back. There will be _m_ people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then board the p...
2,700
true
false
false
false
false
false
false
false
false
false
6,411
1980D
GCD (Greatest Common Divisor) of two integers $$$x$$$ and $$$y$$$ is the maximum integer $$$z$$$ by which both $$$x$$$ and $$$y$$$ are divisible. For example, $$$GCD(36, 48) = 12$$$, $$$GCD(5, 10) = 5$$$, and $$$GCD(7,11) = 1$$$. Kristina has an array $$$a$$$ consisting of exactly $$$n$$$ positive integers. She wants t...
1,400
true
true
true
false
false
false
false
false
false
false
407
623E
Problem - 623E - 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...
3,300
true
false
false
true
false
false
false
false
false
false
7,336
906E
Problem - 906E - 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...
3,300
false
false
false
true
false
false
false
false
false
false
6,123
997C
Problem - 997C - 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
true
false
false
false
false
false
false
false
false
false
5,716
1555A
PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $$$6$$$ slices, medium ones consist of $$$8$$$ slices, and large pizzas consist of $$$10$$$ slices each. Baking them takes $$$15$$$, $$$20$$$ and $$$25$$$ minutes, respectively. Petya's birthday is today...
900
true
false
false
false
false
false
true
false
false
false
2,861
1691C
You are given a binary string $$$s$$$ of length $$$n$$$. Let's define $$$d_i$$$ as the number whose decimal representation is $$$s_i s_{i+1}$$$ (possibly, with a leading zero). We define $$$f(s)$$$ to be the sum of all the valid $$$d_i$$$. In other words, $$$f(s) = sumlimits_{i=1}^{n-1} d_i$$$. For example, for the str...
1,400
true
true
false
false
false
true
true
false
false
false
2,134
939D
Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullover. Now she doesn't want to see him and Tolya is seating at his room and crying at her photos all day long. This story co...
1,600
false
true
false
false
false
false
false
false
false
true
5,941
1581B
CQXYM wants to create a connected undirected graph with $$$n$$$ nodes and $$$m$$$ edges, and the diameter of the graph must be strictly less than $$$k-1$$$. Also, CQXYM doesn't want a graph that contains self-loops or multiple edges (i.e. each edge connects two different vertices and between each pair of vertices there...
1,200
true
true
false
false
false
true
false
false
false
true
2,726
266B
During the break the schoolchildren, boys and girls, formed a queue of _n_ people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward ea...
800
false
false
true
false
false
true
false
false
false
false
8,770
2033A
Sakurako and Kosuke decided to play some games with a dot on a coordinate line. The dot is currently located in position $$$x=0$$$. They will be taking turns, and Sakurako will be the one to start. On the $$$i$$$-th move, the current player will move the dot in some direction by $$$2cdot i-1$$$ units. Sakurako will alw...
800
true
false
true
false
false
true
false
false
false
false
68
1684E
You are given an array $$$a$$$ of $$$n$$$ non-negative integers. In one operation you can change any number in the array to any other non-negative integer. Let's define the cost of the array as $$$operatorname{DIFF}(a) - operatorname{MEX}(a)$$$, where $$$operatorname{MEX}$$$ of a set of non-negative integers is the sma...
2,100
false
true
false
false
true
true
true
true
false
false
2,169
992E
Nastya likes reading and even spends whole days in a library sometimes. Today she found a chronicle of Byteland in the library, and it stated that there lived shamans long time ago. It is known that at every moment there was exactly one shaman in Byteland, and there were _n_ shamans in total enumerated with integers fr...
2,500
false
false
false
false
true
false
false
true
false
false
5,735
494A
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string _s_ written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that th...
1,500
false
true
false
false
false
false
false
false
false
false
7,858
83C
You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to complete the path fastest. The track's map is represented by a rectangle _n_u2009×u2009_m_ i...
2,400
false
true
false
false
false
false
false
false
false
true
9,551
115A
A company has _n_ employees numbered from 1 to _n_. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee _A_ is said to be the superior of another employee _B_ if at least one of the following is true: Employee _A_ is the immediate...
900
false
false
false
false
false
false
false
false
false
true
9,428
732A
Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for _k_ burles. Assume that there is an unlimited number of such shovels in the shop. In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of _r_ burles (1u2...
800
true
false
true
false
false
true
true
false
false
false
6,870
1091G
Integer factorisation is hard. The RSA Factoring Challenge offered $$$$100,000$$$ for factoring RSA-$$$1024$$$, a $$$1024$$$-bit long product of two prime numbers. To this date, nobody was able to claim the prize. We want you to factorise a $$$1024$$$-bit number. Since your programming language of choice might not offe...
3,200
true
false
false
false
false
false
false
false
false
false
5,253
1088B
Problem - 1088B - 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
false
true
false
false
false
false
false
true
false
5,290
1893C
Let's define the anti-beauty of a multiset $$${b_1, b_2, ldots, b_{len}}$$$ as the number of occurrences of the number $$$len$$$ in the multiset. You are given $$$m$$$ multisets, where the $$$i$$$-th multiset contains $$$n_i$$$ distinct elements, specifically: $$$c_{i, 1}$$$ copies of the number $$$a_{i,1}$$$, $$$c_{i,...
2,000
false
true
true
false
false
false
true
false
false
false
949
125B
Let's define a string <x> as an opening tag, where _x_ is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where _x_ is the same letter. Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair. Let's define the noti...
1,000
false
false
true
false
false
false
false
false
false
false
9,381
290C
Problem - 290C - Codeforces =============== xa0 . Output Output a single real number. The answer is considered to be correct if its absolute or relative error does not exceed 10u2009-u20094. Examples Input 3 0 1 1 Output 0.666667
1,700
false
false
true
false
false
false
false
false
false
false
8,675
593D
Bogdan has a birthday today and mom gave him a tree consisting of _n_ vertecies. For every edge of the tree _i_, some number _x__i_ was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After the present was granted, _m_ guests consecutively come to Bogdan's party. When the _i_...
2,400
true
false
false
false
true
false
false
false
false
true
7,474
295C
One day Greg and his friends were walking in the forest. Overall there were _n_ people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold ...
2,100
false
false
false
true
false
false
false
false
false
true
8,649
708C
Tree is a connected acyclic graph. Suppose you are given a tree consisting of _n_ vertices. The vertex of this tree is called centroid if the size of each connected component that appears if this vertex is removed from the tree doesn't exceed . You are given a tree of size _n_ and can perform no more than one edge repl...
2,300
false
true
false
true
true
false
false
false
false
true
6,987
301E
Problem - 301E - 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,800
false
false
false
true
false
false
false
false
false
false
8,626
1864G
Aquamoon has a Rubik's Square which can be seen as an $$$n imes n$$$ matrix, the elements of the matrix constitute a permutation of numbers $$$1, ldots, n^2$$$. Aquamoon can perform two operations on the matrix: Row shift, i.e. shift an entire row of the matrix several positions (at least $$$1$$$ and at most $$$n-1$$...
3,100
false
false
true
false
false
true
false
false
false
false
1,091
367B
Problem - 367B - 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,900
false
false
false
false
true
false
false
true
false
false
8,364
1867F
Given a tree with $$$n$$$ vertices rooted at vertex $$$1$$$, denote it as $$$G$$$. Also denote $$$P(G)$$$ as the multiset of subtrees of all vertices in tree $$$G$$$. You need to find a tree $$$G'$$$ of size $$$n$$$ rooted at vertex $$$1$$$ such that the number of subtrees in $$$P(G')$$$ that are isomorphic to any subt...
2,700
false
true
false
false
false
true
true
false
false
false
1,069