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
1971E
Timur is in a car traveling on the number line from point $$$0$$$ to point $$$n$$$. The car starts moving from point $$$0$$$ at minute $$$0$$$. There are $$$k+1$$$ signs on the line at points $$$0, a_1, a_2, dots, a_k$$$, and Timur knows that the car will arrive there at minutes $$$0, b_1, b_2, dots, b_k$$$, respective...
1,500
true
false
false
false
false
false
false
true
true
false
461
1622E
Petya is a math teacher. $$$n$$$ of his students has written a test consisting of $$$m$$$ questions. For each student, it is known which questions he has answered correctly and which he has not. If the student answers the $$$j$$$-th question correctly, he gets $$$p_j$$$ points (otherwise, he gets $$$0$$$ points). Moreo...
2,200
false
true
false
false
false
false
true
false
false
false
2,507
1360H
# Binary Median Input file: standard input Output file: standard output Time limit: 2 seconds Memory limit: 256 megabytes Consider all binary strings of length m (1 ≤ m ≤ 60 ). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously...
2,100
false
false
false
false
false
true
true
true
false
false
3,878
739C
Alyona has built _n_ towers by putting small cubes some on the top of others. Each cube has size 1u2009×u20091u2009×u20091. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row. Sometimes Alyona chooses some segment towers, and put on the top of each ...
2,500
false
false
false
false
true
false
false
false
false
false
6,841
317D
Problem - 317D - 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,300
false
false
false
true
false
false
false
false
false
false
8,562
1461E
In recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point of his distraction was to maintain a water level in the water cooler used by other zebras. Original...
2,200
true
true
true
false
false
false
true
false
false
true
3,382
1819A
As you know, any problem that does not require the use of complex data structures is considered constructive. You are offered to solve one of such problems. You are given an array $$$a$$$ of $$$n$$$ non-negative integers. You are allowed to perform the following operation exactly once: choose some non-empty subsegment ...
1,300
false
true
false
false
false
false
true
false
false
false
1,365
446D
Today DZY begins to play an old game. In this game, he is in a big maze with _n_ rooms connected by _m_ corridors (each corridor allows to move in both directions). You can assume that all the rooms are connected with corridors directly or indirectly. DZY has got lost in the maze. Currently he is in the first room and ...
2,800
true
false
false
false
false
false
false
false
false
false
8,053
1184C1
The Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying everything they encounter. However, a little-known fact about them is that they both also love taking Turing tests! Heidi designed a series of increasingly difficult tasks for them to spend thei...
1,600
false
false
true
false
false
false
false
false
false
false
4,788
1408B
You are given a non-decreasing array of non-negative integers $$$a_1, a_2, ldots, a_n$$$. Also you are given a positive integer $$$k$$$. You want to find $$$m$$$ non-decreasing arrays of non-negative integers $$$b_1, b_2, ldots, b_m$$$, such that: The size of $$$b_i$$$ is equal to $$$n$$$ for all $$$1 leq i leq m$$$. ...
1,400
true
true
false
false
false
true
false
false
false
false
3,635
1672B
Let's call a string good if its length is at least $$$2$$$ and all of its characters are $$$ exttt{A}$$$ except for the last character which is $$$ exttt{B}$$$. The good strings are $$$ exttt{AB}, exttt{AAB}, exttt{AAAB},ldots$$$. Note that $$$ exttt{B}$$$ is not a good string. You are given an initially empty string $...
800
false
false
true
false
false
true
false
false
false
false
2,244
612E
Problem - 612E - Codeforces =============== xa0 ]( "Educational Codeforces Round 4") — the number of elements in permutation _p_. The second line contains _n_ distinct integers _p_1,u2009_p_2,u2009...,u2009_p__n_ (1u2009≤u2009_p__i_u2009≤u2009_n_) — the elements of permutation _p_. Output If there is no pe...
2,200
true
false
false
false
false
true
false
false
false
true
7,389
1567C
Alice has just learned addition. However, she hasn't learned the concept of "carrying" fullyxa0— instead of carrying to the next column, she carries to the column two columns to the left. For example, the regular way to evaluate the sum $$$2039 + 2976$$$ would be as shown: However, Alice evaluates it as shown: In parti...
1,600
true
false
false
true
false
false
false
false
false
false
2,802
1279A
Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands. The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them a...
900
true
false
false
false
false
false
false
false
false
false
4,300
1260A
Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house. Your house has $$$n$$$ rooms. In the $$$i$$$-th room you can install at most $$$c_i$$$ heating radiators. Each radiator can have sever...
1,000
true
false
false
false
false
false
false
false
false
false
4,394
1750C
You have two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$. You would like to make all the elements of both strings equal to $$$0$$$. Unfortunately, you can modify the contents of these strings using only the following operation: You choose two indices $$$l$$$ and $$$r$$$ ($$$1 le l le r le n$$$); For every $$...
1,400
false
false
true
false
false
true
false
false
false
false
1,783
607B
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of _n_ gemstones, the _i_-th of which has color _c__i_. The goal of the game is to destroy all the gemstones in the line as quickly as possible. In one second, Genos is able to choose exactly one continuous substring of colored gemstones t...
1,900
false
false
false
true
false
false
false
false
false
false
7,418
48D
A permutation is a sequence of integers from 1 to _n_ of length _n_ containing each number exactly once. For example, (1), (4,u20093,u20095,u20091,u20092), (3,u20092,u20091) are permutations, and (1,u20091), (4,u20093,u20091), (2,u20093,u20094) are not. There are many tasks on permutations. Today you are going to solve...
1,500
false
true
false
false
false
false
false
false
false
false
9,734
484C
How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... Let's have a look at another specific order: _d_-sorting. This sorting is applied to the strings of length at least _d_, where _d_ is some positive integer. The characters of the string ...
2,600
true
false
true
false
false
false
false
false
false
false
7,900
865C
You're trying to set the record on your favorite video game. The game consists of _N_ levels, which must be completed sequentially in order to beat the game. You usually complete each level as fast as possible, but sometimes finish a level slower. Specifically, you will complete the _i_-th level in either _F__i_ second...
2,400
false
false
false
true
false
false
false
true
false
false
6,279
581F
It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on _n_ main squares of the capital of Berland. Each of the _n_ squares certainly can have demonstrations of only one party, otherwise it could lead to r...
2,400
false
false
false
true
false
false
false
false
false
false
7,518
993A
You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect. The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the t...
1,600
false
false
true
false
false
false
false
false
false
false
5,734
1748D
You are given three integers $$$a$$$, $$$b$$$, and $$$d$$$. Your task is to find any integer $$$x$$$ which satisfies all of the following conditions, or determine that no such integers exist: $$$0 le x lt 2^{60}$$$; $$$ax$$$ is divisible by $$$d$$$; $$$bx$$$ is divisible by $$$d$$$. Here, $$$$$$ denotes the xa0— the...
2,100
true
false
false
false
false
true
false
false
false
false
1,794
455A
Problem - 455A - 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
false
false
true
false
false
false
false
false
false
8,019
287A
In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4u2009×u20094 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that...
1,100
false
false
true
false
false
false
true
false
false
false
8,686
1364E
2,700
false
false
false
false
false
true
false
false
false
false
3,858
1983C
Alice, Bob and Charlie want to share a rectangular cake cut into $$$n$$$ pieces. Each person considers every piece to be worth a different value. The $$$i$$$-th piece is considered to be of value $$$a_i$$$ by Alice, $$$b_i$$$ by Bob and $$$c_i$$$ by Charlie. The sum over all $$$a_i$$$, all $$$b_i$$$ and all $$$c_i$$$ i...
1,400
false
true
true
false
false
false
true
true
false
false
388
11A
Problem - 11A - Codeforces =============== xa0 ]( "Codeforces Beta Round #11") . The second line contains space separated sequence _b_0,u2009_b_1,u2009...,u2009_b__n_u2009-u20091 (1u2009≤u2009_b__i_u2009≤u2009106). Output Output the minimal number of moves needed to make the sequence increasing. Examples Input...
900
true
false
true
false
false
true
false
false
false
false
9,940
808A
Problem - 808A - Codeforces =============== xa0 ]( "52010") — current year in Berland. Output Output amount of years from the current year to the next lucky one. Examples Input 4 Output 1 Input 201 Output 99 Input 4000 Output 1000 Note In the first example next lucky year is 5. In the second one ...
900
false
false
true
false
false
false
false
false
false
false
6,535
946B
Problem - 946B - 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
true
false
false
false
false
false
false
false
false
false
5,931
831B
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet. You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts in...
800
false
false
true
false
false
false
false
false
false
false
6,441
1089A
Alice is a big fan of volleyball and especially of the very strong "Team A". Volleyball match consists of up to five sets. During each set teams score one point for winning axa0ball. The first four sets are played until one of the teams scores at least 25xa0points and the fifth set is played until one of the teams scor...
2,200
false
false
false
true
false
false
false
false
false
false
5,285
1157C2
The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2). You are given a sequence $$$a$$$ consisting of $$$n$$$ integers. You are making a sequence of moves. During each move you must take either the leftmost element of the seque...
1,700
false
true
false
false
false
false
false
false
false
false
4,920
2021C1
This is the easy version of the problem. In the two versions, the constraints on $$$q$$$ and the time limit are different. In this version, $$$q=0$$$. You can make hacks only if all the versions of the problem are solved. A team consisting of $$$n$$$ members, numbered from $$$1$$$ to $$$n$$$, is set to present a slide ...
1,300
false
true
false
false
false
true
false
false
false
false
144
1088E
You're given a tree consisting of $$$n$$$ nodes. Every node $$$u$$$ has a weight $$$a_u$$$. You want to choose an integer $$$k$$$ $$$(1 le k le n)$$$ and then choose $$$k$$$ connected components of nodes that don't overlap (i.e every node is in at most 1 component). Let the set of nodes you chose be $$$s$$$. You want t...
2,400
true
true
false
true
false
false
false
false
false
false
5,287
1187F
Let $$$x$$$ be an array of integers $$$x = [x_1, x_2, dots, x_n]$$$. Let's define $$$B(x)$$$ as a minimal size of a partition of $$$x$$$ into subsegments such that all elements in each subsegment are equal. For example, $$$B([3, 3, 6, 1, 6, 6, 6]) = 4$$$ using next partition: $$$[3, 3 6 1 6, 6, 6]$$$. Now you don't ...
2,500
true
false
false
true
false
false
false
false
false
false
4,761
72C
Problem - 72C - Codeforces =============== xa0 → 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 - solve these problems in...
1,200
true
false
false
false
false
false
false
false
false
false
9,609
223C
Problem - 223C - 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
true
false
false
false
false
false
false
false
false
false
8,945
1919F1
This is the easy version of the problem. The only difference between the two versions is the constraint on $$$c_i$$$ and $$$z$$$. You can make hacks only if both versions of the problem are solved. There are three arrays $$$a$$$, $$$b$$$ and $$$c$$$. $$$a$$$ and $$$b$$$ have length $$$n$$$ and $$$c$$$ has length $$$n-1...
2,300
false
true
false
false
true
false
false
false
false
false
776
830E
Developer Petr thinks that he invented a perpetual motion machine. Namely, he has a lot of elements, which work in the following way. Each element has one controller that can be set to any non-negative real value. If a controller is set on some value _x_, then the controller consumes _x_2 energy units per second. At th...
3,100
true
false
true
true
false
true
false
false
false
true
6,443
678A
. Output Print the smallest integer _x_u2009>u2009_n_, so it is divisible by the number _k_.
800
true
false
true
false
false
false
false
false
false
false
7,116
1000F
You are given an array $$$a$$$ consisting of $$$n$$$ integers, and $$$q$$$ queries to it. $$$i$$$-th query is denoted by two integers $$$l_i$$$ and $$$r_i$$$. For each query, you have to find any integer that occurs exactly once in the subarray of $$$a$$$ from index $$$l_i$$$ to index $$$r_i$$$ (a subarray is a contigu...
2,400
false
false
false
false
true
false
false
false
false
false
5,700
1458D
You are given a string $$$s$$$ of 0's and 1's. You are allowed to perform the following operation: choose a non-empty contiguous substring of $$$s$$$ that contains an equal number of 0's and 1's; flip all characters in the substring, that is, replace all 0's with 1's, and vice versa; reverse the substring. For examp...
3,100
false
true
false
false
true
false
false
false
false
true
3,391
134A
Problem - 134A - Codeforces =============== xa0 . Input The first line contains the integer _n_ (2u2009≤u2009_n_u2009≤u20092·105). The second line contains elements of the sequence _a_1,u2009_a_2,u2009...,u2009_a__n_ (1u2009≤u2009_a__i_u2009≤u20091000). All the elements are positive integers. Output Print on ...
1,200
false
false
true
false
false
false
true
false
false
false
9,340
1185G1
The only difference between easy and hard versions is constraints. Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly $$$T$$$ minutes. In the player, Polycarp stores $$$n$$$ songs, each o...
2,100
false
false
false
true
false
false
false
false
false
false
4,773
62B
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome! The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac ...
1,800
false
false
true
false
false
false
false
true
false
false
9,664
618C
Cat Noku has obtained a map of the night sky. On this map, he found a constellation with _n_ stars numbered from 1 to _n_. For each _i_, the _i_-th star is located at coordinates (_x__i_,u2009_y__i_). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would l...
1,600
false
false
true
false
false
false
false
false
false
false
7,362
1978A
Alice has $$$n$$$ books. The $$$1$$$-st book contains $$$a_1$$$ pages, the $$$2$$$-nd book contains $$$a_2$$$ pages, $$$ldots$$$, the $$$n$$$-th book contains $$$a_n$$$ pages. Alice does the following: She divides all the books into two non-empty piles. Thus, each book ends up in exactly one of the two piles. Alice r...
800
false
true
false
false
false
true
false
false
true
false
422
2039B
For a string $$$p$$$, let $$$f(p)$$$ be the number of distinct non-empty substrings$$$^{ ext{∗}}$$$ of $$$p$$$. Shohag has a string $$$s$$$. Help him find a non-empty string $$$p$$$ such that $$$p$$$ is a substring of $$$s$$$ and $$$f(p)$$$ is even or state that no such string exists. $$$^{ ext{∗}}$$$A string $$$a$$$ i...
1,000
false
true
true
false
false
true
false
false
false
false
23
1866K
There is a tree of $$$N$$$ vertices and $$$N-1$$$ edges. The $$$i$$$-th edge connects vertices $$$U_i$$$ and $$$V_i$$$ and has a length of $$$W_i$$$. Chaneka, the owner of the tree, asks you $$$Q$$$ times. For the $$$j$$$-th question, the following is the question format: $$$X_j$$$ $$$K_j$$$ – If each edge that contai...
2,500
false
false
true
true
true
false
false
true
false
true
1,078
551E
Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called _GukiZiana_. For given array _a_, indexed with integers from 1 to _n_, and number _y_, _GukiZiana_(_a_,u2009_y_) represents maximum value of _j_u2009-u2009_i_, such that _a__j_u2009=u2009_a__i_u2009=u2009_y_. If ther...
2,500
false
false
true
false
true
false
false
true
false
false
7,628
1063A
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not. A string is called a substring of another string, if it can be obtained from that string by dropping some (possib...
1,300
false
false
false
false
false
true
false
false
false
false
5,396
1615F
After getting bored by playing with crayons, you decided to switch to Legos! Today, you're working with a long strip, with height $$$1$$$ and length $$$n$$$, some positions of which are occupied by $$$1$$$ by $$$1$$$ Lego pieces. In one second, you can either remove two adjacent Lego pieces from the strip (if both are ...
2,800
true
false
false
true
false
false
false
false
false
false
2,559
1585A
Petya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given $$$n$$$ days from Petya's live and you have to determine what happened with his flower in the end. The flower grows as follows: If the flower isn't watered for two days in a row, it dies. If the flower is w...
800
false
false
true
false
false
false
false
false
false
false
2,702
425B
Sereja has an _n_u2009×u2009_m_ rectangular table _a_, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, th...
2,200
false
true
false
false
false
false
false
false
false
false
8,137
1618E
$$$n$$$ towns are arranged in a circle sequentially. The towns are numbered from $$$1$$$ to $$$n$$$ in clockwise order. In the $$$i$$$-th town, there lives a singer with a repertoire of $$$a_i$$$ minutes for each $$$i in [1, n]$$$. Each singer visited all $$$n$$$ towns in clockwise order, starting with the town he live...
1,700
true
false
false
false
false
true
false
false
false
false
2,538
269B
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length. Over the years Emuskald has cultivated _n_ plants in his greenhouse, of _m_ different plant species numbered from 1 to _m_. His greenhouse is very narrow and can be viewed as an infinite line, with each pl...
1,700
false
false
false
true
false
false
false
false
false
false
8,757
2036G
This is an interactive problem. The Department of Supernatural Phenomena at the Oxenfurt Academy has opened the Library of Magic, which contains the works of the greatest sorcerers of Redania — $$$n$$$ ($$$3 leq n leq 10^{18}$$$) types of books, numbered from $$$1$$$ to $$$n$$$. Each book's type number is indicated on ...
2,200
true
false
false
false
false
true
false
true
false
false
46
1528C
Soroush and Keshi each have a labeled and rooted tree on $$$n$$$ vertices. Both of their trees are rooted from vertex $$$1$$$. Soroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to make a memor...
2,300
false
true
false
false
true
false
false
false
false
false
3,021
846C
Problem - 846C - Codeforces =============== xa0 be the sum of all numbers on positions from _l_ to _r_ non-inclusive (_l_-th element is counted, _r_-th element is not counted). For indices _l_ and _r_ holds 0u2009≤u2009_l_u2009≤u2009_r_u2009≤u2009_n_. Indices in array are numbered from 0. For example, if ...
1,800
false
false
false
true
true
false
true
false
false
false
6,375
1418F
Problem - 1418F - 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,000
true
false
false
false
true
false
false
false
false
false
3,589
1491A
You are given an array $$$a$$$ consisting of $$$n$$$ integers. Initially all elements of $$$a$$$ are either $$$0$$$ or $$$1$$$. You need to process $$$q$$$ queries of two kinds: 1 x : Assign to $$$a_x$$$ the value $$$1 - a_x$$$. 2 k : Print the $$$k$$$-th largest value of the array. As a reminder, $$$k$$$-th largest ...
800
false
true
true
false
false
false
true
false
false
false
3,222
1419E
An agent called Cypher is decrypting a message, that contains a $$$xa0— the number of test cases. Next $$$t$$$ lines describe each test case. In a single line of each test case description, there is a single composite number $$$n$$$ $$$(4 le n le 10^9)$$$xa0— the number from the message. It's guaranteed that the total ...
2,100
true
false
true
false
false
true
false
false
false
false
3,582
1194G
Problem - 1194G - 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,700
false
false
false
true
false
false
false
false
false
false
4,730
999C
You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. Polycarp wants to remove exactly $$$k$$$ characters ($$$k le n$$$) from the string $$$s$$$. Polycarp uses the following algorithm $$$k$$$ times: if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, othe...
1,200
false
false
true
false
false
false
false
false
false
false
5,709
2039H2
This is the hard 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
14
1110B
You have a long stick, consisting of $$$m$$$ segments enumerated from $$$1$$$ to $$$m$$$. Each segment is $$$1$$$ centimeter long. Sadly, some segments are broken and need to be repaired. You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken segments....
1,400
false
true
false
false
false
false
false
false
true
false
5,148
1839E
This is an interactive problem. Consider the following game for two players: Initially, an array of integers $$$a_1, a_2, ldots, a_n$$$ of length $$$n$$$ is written on blackboard. Game consists of rounds. On each round, the following happens: The first player selects any $$$i$$$ such that $$$a_i gt 0$$$. If there is...
2,400
false
true
false
true
false
true
false
false
false
false
1,254
616B
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places. Munhattan consists of _n_ streets and _m_ avenues. There is exactly one restaurant on the intersection of each street and avenue. The street...
1,000
false
true
false
false
false
false
false
false
false
false
7,374
1704D
Eric has an array $$$b$$$ of length $$$m$$$, then he generates $$$n$$$ additional arrays $$$c_1, c_2, dots, c_n$$$, each of length $$$m$$$, from the array $$$b$$$, by the following way: Initially, $$$c_i = b$$$ for every $$$1 le i le n$$$. Eric secretly chooses an integer $$$k$$$ $$$(1 le k le n)$$$ and chooses $$$c_k$...
1,900
true
false
true
false
false
true
false
false
false
false
2,052
1599J
Bob really likes playing with arrays of numbers. That's why for his birthday, his friends bought him a really interesting machine – an array beautifier. The array beautifier takes an array $$$A$$$ consisting of $$$N$$$ integers, and it outputs a new array $$$B$$$ of length N that it constructed based on the array given...
2,600
false
true
false
false
false
false
true
false
false
false
2,655
136B
Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the _xor_ operation is performed on this computer (and whether there is anything like ...
1,100
true
false
true
false
false
false
false
false
false
false
9,331
1521A
Nastia has $$$2$$$ positive integers $$$A$$$ and $$$B$$$. She defines that: The integer is good if it is divisible by $$$A cdot B$$$; Otherwise, the integer is nearly good, if it is divisible by $$$A$$$. For example, if $$$A = 6$$$ and $$$B = 4$$$, the integers $$$24$$$ and $$$72$$$ are good, the integers $$$6$$$, $$...
1,000
true
false
false
false
false
true
false
false
false
false
3,055
37C
Problem - 37C - Codeforces =============== xa0 ") — the number of words in Old Berland language. The second line contains _N_ space-separated integers — the lengths of these words. All the lengths are natural numbers not exceeding 1000. Output If there’s no such set of words, in the single line output NO....
1,900
false
true
false
false
true
false
false
false
false
false
9,811
1313C2
This is a harder version of the problem. In this version $$$n le 500,000$$$ The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the ...
1,900
false
true
false
true
true
false
false
false
false
false
4,127
757B
Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases. But Zulu warns him that a group of _k_u2009>u20091 Pokemon with strengths ...
1,400
true
true
false
false
false
false
false
false
false
false
6,763
1863F
You are given an array of $$$n$$$ integers $$$a_1, a_2, ldots, a_n$$$. In one operation you split the array into two parts: a non-empty prefix and a non-empty suffix. The value of each part is the , determine whether it is possible to achieve the state when only the $$$i$$$-th element (with respect to the original numb...
2,600
true
false
false
true
false
false
false
false
false
false
1,101
1320F
Polycarp plays a well-known computer game (we won't mention its name). Every object in this game consists of three-dimensional blocks — axis-aligned cubes of size $$$1 imes 1 imes 1$$$. These blocks are unaffected by gravity, so they can float in the air without support. The blocks are placed in cells of size $$$1 i...
3,500
false
false
false
false
false
false
true
false
false
false
4,110
1497A
You are given an integer $$$n$$$ and an array $$$a_1, a_2, ldots, a_n$$$. You should reorder the elements of the array $$$a$$$ in such way that the sum of $$$ extbf{MEX}$$$ on prefixes ($$$i$$$-th prefix is $$$a_1, a_2, ldots, a_i$$$) is maximized. Formally, you should find an array $$$b_1, b_2, ldots, b_n$$$, such tha...
800
false
true
false
false
true
false
true
false
true
false
3,188
1874B
Jellyfish is given the non-negative integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ and $$$m$$$. Initially $$$(x,y)=(a,b)$$$. Jellyfish wants to do several operations so that $$$(x,y)=(c,d)$$$. For each operation, she can do one of the following: $$$x := x,&,y$$$, $$$x := x,,y$$$, $$$y := x oplus y$$$, $$$y := y oplus ...
2,400
false
false
false
true
false
false
true
false
false
true
1,035
1516B
Baby Ehab is known for his love for a certain operation. He has an array $$$a$$$ of length $$$n$$$, and he decided to keep doing the following operation on it: he picks $$$2$$$ adjacent elements; he then removes them and places a single integer in their place: their xa0— the number of test cases you need to solve. The...
1,500
false
true
false
true
false
false
true
false
false
false
3,081
1491H
Yuezheng Ling gives Luo Tianyi a tree which has $$$n$$$ nodes, rooted at $$$1$$$. Luo Tianyi will tell you that the parent of the $$$i$$$-th node is $$$a_i$$$ ($$$1 leq a_i<i$$$ for $$$2 le i le n$$$), and she will ask you to perform $$$q$$$ queries of $$$2$$$ types: 1. She'll give you three integers $$$l$$$, $$$r$$$ a...
3,400
false
false
false
false
true
false
false
false
false
false
3,215
1424G
During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range $$$(1, 10^9)$$$! Therefore, the planet ...
1,300
false
false
false
false
true
false
false
false
true
false
3,549
785B
Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has _n_ variants when he will attend chess classes, _i_-th variant is given by a period of time (_l_1,u2009_i_,u2009_r_1,u2009_i_). Also he has _m_ variants when he will attend pr...
1,100
false
true
false
false
false
false
false
false
true
false
6,632
754C
Recently Vladik discovered a new entertainmentxa0— coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them. At first, he need to download _t_ chats. Vladik coded a script which should have downloaded the chats, however, something went wron...
2,200
false
false
true
true
false
true
true
false
false
false
6,780
460A
Problem - 460A - 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
8,001
710B
Problem - 710B - Codeforces =============== xa0 — the number of points on the line. The second line contains _n_ integers _x__i_ (u2009-u2009109u2009≤u2009_x__i_u2009≤u2009109) — the coordinates of the given _n_ points. Output Print the only integer _x_ — the position of the optimal point on the line. If ...
1,400
false
false
false
false
false
false
true
false
true
false
6,981
542B
A duck hunter is doing his favorite thing, hunting. He lives in a two dimensional world and is located at point (0,u20090). As he doesn't like walking for his prey, he prefers to shoot only vertically up (because in this case, the ducks fall straight into his hands). The hunter doesn't reload the gun immediately — _r_ ...
3,100
false
false
false
false
true
false
false
false
false
false
7,674
1916G
You are given a tree with $$$n$$$ vertices, whose vertices are numbered from $$$1$$$ to $$$n$$$. Each edge is labeled with some integer $$$w_i$$$. Define $$$len(u, v)$$$ as the number of edges in the simple path between vertices $$$u$$$ and $$$v$$$, and $$$gcd(u, v)$$$ as the Greatest Common Divisor of all numbers writ...
3,500
false
false
false
true
false
false
false
false
false
false
797
1194F
Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only $$$T$$$ seconds after coming. Fortunately, Adilbek can spend time w...
2,400
false
false
false
true
false
false
false
false
false
false
4,731
1791D
Let's denote the $$$f(x)$$$ function for a string $$$x$$$ as the number of distinct characters that the string contains. For example $$$f( exttt{abc}) = 3$$$, $$$f( exttt{bbbbb}) = 1$$$, and $$$f( exttt{babacaba}) = 3$$$. Given a string $$$s$$$, split it into two non-empty strings $$$a$$$ and $$$b$$$ such that $$$f(a) ...
1,000
false
true
false
false
false
false
true
false
false
false
1,532
48H
According to the legends the king of Berland Berl I was noted for his love of beauty and order. One day he ordered to tile the palace hall's floor where balls and receptions used to take place with black and white tiles according to a regular geometrical pattern invented by him. However, as is after the case, due to lo...
2,800
false
false
false
false
false
true
false
false
false
false
9,730
91E
Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building! There are _n_ walruses taking part in the contest. Each walrus is given a unique number from 1 to _n_. After start each walrus begins to build his own igloo skyscraper. Initially, at the moment of time equal to 0, the height of...
2,500
false
false
false
false
true
false
false
false
false
false
9,518
1519C
Polycarp is an organizer of a Berland ICPC regional event. There are $$$n$$$ universities in Berland numbered from $$$1$$$ to $$$n$$$. Polycarp knows all competitive programmers in the region. There are $$$n$$$ students: the $$$i$$$-th student is enrolled at a university $$$u_i$$$ and has a programming skill $$$s_i$$$....
1,400
false
true
false
false
true
false
true
false
true
false
3,067
1284E
Kiwon's favorite video game is now holding a new year event to motivate the users! The game is about building and defending a castle, which led Kiwon to think about the following puzzle. In a 2-dimension plane, you have a set $$$s = {(x_1, y_1), (x_2, y_2), ldots, (x_n, y_n)}$$$ consisting of $$$n$$$ distinct points. I...
2,500
true
false
false
false
false
false
false
false
true
false
4,270
1883D
Initially, you have an empty multiset of segments. You need to process $$$q$$$ operations of two types: $$$+$$$ $$$l$$$ $$$r$$$ — Add the segment $$$(l, r)$$$ to the multiset, $$$-$$$ $$$l$$$ $$$r$$$ — Remove exactly one segment $$$(l, r)$$$ from the multiset. It is guaranteed that this segment exists in the multiset...
1,500
false
true
false
false
true
false
false
false
false
false
988
203B
One not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game. He took a checkered white square piece of paper, consisting of _n_u2009×u2009_n_ cells. After that, he started to paint the white cells black one after the other. In total he painted _m_ different c...
1,300
false
false
true
false
false
false
true
false
false
false
9,031
332A
Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice! Yesterday one student, Vasya and his mates made some barbecue and they drank this healthy drink only. After they ran out of the first barrel of juice, they decided to pla...
1,300
false
false
true
false
false
false
false
false
false
false
8,510
1263B
A PIN code is a string that consists of exactly $$$4$$$ digits. Examples of possible PIN codes: 7013, 0000 and 0990. Please note that the PIN code can begin with any digit, even with 0. Polycarp has $$$n$$$ ($$$2 le n le 10$$$) bank cards, the PIN code of the $$$i$$$-th card is $$$p_i$$$. Polycarp has recently read a r...
1,400
false
true
true
false
false
false
false
false
false
false
4,386
80B
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels! There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle... Everybody was upset. The beautiful Bel...
1,200
true
false
false
false
false
false
false
false
false
false
9,564