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
104A
One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one! Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to ...
800
false
false
true
false
false
false
false
false
false
false
9,467
462B
Problem - 462B - 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
true
false
false
false
false
false
false
false
false
7,990
803A
Problem - 803A - Codeforces =============== xa0 and is lexicographically maximal. One matrix is lexicographically greater than the other if the first different number in the first different row from the top in the first matrix is greater than the corresponding number in the second one. If there exists no ...
1,400
false
false
false
false
false
true
false
false
false
false
6,552
1718E
Burenka has two pictures $$$a$$$ and $$$b$$$, which are tables of the same size $$$n imes m$$$. Each cell of each painting has a color β€” a number from $$$0$$$ to $$$2 cdot 10^5$$$, and there are no repeating colors in any row or column of each of the two paintings, except color $$$0$$$. Burenka wants to get a picture ...
3,500
true
false
true
false
false
true
false
false
false
true
1,970
1149B
During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace. The Word of Univ...
2,200
false
false
true
true
false
false
false
false
false
false
4,968
1566C
A binary string is a string that consists of characters $$$0$$$ and $$$1$$$. A bi-table is a table that has exactly two rows of equal length, each being a binary string. Let $$$operatorname{MEX}$$$ of a bi-table be the smallest digit among $$$0$$$, $$$1$$$, or $$$2$$$ that does not occur in the bi-table. For example, $...
1,000
false
true
false
true
false
true
false
false
false
false
2,811
1648F
In order to make the capital of Berland a more attractive place for tourists, the great king came up with the following plan: choose two streets of the city and call them avenues. Certainly, these avenues will be proclaimed extremely important historical places, which should attract tourists from all over the world. Th...
3,500
false
false
false
false
true
false
false
false
false
true
2,378
965D
A lot of frogs want to cross a river. A river is $$$w$$$ units width, but frogs can only jump $$$l$$$ units long, where $$$l < w$$$. Frogs can also jump on lengths shorter than $$$l$$$. but can't jump longer. Hopefully, there are some stones in the river to help them. The stones are located at integer distances from th...
1,900
false
true
false
false
false
false
false
true
false
false
5,839
1626D
Monocarp is planning to host a martial arts tournament. There will be three divisions based on weight: lightweight, middleweight and heavyweight. The winner of each division will be determined by a single elimination system. In particular, that implies that the number of participants in each division should be a power ...
2,100
true
true
false
false
false
false
true
true
false
false
2,484
1876D
Pak Chanek loves his faculty, the Faculty of Computer Science, University of Indonesia (Fasilkom). He wants to play with the colours of the faculty's logo, blue and red. There is an array $$$a$$$ consisting of $$$n$$$ elements, element $$$i$$$ has a value of $$$a_i$$$. Pak Chanek wants to colour each element in the arr...
2,500
false
false
false
false
false
false
false
false
false
true
1,023
1847E
Enter Register HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN Codeforces Round 882 (Div. 2) 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...
2,900
true
false
true
false
false
false
true
false
false
false
1,196
1658B
Marin wants you to count number of permutations that are beautiful. A beautiful permutation of length $$$n$$$ is a permutation that has the following property: $$$$$$ gcd (1 cdot p_1, , 2 cdot p_2, , dots, , n cdot p_n) > 1, $$$$$$ where $$$gcd$$$ is the and $$$[1,3, 4]$$$ is also not a permutation ($$$n=3$$$ but there...
800
true
false
false
false
false
false
false
false
false
false
2,338
1975H
378QAQ has a string $$$s$$$ of length $$$n$$$. Define the core of a string as the substring$$$^dagger$$$ with maximum lexicographic$$$^ddagger$$$ order. For example, the core of "$$$mathtt{bazoka}$$$" is "$$$mathtt{zoka}$$$", and the core of "$$$mathtt{aaa}$$$" is "$$$mathtt{aaa}$$$". 378QAQ wants to rearrange the stri...
3,500
false
true
false
false
false
false
false
false
false
false
435
1882C
There are $$$n$$$ cards stacked in a deck. Initially, $$$a_{i}$$$ is written on the $$$i$$$-th card from the top. The value written on a card does not change. You will play a game. Initially your score is $$$0$$$. In each turn, you can do one of the following operations: Choose an odd$$$^{dagger}$$$ positive integer $...
1,500
false
true
false
false
false
false
true
false
false
false
995
959B
Mahmoud wants to send a message to his friend Ehab. Their language consists of _n_ words numbered from 1 to _n_. Some words have the same meaning so there are _k_ groups of words such that all the words in some group have the same meaning. Mahmoud knows that the _i_-th word can be sent with cost _a__i_. For each word i...
1,200
false
true
true
false
false
false
false
false
false
false
5,876
859G
_n_ evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number _k_. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by _k_ or decrease all numbers at ...
3,000
true
false
false
false
false
false
false
false
false
false
6,302
873A
Luba has to do _n_ chores today. _i_-th chore takes _a__i_ units of time to complete. It is guaranteed that for every the condition _a__i_u2009β‰₯u2009_a__i_u2009-u20091 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than _k_ any chores and do each of them in _x_...
800
false
false
true
false
false
false
false
false
false
false
6,254
358A
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of _n_ distinct points on the abscissa axis and asked to consecutively connect the...
1,400
false
false
true
false
false
false
true
false
false
false
8,404
915E
This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term is very soon, but, unfortunately, Alex still hasn't attended a single lesson...
2,300
false
false
true
false
true
false
false
false
true
false
6,071
234B
Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed _k_ hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very lig...
1,000
false
false
false
false
false
false
false
false
true
false
8,903
1834E
You are given an array $$$a$$$ of length $$$n$$$. A positive integer $$$x$$$ is called good if it is impossible to find a subsegment$$$^{dagger}$$$ of the array such that the β€” the number of test cases. The description of test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 leq n...
2,300
true
false
true
false
true
false
false
true
false
false
1,280
865E
Copying large hexadecimal (base 16) strings by hand can be error prone, but that doesn't stop people from doing it. You've discovered a bug in the code that was likely caused by someone making a mistake when copying such a string. You suspect that whoever copied the string did not change any of the digits in the string...
3,300
false
false
false
true
false
false
true
false
false
true
6,277
1701A
There is a field of size $$$2 imes 2$$$. Each cell of this field can either contain grass or be empty. The value $$$a_{i, j}$$$ is $$$1$$$ if the cell $$$(i, j)$$$ contains grass, or $$$0$$$ otherwise. In one move, you can choose one row and one column and cut all the grass in this row and this column. In other words,...
800
false
false
true
false
false
false
false
false
false
false
2,076
1278E
We had a really tough time generating tests for problem D. In order to prepare strong tests, we had to solve the following problem. Given an undirected labeled tree consisting of $$$n$$$ vertices, find a set of segments such that: 1. both endpoints of each segment are integers from $$$1$$$ to $$$2n$$$, and each integer...
2,200
false
false
false
false
false
true
false
false
false
false
4,302
1354A
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $$$a$$$ minutes to feel refreshed. Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $$$b$$$ minutes. Every time Polycarp wakes up, he decides if he want...
900
true
false
false
false
false
false
false
false
false
false
3,939
1696F
Fishingprince loves trees. A tree is a connected undirected graph without cycles. Fishingprince has a tree of $$$n$$$ vertices. The vertices are numbered $$$1$$$ through $$$n$$$. Let $$$d(x,y)$$$ denote the shortest distance on the tree from vertex $$$x$$$ to vertex $$$y$$$, assuming that the length of each edge is $$$...
2,600
false
false
false
false
false
true
true
false
false
true
2,103
1272D
Problem - 1272D - 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,500
false
false
false
true
false
false
true
false
false
false
4,326
1826C
Because to take away a man's freedom of choice, even his freedom to make the wrong choice, is to manipulate him as though he were a puppet and not a person. β€” Madeleine L'Engle There are $$$n$$$ programmers choosing their favorite algorithm amongst $$$m$$$ different choice options. Before the first round, all $$$m$$$ o...
1,300
true
true
false
false
false
false
false
false
false
false
1,327
1660A
Vasya decided to go to the grocery store. He found in his wallet $$$a$$$ coins of $$$1$$$ burle and $$$b$$$ coins of $$$2$$$ burles. He does not yet know the total cost of all goods, so help him find out $$$s$$$ ($$$s > 0$$$): the minimum positive integer amount of money he cannot pay without change or pay at all using...
800
true
true
false
false
false
false
false
false
false
false
2,326
1552F
An ant moves on the real line with constant speed of $$$1$$$ unit per second. It starts at $$$0$$$ and always moves to the right (so its position increases by $$$1$$$ each second). There are $$$n$$$ portals, the $$$i$$$-th of which is located at position $$$x_i$$$ and teleports to position $$$y_i < x_i$$$. Each portal ...
2,200
false
false
false
true
true
false
false
true
true
false
2,879
1660C
A string $$$a=a_1a_2dots a_n$$$ is called even if it consists of a concatenation (joining) of strings of length $$$2$$$ consisting of the same characters. In other words, a string $$$a$$$ is even if two conditions are satisfied at the same time: its length $$$n$$$ is even; for all odd $$$i$$$ ($$$1 le i le n - 1$$$),...
1,300
false
true
false
true
false
false
false
false
false
false
2,324
1137E
Vasya likes to travel by train, but doesn't like when the car he travels in is located in the tail of the train. Vasya gets on the train at the station. The train consists of $$$n$$$ cars indexed from $$$1$$$ to $$$n$$$ counting from the locomotive (head of the train). Three types of events occur while the train is mov...
2,700
false
true
false
false
true
false
false
false
false
false
5,038
1027E
You are given a square board, consisting of $$$n$$$ rows and $$$n$$$ columns. Each tile in it should be colored either white or black. Let's call some coloring beautiful if each pair of adjacent rows are either the same or different in every position. The same condition should be held for the columns as well. Let's cal...
2,100
true
false
false
true
false
false
false
false
false
false
5,572
813F
Problem - 813F - Codeforces =============== xa0 . Input The first line contains two integers _n_ and _q_ (2u2009≀u2009_n_,u2009_q_u2009≀u2009100000). Then _q_ lines follow. _i_th line contains two numbers _x__i_ and _y__i_ (1u2009≀u2009_x__i_u2009<u2009_y__i_u2009≀u2009_n_). These numbers describe _i_th q...
2,500
false
false
false
false
true
false
false
false
false
true
6,506
671B
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are _n_ citizens in Kekoland, each person has _c__i_ coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it...
2,000
false
true
false
false
false
false
false
true
false
false
7,139
320B
Problem - 320B - 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
false
false
false
false
false
false
true
8,552
571C
'In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of clauses, where a clause is a disjunction of literals' (cited from the other words, CNF is a formula of type , where & represents a logical "AND" (conjunction), represents a logical "OR" (disjunction), and _...
2,500
false
true
false
false
false
true
false
false
false
true
7,564
1672C
You are given an array $$$a$$$ of length $$$n$$$. We define the equality of the array as the number of indices $$$1 le i le n - 1$$$ such that $$$a_i = a_{i + 1}$$$. We are allowed to do the following operation: Select two integers $$$i$$$ and $$$x$$$ such that $$$1 le i le n - 1$$$ and $$$1 le x le 10^9$$$. Then, set...
1,100
false
true
true
false
false
true
false
false
false
false
2,243
1857E
You are given $$$n$$$ points with integer coordinates $$$x_1,dots x_n$$$, which lie on a number line. For some integer $$$s$$$, we construct segments [$$$s,x_1$$$], [$$$s,x_2$$$], $$$dots$$$, [$$$s,x_n$$$]. Note that if $$$x_i<s$$$, then the segment will look like [$$$x_i,s$$$]. The segment [$$$a, b$$$] covers all inte...
1,500
true
false
false
false
false
false
false
false
true
false
1,140
1941C
Rudolf has a string $$$s$$$ of length $$$n$$$. Rudolf considers the string $$$s$$$ to be ugly if it contains the substring$$$^dagger$$$ "pie" or the substring "map", otherwise the string $$$s$$$ will be considered beautiful. For example, "ppiee", "mmap", "dfpiefghmap" are ugly strings, while "mathp", "ppiiee" are beaut...
900
false
true
false
true
false
false
false
false
false
false
637
1225C
Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $$$p$$$ (which may be positive, negative, or zero). To combine their tastes, they invented $$$p$$$-binary numbers of the form $$$2^x + p$$$, where $$$x$$$ is a non-negativ...
1,600
true
false
false
false
false
false
true
false
false
false
4,549
380C
Sereja has a bracket sequence _s_1,u2009_s_2,u2009...,u2009_s__n_, or, in other words, a string _s_ of length _n_, consisting of characters "(" and ")". Sereja needs to answer _m_ queries, each of them is described by two integers _l__i_,u2009_r__i_ (1u2009≀u2009_l__i_u2009≀u2009_r__i_u2009≀u2009_n_). The answer to the...
2,000
false
false
false
false
true
false
false
false
false
false
8,308
2030G2
This is the hard version of the problem. In this version, $$$n leq 10^6$$$. You can only make hacks if both versions of the problem are solved. Orangutans are powerful beingsβ€”so powerful that they only need $$$1$$$ unit of time to destroy every vulnerable planet in the universe! There are $$$n$$$ planets in the univers...
3,100
true
false
false
false
false
false
false
false
false
false
81
388B
Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with _n_ vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2." Same with some writers, she wants to make an example with some certain outpu...
1,900
true
false
true
false
false
true
false
false
false
true
8,276
1515B
Problem - 1515B - Codeforces =============== xa0 ]( "Codeforces Global Round 14") . Can he do it? Input The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 le t le 10^4$$$)xa0β€” the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$...
1,000
true
false
false
false
false
false
true
false
false
false
3,090
1099B
Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $$$n$$$ squares in the snow with a side length of $$$1$$$. For simplicity, we assume that Sofia lives on a plane and can draw only segments of length $$$1$$$, parallel to the coordi...
1,100
true
false
false
false
false
true
false
true
false
false
5,209
150A
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer _q_. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of cir...
1,400
true
false
false
false
false
false
false
false
false
false
9,276
714B
Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers _a_1,u2009_a_2,u2009...,u2009_a__n_. First, he pick an integer _x_ and then he adds _x_ to some elements of the array (no more ...
1,200
false
false
true
false
false
false
false
false
true
false
6,960
266A
Problem - 266A - Codeforces =============== xa0 ]( --- Finished β†’ Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
800
false
false
true
false
false
false
false
false
false
false
8,771
938F
Problem - 938F - 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,700
false
true
false
true
false
false
false
false
false
false
5,946
821C
Okabe and Super Hacker Daru are stacking and removing boxes. There are _n_ boxes numbered from 1 to _n_. Initially there are no boxes on the stack. Okabe, being a control freak, gives Daru 2_n_ commands: _n_ of which are to add a box to the top of the stack, and _n_ of which are to remove a box from the top of the stac...
1,500
false
true
false
false
true
false
false
false
false
false
6,471
1413F
In the Land of Fire there are $$$n$$$ villages and $$$n-1$$$ bidirectional road, and there is a path between any pair of villages by roads. There are only two types of roads: stone ones and sand ones. Since the Land of Fire is constantly renovating, every morning workers choose a single road and flip its type (so it be...
2,800
false
false
false
false
true
false
false
false
false
false
3,609
958C3
Heidi is now just one code away from breaking the encryption of the Death Star plans. The screen that should be presenting her with the description of the next code looks almost like the previous one, though who would have thought that the evil Empire engineers would fill this small screen with several million digits! ...
2,500
false
false
false
true
true
false
false
false
false
false
5,886
1582G
Kuzya started going to school. He was given math homework in which he was given an array $$$a$$$ of length $$$n$$$ and an array of symbols $$$b$$$ of length $$$n$$$, consisting of symbols '*' and '/'. Let's denote a path of calculations for a segment $$$[l; r]$$$ ($$$1 le l le r le n$$$) in the following way: Let $$$x...
2,600
false
false
false
false
true
false
false
false
false
false
2,718
226E
In Berland each feudal owns exactly one castle and each castle belongs to exactly one feudal. Each feudal, except one (the King) is subordinate to another feudal. A feudal can have any number of vassals (subordinates). Some castles are connected by roads, it is allowed to move along the roads in both ways. Two castles ...
2,900
false
false
false
false
true
false
false
false
false
false
8,931
1567D
On the board, Bob wrote $$$n$$$ positive integers in . Alice sees the board, but accidentally interprets the numbers on the board as base-$$$11$$$ integers and adds them up (in base $$$11$$$). What numbers should Bob write on the board, so Alice's sum is as large as possible? Input The input consists of multiple test c...
2,000
true
true
true
false
false
true
false
false
false
false
2,801
998A
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $$$n$$$ packets with inflatable balloons, where $$$i$$$-th of them has exactly $$$a_i$$$ ba...
1,000
false
false
true
false
false
true
false
false
false
false
5,713
1383F
Koa the Koala has a directed graph $$$G$$$ with $$$n$$$ nodes and $$$m$$$ edges. Each edge has a capacity associated with it. Exactly $$$k$$$ edges of the graph, numbered from $$$1$$$ to $$$k$$$, are special, such edges initially have a capacity equal to $$$0$$$. Koa asks you $$$q$$$ queries. In each query she gives yo...
3,200
false
false
false
false
false
false
false
false
false
true
3,751
1712A
God's Blessing on This PermutationForces! A Random Pebble You are given a permutation $$$p_1,p_2,ldots,p_n$$$ of length $$$n$$$ and a positive integer $$$k le n$$$. In one operation you can choose two indices $$$i$$$ and $$$j$$$ ($$$1 le i < j le n$$$) and swap $$$p_i$$$ with $$$p_j$$$. Find the minimum number of opera...
800
false
true
true
false
false
false
false
false
false
false
2,013
2002A
Problem - 2002A - 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
true
false
false
true
false
false
false
false
249
1765N
Problem - 1765N - 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,500
false
true
false
false
false
false
false
false
false
false
1,704
271D
You've got string _s_, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring _s_[_l_..._r_] (1u2009≀u2009_l_u2009≀u2009_r_u2009≀u2009_s_) of string _s_u2009u2009=u2009u2009_s_1_s_2..._s__s_ (where _s_ is the length of string _s_) is string u2009_s__l__s__l_u2009+u20091...
1,800
false
false
false
false
true
false
false
false
false
false
8,748
1392G
Omkar has a pie tray with $$$k$$$ ($$$2 leq k leq 20$$$) spots. Each spot in the tray contains either a chocolate pie or a pumpkin pie. However, Omkar does not like the way that the pies are currently arranged, and has another ideal arrangement that he would prefer instead. To assist Omkar, $$$n$$$ elves have gathered ...
2,900
true
false
false
true
false
false
false
false
false
false
3,710
1697A
You are walking through a parkway near your house. The parkway has $$$n+1$$$ benches in a row numbered from $$$1$$$ to $$$n+1$$$ from left to right. The distance between the bench $$$i$$$ and $$$i+1$$$ is $$$a_i$$$ meters. Initially, you have $$$m$$$ units of energy. To walk $$$1$$$ meter of distance, you spend $$$1$$$...
800
false
true
true
false
false
false
false
false
false
false
2,100
1530A
Problem - 1530A - 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
true
false
false
false
false
false
false
false
false
3,015
156A
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string _s_. String _p_ is called a substring of string _s_ if you can read it starting from some position in the string _s_. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string _s_ and cut ...
1,700
false
false
false
false
false
false
true
false
false
false
9,252
1807D
You have an array $$$a_1, a_2, dots, a_n$$$. Answer $$$q$$$ queries of the following form: If we change all elements in the range $$$a_l, a_{l+1}, dots, a_r$$$ of the array to $$$k$$$, will the sum of the entire array be odd? Note that queries are independent and do not affect future queries. Input Each test contains ...
900
false
false
true
false
true
false
false
false
false
false
1,432
1764G2
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{25}$$$ 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...
3,000
false
false
false
false
false
false
false
true
false
false
1,720
990G
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,400
false
false
false
true
false
false
false
false
false
false
5,746
1684G
Let's consider Euclid's algorithm for finding the : if a < b: swap(a, b)if b == 0: return a r = reminder from dividing a by b if r > 0: append r to the back of t return Euclid(b, r) There is an array $$$p$$$ of pairs of positive integers that are not greater than $$$m$$$. Initially, the list $$$t$$$ is empty....
2,800
true
false
false
false
false
true
false
false
false
false
2,167
11D
Problem - 11D - Codeforces =============== xa0 ]( "Codeforces Beta Round #11") – respectively the number of vertices and edges of the graph. Each of the subsequent _m_ lines contains two integers _a_ and _b_, (1u2009≀u2009_a_,u2009_b_u2009≀u2009_n_, _a_u2009β‰ u2009_b_) indicating that vertices _a_ and _b_ are c...
2,200
false
false
false
true
false
false
false
false
false
true
9,937
1656B
You are given a list of $$$n$$$ integers. You can perform the following operation: you choose an element $$$x$$$ from the list, erase $$$x$$$ from the list, and subtract the value of $$$x$$$ from all the remaining elements. Thus, in one operation, the length of the list is decreased by exactly $$$1$$$. Given an integer...
1,100
true
true
false
false
true
false
false
false
false
false
2,353
802E
Problem - 802E - Codeforces =============== xa0 ]( --- Finished β†’ Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
2,200
true
false
false
false
false
false
false
false
false
false
6,563
1998C
I see satyam343. I'm shaking. Please more median problems this time. I love those. Please satyam343 we believe in you. β€” satyam343's biggest fan You are given an array $$$a$$$ of length $$$n$$$ and an integer $$$k$$$. You are also given a binary array $$$b$$$ of length $$$n$$$. You can perform the following operation a...
1,900
false
true
true
false
false
true
true
true
false
false
275
134B
Problem - 134B - Codeforces =============== xa0 . We can get a new pair (_a_u2009+u2009_b_,u2009_b_) or (_a_,u2009_a_u2009+u2009_b_) from the given pair in a single step. Let the initial pair of numbers be (1,1). Your task is to find number _k_, that is, the least number of steps needed to transform (1,1) int...
1,900
true
false
false
false
false
false
true
false
false
false
9,339
1342C
Problem - 1342C - 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,600
true
false
false
false
false
false
false
false
false
false
3,997
1691D
You are given an array $$$a$$$ of $$$n$$$ integers. You are asked to find out if the inequality $$$$$$max(a_i, a_{i + 1}, ldots, a_{j - 1}, a_{j}) geq a_i + a_{i + 1} + dots + a_{j - 1} + a_{j}$$$$$$ holds for all pairs of indices $$$(i, j)$$$, where $$$1 leq i leq j leq n$$$. Input Each test contains multiple test cas...
1,800
false
false
true
false
true
true
false
true
false
false
2,133
555C
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an _n_u2009Γ—u2009_n_ table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to _n_ from left to right and ...
2,200
false
false
false
false
true
false
false
false
false
false
7,613
1223D
You are given a sequence $$$a_1, a_2, dots, a_n$$$, consisting of integers. You can apply the following operation to this sequence: choose some integer $$$x$$$ and move all elements equal to $$$x$$$ either to the beginning, or to the end of $$$a$$$. Note that you have to move all these elements in one direction in one ...
2,000
false
true
false
true
false
false
false
false
false
false
4,556
1709E
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$$$. Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let's say...
2,400
false
true
false
false
true
false
false
false
false
false
2,022
1726B
Mainak has two positive integers $$$n$$$ and $$$m$$$. Mainak finds a sequence $$$a_1, a_2, ldots, a_n$$$ of $$$n$$$ positive integers interesting, if for all integers $$$i$$$ ($$$1 le i le n$$$), the , $$$[4,1,1,2,4]$$$ ($$$p_1 = 1 oplus 1 oplus 2 = 2 e 0$$$), $$$[29,30,30]$$$ ($$$p_2 = 29 e 0$$$) aren't interesting....
1,100
true
false
false
false
false
true
false
false
false
false
1,932
756C
Nikita has a stack. A stack in this problem is a data structure that supports two operations. Operation push(x) puts an integer _x_ on the top of the stack, and operation pop() deletes the top integer from the stack, i.xa0e. the last added. If the stack is empty, then the operation pop() does nothing. Nikita made _m_ o...
2,200
false
false
false
false
true
false
false
false
false
false
6,768
142A
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple...
1,600
true
false
false
false
false
false
true
false
false
false
9,307
745B
Hongcow likes solving puzzles. One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be described by an _n_ by _m_ grid of characters, where the character 'X' denotes a part of the puzzle and '.' denotes an empty part of the grid. It is guaranteed that...
1,400
false
false
true
false
false
false
false
false
false
false
6,818
1228F
You have an integer $$$n$$$. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of $$$2^{n} - 1$$$ vertices. Complete and full binary tree means a tree that exactly one vertex is a root, all leaves have the same depth (distance from the root), and all non-leaf nodes ha...
2,500
false
false
true
false
false
true
false
false
false
false
4,530
2003B
Turtle and Piggy are playing a game on a sequence. They are given a sequence $$$a_1, a_2, ldots, a_n$$$, and Turtle goes first. Turtle and Piggy alternate in turns (so, Turtle does the first turn, Piggy does the second, Turtle does the third, etc.). The game goes as follows: Let the current length of the sequence be $...
800
false
true
false
false
false
false
false
false
true
false
238
702A
Problem - 702A - Codeforces =============== xa0 β€” the number of integers. The second line contains _n_ positive integers _a_1,u2009_a_2,u2009...,u2009_a__n_ (1u2009≀u2009_a__i_u2009≀u2009109). Output Print the maximum length of an increasing subarray of the given array. Examples Input 5 1 7 2 11 15 Outp...
800
false
true
true
true
false
false
false
false
false
false
7,017
121C
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicographically _k_-th permutation of integers from 1 to _n_. Determine h...
1,900
false
false
false
false
false
false
true
false
false
false
9,394
1899F
Tree is a connected graph without cycles. It can be shown that any tree of $$$n$$$ vertices has exactly $$$n - 1$$$ edges. Leaf is a vertex in the tree with exactly one edge connected to it. Distance between two vertices $$$u$$$ and $$$v$$$ in a tree is the minimum number of edges that must be passed to come from verte...
1,600
false
true
false
false
false
true
false
false
false
true
917
1213B
Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for $$$n$$$ last days: $$$a_1, a_2, dots, a_n$$$, where $$$a_i$$$ is the price of berPhone on the day $$$i$$$. Polycarp considers the price on the day $$$i$$$ to be bad if later (that is, a day with a greater number) berPhone was sold at a...
1,100
false
false
true
false
true
false
false
false
false
false
4,618
916E
To your surprise, Jamie is the final boss! Ehehehe. Jamie has given you a tree with _n_ vertices, numbered from 1 to _n_. Initially, the root of the tree is the vertex with number 1. Also, each vertex has a value on it. Jamie also gives you three types of queries on the tree: 1 _v_xa0β€” Change the tree's root to vertex ...
2,400
false
false
false
false
true
false
false
false
false
false
6,064
1584A
Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers $$$u$$$ and $$$v$$$, find any pair of integers (not necessarily positive) $$$x$$$, $$$y$$$, such that: $$$$$$frac{x}{u} + frac{y}{v} = frac{x + y}{u + v}...
800
true
false
false
false
false
false
false
false
false
false
2,709
2025C
There's a new game Monocarp wants to play. The game uses a deck of $$$n$$$ cards, where the $$$i$$$-th card has exactly one integer $$$a_i$$$ written on it. At the beginning of the game, on the first turn, Monocarp can take any card from the deck. During each subsequent turn, Monocarp can take exactly one card that has...
1,300
false
true
true
false
false
false
true
true
true
false
121
817F
Problem - 817F - Codeforces =============== xa0 integer number which is not presented in the set. Input The first line contains one integer number _n_ (1u2009≀u2009_n_u2009≀u2009105). Next _n_ lines contain three integer numbers _t_,u2009_l_,u2009_r_ (1u2009≀u2009_t_u2009≀u20093,u20091u2009≀u2009_l_u2009≀...
2,300
false
false
false
false
true
false
false
true
false
false
6,488
219A
Problem - 219A - Codeforces =============== xa0 ]( --- Finished β†’ Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,000
false
false
true
false
false
false
false
false
false
false
8,964
415B
Problem - 415B - 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
true
false
false
false
false
true
false
false
8,163
2041F
Peter loves folding segments. There is a segment on a number line occupying the interval $$$[ell, r]$$$. Since it is the prime time for folding the segments, Peter decides to fold the segment carefully. In each step, he chooses one of the two following operations whenever possible: 1. Operation $$$ t{LTR}$$$: he folds ...
2,400
false
false
false
false
false
false
true
false
false
false
8
980B
The city of Fishtopia can be imagined as a grid of $$$4$$$ rows and an odd number of columns. It has two main villages; the first is located at the top-left cell $$$(1,1)$$$, people who stay there love fishing at the Tuna pond at the bottom-right cell $$$(4, n)$$$. The second village is located at $$$(4, 1)$$$ and its ...
1,600
false
false
false
false
false
true
false
false
false
false
5,805
1208B
You are given an array $$$a_{1}, a_{2}, ldots, a_{n}$$$. You can remove at most one subsegment from it. The remaining elements should be pairwise distinct. In other words, at most one time you can choose two integers $$$l$$$ and $$$r$$$ ($$$1 leq l leq r leq n$$$) and delete integers $$$a_l, a_{l+1}, ldots, a_r$$$ from...
1,500
false
false
true
false
false
false
true
true
false
false
4,653
1857G
Given a tree consisting of $$$n$$$ vertices. A tree is a connected undirected graph without cycles. Each edge of the tree has its weight, $$$w_i$$$. Your task is to count the number of different graphs that satisfy all four conditions: 1. The graph does not have self-loops and multiple edges. 2. The weights on the edge...
2,000
false
true
false
false
false
false
false
false
true
true
1,138