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
818E
Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of _n_ cards and a magic number _k_. The order of the cards in the deck is fixed. Each card has a number written on it; number _a__i_ is written on the _i_-th card in the deck. After rece...
1,900
false
false
false
false
true
false
false
true
false
false
6,483
1738C
Alice and Bob are playing a game on a sequence $$$a_1, a_2, dots, a_n$$$ of length $$$n$$$. They move in turns and Alice moves first. In the turn of each player, he or she should select an integer and remove it from the sequence. The game ends when there is no integer left in the sequence. Alice wins if the sum of her ...
1,500
true
true
false
true
false
false
false
false
false
false
1,859
1958I
You are given two rooted trees, consisting of $$$n$$$ vertices each. The vertices in the trees are numbered from $$$1$$$ to $$$n$$$, and the root is the vertex $$$1$$$. You can perform the following operation: choose the tree and the vertex $$$v$$$ (except the root of the tree) in it; connect the child nodes of $$$v$$$...
3,100
false
false
false
false
false
false
false
false
false
true
518
241A
There are _n_ cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as _c_1,u2009_c_2,u2009...,u2009_c__n_. The Old Peykan wants to travel from city _c_1 to _c__n_ using roads. There are (_n_u2009-u20091) one way roads, the _i_-th road goes f...
1,300
false
true
false
false
false
false
false
false
false
false
8,875
2039H1
This is the easy version of the problem. The only difference is the maximum number of operations you can perform. You can only make hacks if both versions are solved. You are given an array $$$a$$$ of size $$$n$$$. A cool swap walk is the following process: In an $$$n imes n$$$ grid, we note the cells in row $$$i$$$ ...
3,500
false
false
true
false
false
true
false
false
true
false
15
1895D
Problem - 1895D - 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
true
true
false
false
false
false
941
1420E
A lighthouse keeper Peter commands an army of $$$n$$$ battle lemmings. He ordered his army to stand in a line and numbered the lemmings from $$$1$$$ to $$$n$$$ from left to right. Some of the lemmings hold shields. Each lemming cannot hold more than one shield. The more protected Peter's army is, the better. To calcula...
2,500
false
true
false
true
false
false
false
false
false
false
3,575
1883G2
This is the hard version of the problem. The only difference is that in this version $$$m leq 10^9$$$. You are given two arrays of integers $$$a_1, a_2, ldots, a_n$$$ and $$$b_1, b_2, ldots, b_n$$$. Before applying any operations, you can reorder the elements of each array as you wish. Then, in one operation, you will ...
1,900
false
true
false
false
false
false
false
true
true
false
984
1372D
# Omkar and Circle Input file: standard input Output file: standard output Time limit: 2 seconds Memory limit: 256 megabytes Danny, the local Math Maniac, is fascinated by circles, Omkar’s most recent creation. Help him solve this circle problem! You are given n nonnegative integers a1, a 2, . . . , a n arranged in ...
2,100
false
true
false
true
false
false
true
false
false
false
3,804
1918F
The caterpillar decided to visit every node of the tree. Initially, it is sitting at the root. The tree is represented as a rooted tree with the root at the node $$$1$$$. Each crawl to a neighboring node takes $$$1$$$ minute for the caterpillar. And there is a trampoline under the tree. If the caterpillar detaches from...
2,500
false
true
true
false
false
false
false
false
true
true
783
1535C
Problem - 1535C - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - ...
1,400
false
true
true
true
false
false
false
true
false
false
2,972
13D
Problem - 13D - Codeforces =============== xa0 — the number of red and blue points respectively. The following _N_ lines contain two integer numbers each — coordinates of red points. The following _M_ lines contain two integer numbers each — coordinates of blue points. All coordinates do not exceed 109 by...
2,600
false
false
false
true
false
false
false
false
false
false
9,927
484D
Problem - 484D - 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
true
true
false
false
false
false
false
7,899
79B
Fox Ciel saw a large field while she was on a bus. The field was a _n_u2009×u2009_m_ rectangle divided into 1u2009×u20091 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes. After seeing the field carefully, Ciel found that the crop plants of each cell were pl...
1,400
false
false
true
false
false
false
false
false
true
false
9,569
489A
In this problem your goal is to sort an array consisting of _n_ integers in at most _n_ swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another. Note that in this problem you do not have to minimize the number of...
1,200
false
true
true
false
false
false
false
false
true
false
7,883
1780E
Josuke received a huge undirected weighted complete$$$^dagger$$$ graph $$$G$$$ as a gift from his grandfather. The graph contains $$$10^{18}$$$ vertices. The peculiarity of the gift is that the weight of the edge between the different vertices $$$u$$$ and $$$v$$$ is equal to $$$gcd(u, v)^ddagger$$$. Josuke decided to e...
2,400
true
false
false
false
true
false
true
true
false
false
1,591
626A
Problem - 626A - Codeforces =============== xa0 ]( "23515") xa0— the number of commands. The next line contains _n_ characters, each either 'U', 'R', 'D', or 'L'xa0— Calvin's source code. Output Print a single integerxa0— the number of contiguous substrings that Calvin can execute and return to his startin...
1,000
false
false
true
false
false
false
true
false
false
false
7,328
1776N
You are given a string $$$s$$$ with length $$$n-1$$$ whose characters are either $$$ exttt{<}$$$ or $$$ exttt{>}$$$. Count the permutations $$$p_1, , p_2, , dots, , p_n$$$ of $$$1, , 2, , dots, , n$$$ such that, for all $$$i = 1, , 2, , dots, , n - 1$$$, if $$$s_i$$$ is $$$ exttt{<}$$$ then $$$p_i < p_{i+1}$$$ and if $...
3,500
true
false
false
false
false
false
false
false
false
false
1,615
746D
Problem - 746D - 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
true
true
false
false
false
true
false
false
false
false
6,814
908B
Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a single exit...
1,200
false
false
true
false
false
false
true
false
false
false
6,119
725F
Alice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, they decided that they would take turns picking photos. Alice goes first. There are _n_ stacks of photos. Each stack co...
2,900
false
true
false
false
false
false
false
false
false
false
6,902
1547A
There are three cells on an infinite 2-dimensional grid, labeled $$$A$$$, $$$B$$$, and $$$F$$$. Find the length of the shortest path from $$$A$$$ to $$$B$$$ if: in one move you can go to any of the four adjacent cells sharing a side; visiting the cell $$$F$$$ is forbidden (it is an obstacle). Input The first line con...
800
true
false
true
false
false
false
false
false
false
false
2,913
1144G
Two integer sequences existed initially, one of them was strictly increasing, and another one — strictly decreasing. Strictly increasing sequence is a sequence of integers $$$[x_1 < x_2 < dots < x_k]$$$. And strictly decreasing sequence is a sequence of integers $$$[y_1 > y_2 > dots > y_l]$$$. Note that the empty seque...
2,400
false
true
false
true
false
false
false
false
false
false
4,999
1121A
Everybody knows that the $$$m$$$-coder Tournament will happen soon. $$$m$$$ schools participate in the tournament, and only one student from each school participates. There are a total of $$$n$$$ students in those schools. Before the tournament, all students put their names and the names of their schools into the Techn...
1,100
false
false
true
false
false
false
false
false
true
false
5,080
1990F
You are given an array $$$a$$$ of size $$$n$$$. A segment $$$$$$ is called a polygonal segment only if the following conditions hold: $$$(r-l+1) geq 3$$$; Considering $$$a_l, a_{l+1}, ldots, a_r$$$ as side lengths, these sides can form a polygon with $$$(r-l+1)$$$ sides. Process $$$q$$$ queries of two types: "1 l r"...
2,800
false
true
false
true
true
false
true
false
false
false
329
556A
Problem - 556A - 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
true
false
false
false
false
false
false
false
false
7,610
261E
Problem - 261E - 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
true
false
false
false
8,786
46F
Today you are to solve the problem even the famous Hercule Poirot can't cope with! That's why this crime has not yet been solved and this story was never included in Agatha Christie's detective story books. You are not informed on what crime was committed, when and where the corpse was found and other details. We only ...
2,300
false
false
false
false
false
false
false
false
false
true
9,744
1422B
A matrix of size $$$n imes m$$$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $$$(a_1, a_2, dots , a_k)$$$ is a palindrome, if for any integer $$$i$$$ ($$$1 le i le k$$$) the equality $$$a_i = a_{k - i + 1}$$$ holds. Sasha owns a matrix $$$a$$$ of size $$$n imes m$$$. I...
1,300
true
true
true
false
false
false
false
false
false
false
3,568
2026E
Problem - 2026E - 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,500
false
false
false
false
false
false
false
false
false
true
112
1738E
Given an integer sequence $$$a_1, a_2, dots, a_n$$$ of length $$$n$$$, your task is to compute the number, modulo $$$998244353$$$, of ways to partition it into several non-empty continuous subsequences such that the sums of elements in the subsequences form a balanced sequence. A sequence $$$s_1, s_2, dots, s_k$$$ of l...
2,300
true
false
false
true
false
false
false
false
false
false
1,857
555B
Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water. The only dry land there is an archipelago of _n_ narrow islands located in a row. For more comfort let's represent them as non-intersecting segments on a straight line:...
2,000
false
true
false
false
true
false
false
false
true
false
7,614
1806B
You are given an array $$$a$$$ of length $$$n$$$. The score of $$$a$$$ is the MEX$$$^{dagger}$$$ of $$$[a_1+a_2,a_2+a_3,ldots,a_{n-1}+a_n]$$$. Find the minimum score of $$$a$$$ if you are allowed to rearrange elements of $$$a$$$ in any order. Note that you are not required to construct the array $$$a$$$ that achieves t...
900
false
true
false
false
false
true
false
false
false
false
1,441
1470B
Let us call two integers $$$x$$$ and $$$y$$$ adjacent if $$$frac{lcm(x, y)}{gcd(x, y)}$$$ is a perfect square. For example, $$$3$$$ and $$$12$$$ are adjacent, but $$$6$$$ and $$$9$$$ are not. Here $$$gcd(x, y)$$$ denotes the $$$ denotes the , that are adjacent to the current value. Let $$$d_i$$$ be the number of adjace...
1,900
true
false
false
false
false
false
false
false
false
true
3,331
1283F
Polycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself. Simple garlands consisting of several lamps connected by one wire are too boring for Polycarp. He is going to solder a garland consisting of $$$n$$...
2,200
false
true
false
false
false
true
false
false
false
false
4,275
282B
The Bitlandians are quite weird people. They have very peculiar customs. As is customary, Uncle J. wants to have _n_ eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work. The kids are excited because just as is customary, they're going to be paid for the job! Overall uncle J. has...
1,500
true
true
false
false
false
false
false
false
false
false
8,707
909C
In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation. We will consider an extremely simplified subset of Python with only two types of statements. Simple statements are written in a single line, one per line. An exam...
1,800
false
false
false
true
false
false
false
false
false
false
6,110
930C
Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;_m_] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodo...
1,900
false
false
false
true
true
false
false
false
false
false
5,984
1288A
Adilbek was assigned to a special project. For Adilbek it means that he has $$$n$$$ days to run a special program and provide its results. But there is a problem: the program needs to run for $$$d$$$ days to calculate the results. Fortunately, Adilbek can optimize the program. If he spends $$$x$$$ ($$$x$$$ is a non-neg...
1,100
true
false
false
false
false
false
true
true
false
false
4,252
1968A
Problem - 1968A - 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
true
false
false
false
false
false
true
false
false
false
500
1173B
Nauuo is a girl who loves playing chess. One day she invented a game by herself which needs $$$n$$$ chess pieces to play on a $$$m imes m$$$ chessboard. The rows and columns are numbered from $$$1$$$ to $$$m$$$. We denote a cell on the intersection of the $$$r$$$-th row and $$$c$$$-th column as $$$(r,c)$$$. The game's ...
1,100
false
true
false
false
false
true
false
false
false
false
4,852
1700D
Recently in Divanovo, a huge river locks system was built. There are now $$$n$$$ locks, the $$$i$$$-th of them has the volume of $$$v_i$$$ liters, so that it can contain any amount of water between $$$0$$$ and $$$v_i$$$ liters. Each lock has a pipe attached to it. When the pipe is open, $$$1$$$ liter of water enters th...
1,900
true
true
false
true
false
false
false
true
false
false
2,079
1987F1
This is the easy version of the problem. The only difference between the two versions is the constraint on $$$n$$$. You can make hacks only if both versions of the problem are solved. You are given an array of integers $$$a$$$ of length $$$n$$$. In one operation, you will perform the following two-step process: 1. Choo...
2,500
false
false
false
true
false
false
false
false
false
false
352
1542D
You are given a sequence $$$A$$$, where its elements are either in the form + x or -, where $$$x$$$ is an integer. For such a sequence $$$S$$$ where its elements are either in the form + x or -, define $$$f(S)$$$ as follows: iterate through $$$S$$$'s elements from the first one to the last one, and maintain a multiset...
2,200
true
false
true
true
false
false
false
false
false
false
2,931
158D
The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus _n_ ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they...
1,300
false
false
false
false
false
false
true
false
false
false
9,242
549F
Yura has a team of _k_ developers and a list of _n_ tasks numbered from 1 to _n_. Yura is going to choose some tasks to be done this week. Due to strange Looksery habits the numbers of chosen tasks should be a segment of consecutive integers containing no less than 2 numbers, i. e. a sequence of form _l_,u2009_l_u2009+...
2,800
false
false
false
false
true
false
false
false
false
false
7,640
601E
There's a famous museum in the city where Kleofáš lives. In the museum, _n_ exhibits (numbered 1 through _n_) had been displayed for a long time; the _i_-th of those exhibits has value _v__i_ and mass _w__i_. Then, the museum was bought by a large financial group and started to vary the exhibits. At about the same time...
2,800
false
false
false
true
true
false
false
false
false
false
7,436
1154F
There are $$$n$$$ shovels in the nearby shop. The $$$i$$$-th shovel costs $$$a_i$$$ bourles. Misha has to buy exactly $$$k$$$ shovels. Each shovel can be bought no more than once. Misha can buy shovels by several purchases. During one purchase he can choose any subset of remaining (non-bought) shovels and buy this subs...
2,100
false
true
false
true
false
false
false
false
true
false
4,938
1497D
Please note the non-standard memory limit. There are $$$n$$$ problems numbered with integers from $$$1$$$ to $$$n$$$. $$$i$$$-th problem has the complexity $$$c_i = 2^i$$$, tag $$$tag_i$$$ and score $$$s_i$$$. After solving the problem $$$i$$$ it's allowed to solve problem $$$j$$$ if and only if $$$ ext{IQ} < c_i - c_j...
2,500
false
false
false
true
false
false
false
false
false
true
3,184
1148H
You are given an array which is initially empty. You need to perform $$$n$$$ operations of the given format: "$$$a$$$ $$$l$$$ $$$r$$$ $$$k$$$": append $$$a$$$ to the end of the array. After that count the number of integer pairs $$$x, y$$$ such that $$$l leq x leq y leq r$$$ and $$$operatorname{mex}(a_{x}, a_{x+1}, ld...
3,500
false
false
false
false
true
false
false
false
false
false
4,970
897B
Problem - 897B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,300
false
false
false
false
false
false
true
false
false
false
6,159
1954F
Let's say that two strings $$$a$$$ and $$$b$$$ are equal if you can get the string $$$b$$$ by cyclically shifting string $$$a$$$. For example, the strings 0100110 and 1100100 are equal, while 1010 and 1100 are not. You are given a binary string $$$s$$$ of length $$$n$$$. Its first $$$c$$$ characters are 1-s, and its la...
3,100
true
false
false
true
false
false
false
false
false
false
549
1206A
You are given an array $$$A$$$, consisting of $$$n$$$ positive integers $$$a_1, a_2, dots, a_n$$$, and an array $$$B$$$, consisting of $$$m$$$ positive integers $$$b_1, b_2, dots, b_m$$$. Choose some element $$$a$$$ of $$$A$$$ and some element $$$b$$$ of $$$B$$$ such that $$$a+b$$$ doesn't belong to $$$A$$$ and doesn't...
800
true
false
false
false
false
false
false
false
true
false
4,663
1395A
Boboniu gives you $$$r$$$ red balls, $$$g$$$ green balls, $$$b$$$ blue balls, $$$w$$$ white balls. He allows you to do the following operation as many times as you want: Pick a red ball, a green ball, and a blue ball and then change their color to white. You should answer if it's possible to arrange all the balls ...
1,000
true
false
false
false
false
false
true
false
false
false
3,696
938C
Let's denote a _m_-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size _m_u2009×u2009_m_ of this matrix contains at least one zero. Consider the following problem: You are given two integers _n_ and _m_. You have to construct an _m_-free square matrix of siz...
1,700
false
false
false
false
false
true
true
true
false
false
5,949
1375I
A cubic lattice $$$L$$$ in $$$3$$$-dimensional euclidean space is a set of points defined in the following way: $$$$$$L={u cdot vec r_1 + v cdot vec r_2 + w cdot vec r_3}_{u, v, w in mathbb Z}$$$$$$ Where $$$vec r_1, vec r_2, vec r_3 in mathbb{Z}^3$$$ are some integer vectors such that: $$$vec r_1$$$, $$$vec r_2$$$ an...
3,500
true
false
false
false
false
false
false
false
false
false
3,779
784F
Problem - 784F - Codeforces =============== xa0 ]( "51289") — the size of the array. The following _n_ numbers are the elements of the array (1u2009≤u2009_a__i_u2009≤u2009100). Output Output space-separated elements of the sorted array. Example Input 3 3 1 2 Output 1 2 3 Note Remember, this is a very imp...
1,900
false
false
true
false
false
false
false
false
false
false
6,635
1534G
Annie has gotten bored of winning every coding contest and farming unlimited rating. Today, she is going to farm potatoes instead. Annie's garden is an infinite 2D plane. She has $$$n$$$ potatoes to plant, and the $$$i$$$-th potato must be planted at $$$(x_i,y_i)$$$. Starting at the point $$$(0, 0)$$$, Annie begins wal...
3,300
false
false
false
true
true
false
false
false
true
false
2,976
1918C
You are given integers $$$a$$$, $$$b$$$, $$$r$$$. Find the smallest value of $$$({a oplus x}) - ({b oplus x})$$$ among all $$$0 leq x leq r$$$. $$$oplus$$$ is the operation of xa0— the number of test cases. Each test case contains integers $$$a$$$, $$$b$$$, $$$r$$$ ($$$0 le a, b, r le 10^{18}$$$). Output For each test ...
1,400
true
true
true
false
false
false
false
false
false
false
786
1912H
A revolutionary new transport system is currently operating in Byteland. This system requires neither roads nor sophisticated mechanisms, only giant catapults. The system works as follows. There are $$$n$$$ cities in Byteland. In every city there is a catapult, right in the city center. People who want to travel are pu...
2,400
false
false
false
false
false
false
false
false
false
true
830
963A
You are given two integers $$$a$$$ and $$$b$$$. Moreover, you are given a sequence $$$s_0, s_1, dots, s_{n}$$$. All values in $$$s$$$ are integers $$$1$$$ or $$$-1$$$. It's known that sequence is $$$k$$$-periodic and $$$k$$$ divides $$$n+1$$$. In other words, for each $$$k leq i leq n$$$ it's satisfied that $$$s_{i} = ...
1,800
true
false
false
false
false
false
false
false
false
false
5,849
260E
A country called Flatland is an infinite two-dimensional plane. Flatland has _n_ cities, each of them is a point on the plane. Flatland is ruled by king Circle IV. Circle IV has 9 sons. He wants to give each of his sons part of Flatland to rule. For that, he wants to draw four distinct straight lines, such that two of ...
2,500
false
false
false
false
true
false
true
true
false
false
8,791
914A
Problem - 914A - 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
true
false
true
false
false
false
true
false
false
false
6,083
603B
Problem - 603B - 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,800
true
false
false
false
false
false
false
false
false
false
7,432
1991G
You are given a grid consisting of $$$n$$$ rows and $$$m$$$ columns, where each cell is initially white. Additionally, you are given an integer $$$k$$$, where $$$1 le k le min(n, m)$$$. You will process $$$q$$$ operations of two types: $$$mathtt{H}$$$ (horizontal operation)xa0— You choose a $$$1 imes k$$$ rectangle c...
2,700
false
true
true
false
false
true
false
false
false
false
322
1335E1
The only difference between easy and hard versions is constraints. You are given a sequence $$$a$$$ consisting of $$$n$$$ positive integers. Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are $$$a$$$ and $$$b$$$, $$$a$$$ can be equal $$$b$$$) and ...
1,700
false
false
false
true
true
false
true
true
false
false
4,026
1303G
We define the sum of prefix sums of an array $$$[s_1, s_2, dots, s_k]$$$ as $$$s_1 + (s_1 + s_2) + (s_1 + s_2 + s_3) + dots + (s_1 + s_2 + dots + s_k)$$$. You are given a tree consisting of $$$n$$$ vertices. Each vertex $$$i$$$ has an integer $$$a_i$$$ written on it. We define the value of the simple path from vertex $...
2,700
false
false
false
false
true
false
false
false
false
false
4,172
1821A
An integer template is a string consisting of digits and/or question marks. A positive (strictly greater than $$$0$$$) integer matches the integer template if it is possible to replace every question mark in the template with a digit in such a way that we get the decimal representation of that integer without any leadi...
800
true
false
false
false
false
false
false
false
false
false
1,357
1986B
You are given a matrix of size $$$n imes m$$$, where the rows are numbered from $$$1$$$ to $$$n$$$ from top to bottom, and the columns are numbered from $$$1$$$ to $$$m$$$ from left to right. The element at the intersection of the $$$i$$$-th row and the $$$j$$$-th column is denoted by $$$a_{ij}$$$. Consider the algori...
1,000
false
true
false
false
true
false
true
false
true
false
364
515B
Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan. There are _n_ boys and _m_ girls among his friends. Let's number them from 0 to _n_u2009-u20091 and 0 to _m_u2009-u20091 separately. In _i_-th day, Drazil i...
1,300
false
false
false
false
false
false
true
false
false
false
7,774
335F
Problem - 335F - Codeforces =============== xa0 , the number of pies you wish to acquire. Following this is a line with _n_ integers, each indicating the cost of a pie. All costs are positive integers not exceeding 109. Output Print the minimum cost to acquire all the pies. Please, do not use the %lld spe...
3,000
false
true
false
true
false
false
false
false
false
false
8,493
424B
The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city. The city of Tomsk can be represented as point on the plane with c...
1,200
false
true
true
false
false
false
false
true
true
false
8,142
578D
Problem - 578D - Codeforces =============== xa0 ]( "Codeforces Round #320 between _S_ and _T_ is _n_u2009-u20091. Recall that LCS of two strings _S_ and _T_ is the longest string _C_ such that _C_ both in _S_ and _T_ as a subsequence. Input The first line contains two numbers _n_ and _m_ denoting the length o...
2,700
false
true
false
true
false
false
false
false
false
false
7,533
100J
Problem - 100J - Codeforces =============== xa0 , number of intervals. The following _n_ lines contain a interval description each. Each interval is described by two numbers _s__i_,u2009_e__i_ which are the start and end points of it (u2009-u2009105u2009<u2009_s__i_,u2009_e__i_u2009<u2009105, _s__i_u2009≤u200...
2,400
true
true
false
false
false
false
false
false
false
false
9,480
1732D2
This is the hard version of the problem. The only difference is that in this version there are remove queries. Initially you have a set containing one element — $$$0$$$. You need to handle $$$q$$$ queries of the following types: + $$$x$$$ — add the integer $$$x$$$ to the set. It is guaranteed that this integer is not ...
2,400
false
false
false
false
true
false
true
false
false
false
1,894
1019C
Sergey just turned five years old! When he was one year old, his parents gave him a number; when he was two years old, his parents gave him an array of integers. On his third birthday he received a string. When he was four, his mother woke him up in a quiet voice, wished him to be a good boy and gave him a rooted tree....
3,000
false
false
false
false
false
true
false
false
false
true
5,595
402D
Problem - 402D - 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,800
true
true
false
true
false
false
false
false
false
false
8,214
1354E
You are given an undirected graph without self-loops or multiple edges which consists of $$$n$$$ vertices and $$$m$$$ edges. Also you are given three integers $$$n_1$$$, $$$n_2$$$ and $$$n_3$$$. Can you label each vertex with one of three numbers 1, 2 or 3 in such way, that: 1. Each vertex should be labeled by exactly ...
2,100
false
false
false
true
false
false
false
false
false
true
3,934
1104A
Vasya has his favourite number $$$n$$$. He wants to split it to some non-zero digits. It means, that he wants to choose some digits $$$d_1, d_2, ldots, d_k$$$, such that $$$1 leq d_i leq 9$$$ for all $$$i$$$ and $$$d_1 + d_2 + ldots + d_k = n$$$. Vasya likes beauty in everything, so he wants to find any solution with t...
800
true
false
true
false
false
true
false
false
false
false
5,182
549B
The Looksery company, consisting of _n_ staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts about how cool it is. At the same time everyone is trying to spend as much tim...
2,300
false
true
false
false
false
true
false
false
false
true
7,644
1685E
It turns out that this is exactly the $$$100$$$-th problem of mine that appears in some programming competition. So it has to be special! And what can be more special than another problem about LIS... You are given a permutation $$$p_1, p_2, ldots, p_{2n+1}$$$ of integers from $$$1$$$ to $$$2n+1$$$. You will have to pr...
3,500
false
true
false
false
true
false
false
false
false
false
2,160
2031F
This is an interactive problem. Returning from a restful vacation on Australia's Gold Coast, Penchick forgot to bring home gifts for his pet duck Duong Canh! But perhaps a beautiful problem crafted through deep thought on the scenic beaches could be the perfect souvenir. There is a hidden permutation$$$^{ ext{∗}}$$$ $$...
2,800
false
false
false
false
false
true
false
true
false
false
75
1174D
Problem - 1174D - 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
false
false
false
false
false
true
false
false
false
false
4,848
226A
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!). The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the ...
1,400
true
false
false
false
false
false
false
false
false
false
8,935
437B
Problem - 437B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,500
false
true
true
false
false
false
false
false
true
false
8,090
253A
Problem - 253A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,100
false
true
false
false
false
false
false
false
false
false
8,824
1758A
A palindrome is a string that reads the same backward as forward. For example, the strings $$$ exttt{z}$$$, $$$ exttt{aaa}$$$, $$$ exttt{aba}$$$, and $$$ exttt{abccba}$$$ are palindromes, but $$$ exttt{codeforces}$$$ and $$$ exttt{ab}$$$ are not. The double of a string $$$s$$$ is obtained by writing each character twic...
800
false
false
false
false
false
true
false
false
false
false
1,768
908C
Carol is currently curling. She has _n_ disks each with radius _r_ on the 2D plane. Initially she has all these disks above the line _y_u2009=u200910100. She then will slide the disks towards the line _y_u2009=u20090 one by one in order from 1 to _n_. When she slides the _i_-th disk, she will place its center at the po...
1,500
true
false
true
false
false
false
true
false
false
false
6,118
991E
This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious eitherxa0— although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all....
1,800
true
false
false
false
false
false
true
false
false
false
5,741
1196F
You are given a connected undirected weighted graph consisting of $$$n$$$ vertices and $$$m$$$ edges. You need to print the $$$k$$$-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from $$$i$$$ to $$$j$$$ and from $$$j$$$ to $$$i$$$ are counted as one). More formally, if $...
2,200
false
false
false
false
false
true
true
false
true
false
4,716
1790F
Timofey came to a famous summer school and found a tree on $$$n$$$ vertices. A tree is a connected undirected graph without cycles. Every vertex of this tree, except $$$c_0$$$, is colored white. The vertex $$$c_0$$$ is colored black. Timofey wants to color all the vertices of this tree in black. To do this, he performs...
2,100
true
true
false
false
false
false
true
false
false
true
1,537
1023D
Initially there was an array $$$a$$$ consisting of $$$n$$$ integers. Positions in it are numbered from $$$1$$$ to $$$n$$$. Exactly $$$q$$$ queries were performed on the array. During the $$$i$$$-th query some segment $$$(l_i, r_i)$$$ $$$(1 le l_i le r_i le n)$$$ was selected and values of elements on positions from $$$...
1,700
false
false
false
false
true
true
false
false
false
false
5,587
1091C
There are $$$n$$$ people sitting in a circle, numbered from $$$1$$$ to $$$n$$$ in the order in which they are seated. That is, for all $$$i$$$ from $$$1$$$ to $$$n-1$$$, the people with id $$$i$$$ and $$$i+1$$$ are adjacent. People with id $$$n$$$ and $$$1$$$ are adjacent as well. The person with id $$$1$$$ initially h...
1,400
true
false
false
false
false
false
false
false
false
false
5,257
1748A
You have $$$n$$$ rectangular wooden blocks, which are numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th block is $$$1$$$ unit high and $$$lceil frac{i}{2} ceil$$$ units long. Here, $$$lceil frac{x}{2} ceil$$$ denotes the result of division of $$$x$$$ by $$$2$$$, rounded up. For example, $$$lceil frac{4}{2} ceil = 2$$...
800
true
false
false
false
false
false
false
false
false
false
1,797
1515H
Problem - 1515H - Codeforces =============== xa0 ]( "Codeforces Global Round 14") xa0— the number of integers and the number of queries, respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, dots, a_n$$$ ($$$0 le a_i < 2^{20}$$$)xa0— the integers that Phoenix starts with. The next $$$q$$$ li...
3,500
false
false
false
false
true
false
true
false
true
false
3,084
29C
One day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a letter directly from the city of the sender to the city of the receiver, that's why the letter is sen...
1,700
false
false
true
false
true
false
false
false
false
true
9,851
1454C
You are given a sequence $$$a$$$, initially consisting of $$$n$$$ integers. You want to transform this sequence so that all elements in it are equal (i.xa0e. it contains several occurrences of the same element). To achieve this, you choose some integer $$$x$$$ that occurs at least once in $$$a$$$, and then perform the ...
1,200
false
true
true
false
false
false
false
false
false
false
3,406
1763C
You are given an array $$$a$$$ of $$$n$$$ integers. You are allowed to perform the following operation on it as many times as you want (0 or more times): Choose $$$2$$$ indices $$$i$$$,$$$j$$$ where $$$1 le i < j le n$$$ and replace $$$a_k$$$ for all $$$i leq k leq j$$$ with $$$a_i - a_j$$$ Print the maximum sum of al...
2,000
false
true
false
false
false
true
true
false
false
false
1,731
754B
Ilya is an experienced player in tic-tac-toe on the 4u2009×u20094 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game b...
1,100
false
false
true
false
false
false
true
false
false
false
6,781
1716B
A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ such that each integer appears in it exactly once. Let the fixedness of a permutation $$$p$$$ be the number of fixed points in itxa0— the number of positions $$$j$$$ such that $$$p_j = j$$$, where $$$p_j$$$ is the $$$j$$$-th element of th...
800
true
false
false
false
false
true
false
false
false
false
1,986