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
828A
In a small restaurant there are _a_ tables for one person and _b_ tables for two persons. It it known that _n_ groups of people come today, each consisting of one or two people. If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seater ta...
1,200
false
false
true
false
false
false
false
false
false
false
6,449
1712F
— To count graph diameters. You and Your Submission A tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each edge. The degree of a vertex is the number of edges connected to this vertex. You are given a weighted tree with $$$n$$$ vertices, each edge has a weight of $$$1$$$. L...
3,200
false
false
false
false
true
false
false
true
false
false
2,007
1545E2
Note that the differences between easy and hard versions are the constraints on $$$n$$$ and the time limit. You can make hacks only if both versions are solved. AquaMoon knew through foresight that some ghosts wanted to curse tourists on a pedestrian street. But unfortunately, this time, these ghosts were hiding in a b...
3,500
false
false
false
true
true
false
false
false
false
false
2,917
1425C
Problem - 1425C - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - ...
3,100
true
false
false
false
false
false
false
false
false
false
3,545
1674D
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 786 (Div. 3) Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If...
1,200
false
false
true
false
false
true
false
false
true
false
2,226
457C
Problem - 457C - Codeforces =============== xa0 — number of voters in the city. Each of the next _n_ lines describes one voter and contains two integers _a__i_ and _b__i_ (0u2009≤u2009_a__i_u2009≤u2009105;xa00u2009≤u2009_b__i_u2009≤u2009104) — number of the candidate that voter is going to vote for and am...
2,100
false
false
false
false
false
false
true
false
false
false
8,010
279D
You've got a positive integer sequence _a_1,u2009_a_2,u2009...,u2009_a__n_. All numbers in the sequence are distinct. Let's fix the set of variables _b_1,u2009_b_2,u2009...,u2009_b__m_. Initially each variable _b__i_ (1u2009≤u2009_i_u2009≤u2009_m_) contains the value of zero. Consider the following sequence, consisting...
2,200
false
false
false
true
false
false
false
false
false
false
8,717
1093B
You are given a string $$$s$$$ consisting only of lowercase Latin letters. You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossible to do it. Let's call a string good if it is not a palindrome. Palindrom...
900
false
true
false
false
false
true
false
false
true
false
5,243
1556A
William has two numbers $$$a$$$ and $$$b$$$ initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer $$$k$$$ is picked, which is then used to perform one of the following operations: (note, that for each operation you ...
800
true
false
false
false
false
false
false
false
false
false
2,855
825F
Ivan wants to write a letter to his friend. The letter is a string _s_ consisting of lowercase Latin letters. Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string _s_ instead...
2,400
false
false
false
true
false
false
false
false
false
false
6,457
1205C
This is an interactive problem You are given a grid $$$n imes n$$$, where $$$n$$$ is odd. Rows are enumerated from $$$1$$$ to $$$n$$$ from up to down, columns are enumerated from $$$1$$$ to $$$n$$$ from left to right. Cell, standing on the intersection of row $$$x$$$ and column $$$y$$$, is denoted by $$$(x, y)$$$. Ever...
2,400
false
false
true
false
false
false
false
false
false
false
4,667
1708A
You are given an array $$$a$$$ consisting of $$$n$$$ positive integers. You are allowed to perform this operation any number of times (possibly, zero): choose an index $$$i$$$ ($$$2 le i le n$$$), and change $$$a_i$$$ to $$$a_i - a_{i-1}$$$. Is it possible to make $$$a_i=0$$$ for all $$$2le ile n$$$? Input The input c...
800
true
true
false
false
false
false
false
false
false
false
2,028
331D1
Don't put up with what you're sick of! The Smart Beaver decided to escape from the campus of Beaver Science Academy (BSA). BSA is a _b_u2009×u2009_b_ square on a plane. Each point _x_,u2009_y_ (0u2009≤u2009_x_,u2009_y_u2009≤u2009_b_) belongs to BSA. To make the path quick and funny, the Beaver constructed a Beaveractor...
2,400
false
false
true
false
false
false
false
false
false
false
8,515
2031B
Penchick and his friend Kohane are touring Indonesia, and their next stop is in Surabaya! In the bustling food stalls of Surabaya, Kohane bought $$$n$$$ satay sticks and arranged them in a line, with the $$$i$$$-th satay stick having length $$$p_i$$$. It is given that $$$p$$$ is a permutation$$$^{ ext{∗}}$$$ of length ...
900
false
true
false
false
false
false
true
false
true
false
79
1625A
Martian scientists explore Ganymede, one of Jupiter's numerous moons. Recently, they have found ruins of an ancient civilization. The scientists brought to Mars some tablets with writings in a language unknown to science. They found out that the inhabitants of Ganymede used an alphabet consisting of two letters, and ea...
800
true
true
false
false
false
false
false
false
false
false
2,493
1624B
Polycarp has $$$3$$$ positive integers $$$a$$$, $$$b$$$ and $$$c$$$. He can perform the following operation exactly once. Choose a positive integer $$$m$$$ and multiply exactly one of the integers $$$a$$$, $$$b$$$ or $$$c$$$ by $$$m$$$. Can Polycarp make it so that after performing the operation, the sequence of three...
900
true
false
true
false
false
false
false
false
false
false
2,499
1178C
Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factorxa0—xa0a square tile that is diagonally split into white and black part as depicted in the figure below. The dimension of this tile is perfect for this kitchen, as he will...
1,300
true
true
false
false
false
false
false
false
false
false
4,828
1974D
Let's imagine the surface of Mars as an infinite coordinate plane. Initially, the rover Perseverance-2 and the helicopter Ingenuity-2 are located at the point with coordinates $$$(0, 0)$$$. A set of instructions $$$s$$$ consisting of $$$n$$$ instructions of the following types was specially developed for them: N: move...
1,400
false
true
true
false
false
true
false
false
false
false
446
1039C
The Metropolis computer network consists of $$$n$$$ servers, each has an encryption key in the range from $$$0$$$ to $$$2^k - 1$$$ assigned to it. Let $$$c_i$$$ be the encryption key assigned to the $$$i$$$-th server. Additionally, $$$m$$$ pairs of servers are directly connected via a data communication channel. Becaus...
2,200
true
false
false
false
false
false
false
false
true
true
5,500
1183F
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $$$n$$$ problems and should choose at most three of them into this contest. The prettiness of the $$$i$$$-th problem is $$$a_i$$$. The authors have to compose the most pretty contest (in other...
2,100
true
false
false
false
false
false
true
false
true
false
4,797
1286F
To defeat Lord Voldemort, Harry needs to destroy all horcruxes first. The last horcrux is an array $$$a$$$ of $$$n$$$ integers, which also needs to be destroyed. The array is considered destroyed if all its elements are zeroes. To destroy the array, Harry can perform two types of operations: 1. choose an index $$$i$$$ ...
3,100
true
false
true
true
false
true
true
false
false
false
4,255
930B
Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string _s_, consisting of small English letters, and uniformly at random chooses an integer _k_ from a segment [0,u2009_len_(_s_)u2009-u20091]. He tells Vasya this string _s_, and then shifts it _k_ letters to the left, i.x...
1,600
false
false
true
false
false
false
false
false
false
false
5,985
125C
Problem - 125C - Codeforces =============== xa0 that would last for several days. Next day the hobbits wrote a guest list, some non-empty set containing all the inhabitants of the Shire. To ensure that everybody enjoy themselves and nobody gets bored, for any two days (say, days A and B) of the GP there exist...
1,600
false
true
false
false
false
true
false
false
false
false
9,380
1254C
This is an interactive problem. Khanh has $$$n$$$ points on the Cartesian plane, denoted by $$$a_1, a_2, ldots, a_n$$$. All points' coordinates are integers between $$$-10^9$$$ and $$$10^9$$$, inclusive. No three points are collinear. He says that these points are vertices of a convex polygon; in other words, there exi...
2,300
true
false
false
false
false
true
false
false
false
false
4,413
178A3
The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of _n_ non-negative integers _a__i_ numbered from 1 to _n_. The goal of the game is to make numbers _a_1,u2009_a_2,u2009...,u2009_a__k_ (i.e....
1,100
false
true
false
false
false
false
false
false
false
false
9,138
643E
Limak is a little grizzly bear. He will once attack Deerland but now he can only destroy trees in role-playing games. Limak starts with a tree with one vertex. The only vertex has index 1 and is a root of the tree. Sometimes, a game chooses a subtree and allows Limak to attack it. When a subtree is attacked then each o...
2,700
true
false
false
true
false
false
false
false
false
false
7,240
616F
Problem - 616F - Codeforces =============== xa0 over all strings. Note that the string _s_ is not necessarily some string from _t_. Input The first line contains the only integer _n_ (1u2009≤u2009_n_u2009≤u2009105) — the number of strings in _t_. Each of the next _n_ lines contains contains a non-empty st...
2,700
false
false
false
false
true
false
false
false
true
false
7,370
1213F
Authors have come up with the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. You are given two permutations of its indices (not necessary equal) $$$p$$$ and $$$q$$$ (both of length $$$n$$$). Recall that the permutation is the array of length $$$n$$$ which contains each integer from $$$1$$$ to $$$n$$$ exa...
2,100
false
true
true
false
true
false
false
false
false
true
4,613
755C
PolandBall lives in a forest with his family. There are some trees in the forest. Trees are undirected acyclic graphs with _k_ vertices and _k_u2009-u20091 edges, where _k_ is some integer. Note that one vertex is a valid tree. There is exactly one relative living in each vertex of each tree, they have unique ids from ...
1,300
false
false
false
false
false
false
false
false
false
true
6,775
2001B
There is an integer sequence $$$a$$$ of length $$$n$$$, where each element is initially $$$-1$$$. Misuki has two typewriters where the first one writes letters from left to right, with a pointer initially pointing to $$$1$$$, and another writes letters from right to left with a pointer initially pointing to $$$n$$$. Mi...
800
false
false
false
false
false
true
false
false
false
false
254
1909F2
In the easy version, the $$$a_i$$$ are in the range $$$[0, n]$$$; in the hard version, the $$$a_i$$$ are in the range $$$[-1, n]$$$ and the definition of good permutation is slightly different. You can make hacks only if all versions of the problem are solved. You are given an integer $$$n$$$ and an array $$$a_1, a_2, ...
2,500
true
false
false
true
false
false
false
false
false
false
851
1805F1
This is the easy version of the problem. It differs from the hard one only in constraints on $$$n$$$. You can make hacks only if you lock both versions. Let $$$a_1, a_2, ldots, a_n$$$ be an array of non-negative integers. Let $$$F(a_1, a_2, ldots, a_n)$$$ be the sorted in the non-decreasing order array of $$$n - 1$$$ s...
2,600
true
false
true
false
false
false
true
true
true
false
1,444
1482A
Michael is accused of violating the social distancing rules and creating a risk of spreading coronavirus. He is now sent to prison. Luckily, Michael knows exactly what the prison looks like from the inside, especially since it's very simple. The prison can be represented as a rectangle $$$a imes b$$$ which is divided i...
800
true
false
false
false
false
false
false
false
false
false
3,267
1140E
Problem - 1140E - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - ...
2,200
false
false
false
true
false
false
false
false
false
false
5,024
1872A
You have two vessels with water. The first vessel contains $$$a$$$ grams of water, and the second vessel contains $$$b$$$ grams of water. Both vessels are very large and can hold any amount of water. You also have an empty cup that can hold up to $$$c$$$ grams of water. In one move, you can scoop up to $$$c$$$ grams of...
800
true
true
false
false
false
false
true
false
false
false
1,051
1905D
For an array $$$a$$$, define its cost as $$$sum_{i=1}^{n} operatorname{mex} ^dagger ([a_1,a_2,ldots,a_i])$$$. You are given a permutation$$$^ddagger$$$ $$$p$$$ of the set $$${0,1,2,ldots,n-1}$$$. Find the maximum cost across all cyclic shifts of $$$p$$$. $$$^daggeroperatorname{mex}([b_1,b_2,ldots,b_m])$$$ is the smalle...
2,000
true
false
true
false
true
false
false
false
false
false
880
1666J
Julia's $$$n$$$ friends want to organize a startup in a new country they moved to. They assigned each other numbers from 1 to $$$n$$$ according to the jobs they have, from the most front-end tasks to the most back-end ones. They also estimated a matrix $$$c$$$, where $$$c_{ij} = c_{ji}$$$ is the average number of messa...
2,100
false
false
false
true
false
true
false
false
false
false
2,276
1149A
We're giving away nice huge bags containing number tiles! A bag we want to present to you contains $$$n$$$ tiles. Each of them has a single number written on itxa0— either $$$1$$$ or $$$2$$$. However, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the bag ...
1,200
true
true
false
false
false
true
false
false
false
false
4,969
1133C
You are a coach at your local university. There are $$$n$$$ students under your supervision, the programming skill of the $$$i$$$-th student is $$$a_i$$$. You have to create a team for a new programming competition. As you know, the more students some team has the more probable its victory is! So you have to create a t...
1,200
false
false
false
false
false
false
false
false
true
false
5,052
1766E
For a sequence of integers $$$[x_1, x_2, dots, x_k]$$$, let's define its decomposition as follows: Process the sequence from the first element to the last one, maintaining the list of its subsequences. When you process the element $$$x_i$$$, append it to the end of the first subsequence in the list such that the bitwis...
2,300
false
false
false
true
true
false
true
true
false
false
1,699
1506G
You are given a string $$$s$$$, consisting of lowercase Latin letters. While there is at least one character in the string $$$s$$$ that is repeated at least twice, you perform the following operation: you choose the index $$$i$$$ ($$$1 le i le s$$$) such that the character at position $$$i$$$ occurs at least two times...
2,000
false
true
false
true
true
false
true
false
false
false
3,137
1361A
Today Johnny wants to increase his contribution. His plan assumes writing $$$n$$$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because otherwise, the re...
1,700
false
true
false
false
false
true
false
false
true
true
3,877
100A
Problem - 100A - Codeforces =============== xa0 . Output Write a single YES or NO. Write YES if and only if Sorush can carpet his room completely. Examples Input 10 4 6 Output YES Input 10 2 5 Output NO
1,100
false
false
true
false
false
false
false
false
false
false
9,489
1155F
The whole delivery market of Berland is controlled by two rival companies: BerEx and BerPS. They both provide fast and reliable delivery services across all the cities of Berland. The map of Berland can be represented as an undirected graph. The cities are vertices and the roads are edges between them. Each pair of cit...
2,800
false
false
false
true
false
false
true
false
false
true
4,931
1924B
There are $$$n$$$ points numbered $$$1$$$ to $$$n$$$ on a straight line. Initially, there are $$$m$$$ harbours. The $$$i$$$-th harbour is at point $$$X_i$$$ and has a value $$$V_i$$$. It is guaranteed that there are harbours at the points $$$1$$$ and $$$n$$$. There is exactly one ship on each of the $$$n$$$ points. The...
2,100
true
false
true
false
true
false
false
false
true
false
745
1032E
You have a set of $$$n$$$ weights. You know that their masses are $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ grams, but you don't know which of them has which mass. You can't distinguish the weights. However, your friend does know the mass of each weight. You can ask your friend to give you exactly $$$k$$$ weights with the t...
2,100
true
false
false
true
false
false
false
false
false
false
5,538
439A
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited. Devu has provided organizers a list of the songs and required time for singing them. He will sing _n_ songs, _i__th_ so...
900
false
true
true
false
false
false
false
false
false
false
8,084
1764G1
The only difference between this problem and the other two versions is the maximum number of queries. In this version, you are allowed to ask at most $$$mathbf{30}$$$ queries. You can make hacks only if all versions of the problem are solved. This is an interactive problem. "Everybody! Doremy's Perfect Data Structure C...
2,900
false
false
false
false
false
false
false
true
false
false
1,721
1236B
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are $$$n$$$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of differe...
1,500
true
false
false
false
false
false
false
false
false
false
4,517
1783E
Monocarp and Polycarp are playing a computer game. This game features $$$n$$$ bosses for the playing to kill, numbered from $$$1$$$ to $$$n$$$. They will fight each boss the following way: Monocarp makes $$$k$$$ attempts to kill the boss; Polycarp makes $$$k$$$ attempts to kill the boss; Monocarp makes $$$k$$$ attem...
2,300
true
false
false
false
true
false
true
false
false
false
1,575
1670E
After the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of his team "Hemose 3al shagra" (Hemose on the tree). You are given a tree of $$$n$$$ vertices where $$$n$$$ is a power of $$$2$...
2,200
false
false
false
false
false
true
false
false
false
false
2,253
1731B
Demodogs from the Upside-down have attacked Hawkins again. El wants to reach Mike and also kill as many Demodogs in the way as possible. Hawkins can be represented as an $$$n imes n$$$ grid. The number of Demodogs in a cell at the $$$i$$$-th row and the $$$j$$$-th column is $$$i cdot j$$$. El is at position $$$(1, 1)$...
1,100
true
true
false
false
false
false
false
false
false
false
1,904
1677E
Tokitsukaze has a permutation $$$p$$$ of length $$$n$$$. Let's call a segment $$$[l,r]$$$ beautiful if there exist $$$i$$$ and $$$j$$$ satisfying $$$p_i cdot p_j = max{p_l, p_{l+1}, ldots, p_r }$$$, where $$$l leq i < j leq r$$$. Now Tokitsukaze has $$$q$$$ queries, in the $$$i$$$-th query she wants to know how many be...
2,900
false
false
false
false
true
false
false
false
false
false
2,202
1068C
Ivan is a novice painter. He has $$$n$$$ dyes of different colors. He also knows exactly $$$m$$$ pairs of colors which harmonize with each other. Ivan also enjoy playing chess. He has $$$5000$$$ rooks. He wants to take $$$k$$$ rooks, paint each of them in one of $$$n$$$ colors and then place this $$$k$$$ rooks on a che...
1,700
false
false
false
false
false
true
false
false
false
true
5,368
1214C
Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself. To make everything right, Petya is going to move at most one bracket from its...
1,200
false
true
false
false
true
false
false
false
false
false
4,609
1805C
The universe is a coordinate plane. There are $$$n$$$ space highways, each of which is a straight line $$$y=kx$$$ passing through the origin $$$(0, 0)$$$. Also, there are $$$m$$$ asteroid belts on the plane, which we represent as open upwards parabolas, i.xa0e. graphs of functions $$$y=ax^2+bx+c$$$, where $$$a > 0$$$. ...
1,400
true
false
false
false
true
false
false
true
false
false
1,447
666B
A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will entirely hold the world tour in his native country — Berland. Cicasso is very devoted to...
2,000
false
false
false
false
false
false
false
false
false
true
7,154
1265B
You are given a permutation $$$p=[p_1, p_2, ldots, p_n]$$$ of integers from $$$1$$$ to $$$n$$$. Let's call the number $$$m$$$ ($$$1 le m le n$$$) beautiful, if there exists two indices $$$l, r$$$ ($$$1 le l le r le n$$$), such that the numbers $$$[p_l, p_{l+1}, ldots, p_r]$$$ is a permutation of numbers $$$1, 2, ldots,...
1,300
true
false
true
false
true
false
false
false
false
false
4,373
513E1
You are given an array of length _n_ and a number _k_. Let's pick _k_ non-overlapping non-empty subarrays of the initial array. Let _s__i_ be the sum of the _i_-th subarray in order from left to right. Compute the maximum value of the following expression: _s_1u2009-u2009_s_2u2009+u2009_s_2u2009-u2009_s_3u2009+u2009......
2,600
false
false
false
true
false
false
false
false
false
false
7,787
1223C
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have $$$n$$$ tickets to sell. The price of the $$$i$$$-th ticket is $$$p_i$$$. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a...
1,600
false
true
false
false
false
false
false
true
false
false
4,557
1345B
A card pyramid of height $$$1$$$ is constructed by resting two cards against each other. For $$$h>1$$$, a card pyramid of height $$$h$$$ is constructed by placing a card pyramid of height $$$h-1$$$ onto a base. A base consists of $$$h$$$ pyramids of height $$$1$$$, and $$$h-1$$$ cards on top. For example, card pyramids...
1,100
true
false
false
true
false
false
true
true
false
false
3,980
1146H
Problem - 1146H - Codeforces =============== xa0 ]( "Forethought Future Cup") xa0— the number of points. Each of the next $$$n$$$ lines contains two integers $$$x_i, y_i$$$ ($$$-10^6 leq x_i,y_i leq 10^6$$$)xa0— the coordinates of the $$$i$$$-th point. It is guaranteed that no three points are collinear. O...
2,900
false
false
false
true
false
false
false
false
false
false
4,984
386D
You are playing the following game. There are _n_ points on a plane. They are the vertices of a regular _n_-polygon. Points are labeled with integer numbers from 1 to _n_. Each pair of distinct points is connected by a diagonal, which is colored in one of 26 colors. Points are denoted by lowercase English letters. Ther...
2,100
false
false
true
true
false
false
false
false
false
true
8,283
1184A1
Problem - 1184A1 - 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,200
true
false
false
false
false
false
true
false
false
false
4,794
1765I
The black king lives on a chess board with an infinite number of columns (files) and $$$8$$$ rows (ranks). The columns are numbered with all integer numbers (including negative). The rows are numbered from $$$1$$$ toxa0$$$8$$$. Initially, the black king is located on the starting square $$$(x_s, y_s)$$$, and he needs t...
2,800
false
false
true
false
false
false
false
false
false
false
1,709
1332D
Bob is playing a game named "Walk on Matrix". In this game, player is given an $$$n imes m$$$ matrix $$$A=(a_{i,j})$$$, i.e. the element in the $$$i$$$-th row in the $$$j$$$-th column is $$$a_{i,j}$$$. Initially, player is located at position $$$(1,1)$$$ with score $$$a_{1,1}$$$. To reach the goal, position $$$(n,m)$$...
1,700
true
false
false
false
false
true
false
false
false
false
4,047
1965C
You have a strip of paper with a binary string $$$s$$$ of length $$$n$$$. You can fold the paper in between any pair of adjacent digits. A set of folds is considered valid if after the folds, all characters that are on top of or below each other match. Note that all folds are made at the same time, so the characters do...
2,300
false
true
false
false
false
true
false
false
false
false
514
1326F1
This is the easy version of the problem. The difference is constraints on the number of wise men and the time limit. You can make hacks only if all versions of this task are solved. $$$n$$$ wise men live in a beautiful city. Some of them know each other. For each of the $$$n!$$$ possible permutations $$$p_1, p_2, ldots...
2,600
false
false
false
true
false
false
true
false
false
false
4,081
1427F
When they are bored, Federico and Giada often play the following card game with a deck containing $$$6n$$$ cards. Each card contains one number between $$$1$$$ and $$$6n$$$ and each number appears on exactly one card. Initially the deck is sorted, so the first card contains the number $$$1$$$, the second card contains ...
3,200
false
true
false
false
true
false
false
false
false
false
3,528
901E
Senor Vorpal Kickass'o invented an innovative method to encrypt integer sequences of length _n_. To encrypt a sequence, one has to choose a secret sequence , that acts as a key. Vorpal is very selective, so the key should be such a sequence _b__i_, that its cyclic shifts are linearly independent, that is, there is no n...
3,300
true
false
false
false
false
false
false
false
false
false
6,137
1692G
Given an array $$$a$$$ of length $$$n$$$ and an integer $$$k$$$, find the number of indices $$$1 leq i leq n - k$$$ such that the subarray $$$[a_i, dots, a_{i+k}]$$$ with length $$$k+1$$$ (not with length $$$k$$$) has the following property: If you multiply the first element by $$$2^0$$$, the second element by $$$2^1$...
1,400
false
false
false
true
true
false
false
false
true
false
2,124
1081E
Chouti is working on a strange math problem. There was a sequence of $$$n$$$ positive integers $$$x_1, x_2, ldots, x_n$$$, where $$$n$$$ is even. The sequence was very special, namely for every integer $$$t$$$ from $$$1$$$ to $$$n$$$, $$$x_1+x_2+...+x_t$$$ is a square of some integer number (that is, a . The second lin...
1,900
true
true
false
false
false
true
false
true
false
false
5,319
1627F
There is a $$$k imes k$$$ grid, where $$$k$$$ is even. The square in row $$$r$$$ and column $$$c$$$ is denoted by $$$(r,c)$$$. Two squares $$$(r_1, c_1)$$$ and $$$(r_2, c_2)$$$ are considered adjacent if $$$lvert r_1 - r_2 vert + lvert c_1 - c_2 vert = 1$$$. An array of adjacent pairs of squares is called strong if ...
2,700
false
true
true
false
false
false
false
false
false
true
2,476
2038F
Suppose you are working in the Ministry of Digital Development of Berland, and your task is to monitor the industry of video blogging. There are $$$n$$$ bloggers in Berland. Recently, due to the poor state of the main video platform in Berland, two alternative platforms were introduced. That's why bloggers started to r...
2,500
true
false
false
false
true
false
false
false
true
false
33
854B
Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has _n_ apartments that are numbered from 1 to _n_ and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale. Maxim often visit...
1,200
true
false
false
false
false
true
false
false
false
false
6,328
649E
Вдоль дороги стоят _n_ путешественников. Дорога представляет собой прямую, размерами путешественников можно пренебречь, считая их точками. Водитель автобуса Василий, благодаря мобильному приложению, знает для каждого путешественника точку _x__i_, в которой тот стоит. Кроме того, он знает расстояние _d__i_, которое _i_-...
2,100
false
true
false
false
true
false
false
true
true
false
7,218
40D
Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the moment when the first two people came to that land (it is considered to have happened in the first year). A...
2,600
true
false
false
false
false
false
false
false
false
false
9,786
1472F
Every year Santa Claus gives gifts to all children. However, each country has its own traditions, and this process takes place in different ways. For example, in Berland you need to solve the New Year's puzzle. Polycarp got the following problem: given a grid strip of size $$$2 imes n$$$, some cells of it are blocked....
2,100
false
true
false
true
false
false
true
false
true
false
3,319
1851G
Vlad decided to go on a trip to the mountains. He plans to move between $$$n$$$ mountains, some of which are connected by roads. The $$$i$$$-th mountain has a height of $$$h_i$$$. If there is a road between mountains $$$i$$$ and $$$j$$$, Vlad can move from mountain $$$i$$$ to mountain $$$j$$$ by spending $$$h_j - h_i$$...
2,000
false
false
true
false
true
false
false
true
true
true
1,168
1445A
You are given two arrays $$$a$$$ and $$$b$$$, each consisting of $$$n$$$ positive integers, and an integer $$$x$$$. Please determine if one can rearrange the elements of $$$b$$$ so that $$$a_i + b_i leq x$$$ holds for each $$$i$$$ ($$$1 le i le n$$$). Input The first line of input contains one integer $$$t$$$ ($$$1 leq...
800
false
true
false
false
false
false
false
false
true
false
3,449
2023D
Recently, you received a rare ticket to the only casino in the world where you can actually earn something, and you want to take full advantage of this opportunity. The conditions in this casino are as follows: There are a total of $$$n$$$ games in the casino. You can play each game at most once. Each game is charac...
2,900
true
true
false
true
false
false
true
false
false
false
128
587F
Duff is mad at her friends. That's why she sometimes makes Malek to take candy from one of her friends for no reason! She has _n_ friends. Her _i_-th friend's name is _s__i_ (their names are not necessarily unique). _q_ times, she asks Malek to take candy from her friends. She's angry, but also she acts with rules. Whe...
3,000
false
false
false
false
true
false
false
false
false
false
7,492
477E
Dreamoon has just created a document of hard problems using notepad.exe. The document consists of _n_ lines of text, _a__i_ denotes the length of the _i_-th line. He now wants to know what is the fastest way to move the cursor around because the document is really long. Let (_r_,u2009_c_) be a current cursor position, ...
3,100
false
false
false
false
true
false
false
false
false
false
7,922
1206B
You are given $$$n$$$ numbers $$$a_1, a_2, dots, a_n$$$. With a cost of one coin you can perform the following operation: Choose one of these numbers and add or subtract $$$1$$$ from it. In particular, we can apply this operation to the same number several times. We want to make the product of all these numbers equal t...
900
false
false
true
true
false
false
false
false
false
false
4,662
567C
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer _k_ and a sequence _a_, consisting of _n_ integers. He wants to know how many subsequences of length three can be selected from _a_, so that they form a geom...
1,700
false
false
false
true
true
false
false
true
false
false
7,582
35E
No Great Victory anniversary in Berland has ever passed without the war parade. This year is not an exception. That’s why the preparations are on in full strength. Tanks are building a line, artillery mounts are ready to fire, soldiers are marching on the main square... And the air forces general Mr. Generalov is in tr...
2,100
false
false
false
false
true
false
false
false
true
false
9,819
1634A
Real stupidity beats artificial intelligence every time. — Terry Pratchett, Hogfather, Discworld You are given a string $$$s$$$ of length $$$n$$$ and a number $$$k$$$. Let's denote by $$$rev(s)$$$ the reversed string $$$s$$$ (i.e. $$$rev(s) = s_n s_{n-1} ... s_1$$$). You can apply one of the two kinds of operations to ...
800
false
true
false
false
false
false
false
false
false
false
2,446
731E
Once upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They have only stickers and markers, but that won't stop them. The game they came up with has the following rules. Ini...
2,200
false
false
false
true
false
false
false
false
false
false
6,872
1773H
This is an interactive problem. After emigrating to another country, little Hanna came across the fact that playing "Hot and cold" became more difficult: she does not understand the hint phrases! You are to write a helping program for her. The playground where the game happens is a rectangle, and the treasure is hidden...
2,600
false
false
false
false
false
false
false
true
false
false
1,649
188B
Problem - 188B - Codeforces =============== xa0 , separated by a single space. The numbers are given without leading zeros. Output Output the sum of _a_ and reverse of _b_. Examples Input 5 15 Output 56 Input 73 9180 Output 892
1,300
false
false
true
false
false
false
false
false
false
false
9,091
1423H
In Bubbleland a group of special programming forces gets a top secret job to calculate the number of potentially infected people by a new unknown virus. The state has a population of $$$n$$$ people and every day there is new information about new contacts between people. The job of special programming forces is to calc...
2,500
false
false
false
false
true
false
false
false
false
true
3,556
1941E
Bernard loves visiting Rudolf, but he is always running late. The problem is that Bernard has to cross the river on a ferry. Rudolf decided to help his friend solve this problem. The river is a grid of $$$n$$$ rows and $$$m$$$ columns. The intersection of the $$$i$$$-th row and the $$$j$$$-th column contains the number...
1,600
false
false
false
true
true
false
false
true
false
false
635
1673F
This is an interactive problem. A city has $$$n^2$$$ buildings divided into a grid of $$$n$$$ rows and $$$n$$$ columns. You need to build a road of some length $$$D(A,B)$$$ of your choice between each pair of adjacent by side buildings $$$A$$$ and $$$B$$$. Due to budget limitations and legal restrictions, the length of...
2,400
true
true
false
false
false
true
false
false
false
false
2,230
200A
The capital of Berland has the only movie theater in the country. Besides, it consists of only one room. The room is divided into _n_ rows, each row consists of _m_ seats. There are _k_ people lined up to the box office, each person wants to buy exactly one ticket for his own entertainment. Before the box office starte...
2,400
false
false
false
false
true
false
true
false
false
false
9,044
1795C
A tea manufacturer decided to conduct a massive tea tasting. $$$n$$$ sorts of tea will be tasted by $$$n$$$ tasters. Both the sorts of tea and the tasters are numbered from $$$1$$$ to $$$n$$$. The manufacturer prepared $$$a_i$$$ milliliters of the $$$i$$$-th sort of tea. The $$$j$$$-th taster can drink $$$b_j$$$ millil...
1,500
false
false
true
false
true
false
false
true
false
false
1,507
1101D
You are given a tree consisting of $$$n$$$ vertices. A number is written on each vertex; the number on vertex $$$i$$$ is equal to $$$a_i$$$. Let's denote the function $$$g(x, y)$$$ as the greatest common divisor of the numbers written on the vertices belonging to the simple path from vertex $$$x$$$ to vertex $$$y$$$ (i...
2,000
false
false
false
true
true
false
false
false
false
false
5,197
1320B
The map of Bertown can be represented as a set of $$$n$$$ intersections, numbered from $$$1$$$ to $$$n$$$ and connected by $$$m$$$ one-way roads. It is possible to move along the roads from any intersection to any other intersection. The length of some path from one intersection to another is the number of roads that o...
1,700
false
false
false
false
false
false
false
false
false
true
4,114
700B
Treeland is a country in which there are _n_ towns connected by _n_u2009-u20091 two-way road such that it's possible to get from any town to any other town. In Treeland there are 2_k_ universities which are located in different towns. Recently, the president signed the decree to connect universities by high-speed netwo...
1,800
false
false
false
true
false
false
false
false
false
true
7,024
162A
Problem - 162A - Codeforces =============== xa0 u2009/u20092 (always integer). You are given _n_; calculate _n_-th pentagonal number. Input The only line of input contains an integer _n_ (1u2009≤u2009_n_u2009≤u2009100). Output Output the _n_-th pentagonal number. Examples Input 2 Output 5 Input 5 O...
1,100
false
false
true
false
false
false
false
false
false
false
9,225
868A
As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters. Mu-mu's enemy Kashtanka wants to unlock Mu-mu's ph...
900
false
false
true
false
false
false
true
false
false
false
6,273