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
865B
It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly _S_ slices. It is known that the _i_-th contestant will eat _s__i_ slices of pizza, and g...
1,900
false
false
false
false
false
false
false
true
true
false
6,280
1136C
Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $$$A$$$ and $$$B$$$ are given, each of them has size $$$n imes m$$$. Nastya can perform the following operation to matrix $$$A$$$ unlimited number of times: take any square squ...
1,500
false
false
false
false
false
true
false
false
true
false
5,045
1070B
Berkomnadzorxa0— Federal Service for Supervision of Communications, Information Technology and Mass Mediaxa0— is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet. Berkomnadzor maintains a list of prohibited IPv4 subnets (blacklist) and a list of allowed IP...
2,400
false
true
false
false
true
false
false
false
false
false
5,366
152D
One day Vasya got hold of a sheet of checkered paper _n_u2009×u2009_m_ squares in size. Our Vasya adores geometrical figures, so he painted two rectangles on the paper. The rectangles' sides are parallel to the coordinates' axes, also the length of each side of each rectangle is no less than 3 squares and the sides are...
2,600
false
false
false
false
false
false
true
false
false
false
9,266
1110A
You are given an integer $$$n$$$ ($$$n ge 0$$$) represented with $$$k$$$ digits in base (radix) $$$b$$$. So, $$$$$$n = a_1 cdot b^{k-1} + a_2 cdot b^{k-2} + ldots a_{k-1} cdot b + a_k.$$$$$$ For example, if $$$b=17, k=3$$$ and $$$a=[11, 15, 7]$$$ then $$$n=11cdot17^2+15cdot17+7=3179+255+7=3441$$$. Determine whether $$$...
900
true
false
false
false
false
false
false
false
false
false
5,149
1659E
There is an undirected, connected graph with $$$n$$$ vertices and $$$m$$$ weighted edges. A walk from vertex $$$u$$$ to vertex $$$v$$$ is defined as a sequence of vertices $$$p_1,p_2,ldots,p_k$$$ (which are not necessarily distinct) starting with $$$u$$$ and ending with $$$v$$$, such that $$$p_i$$$ and $$$p_{i+1}$$$ ar...
2,200
false
false
false
false
false
true
true
false
false
true
2,328
459C
Problem - 459C - 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
true
false
false
false
false
8,004
1032F
Vasya has got a tree consisting of $$$n$$$ vertices. He wants to delete some (possibly zero) edges in this tree such that the maximum matching in the resulting graph is unique. He asks you to calculate the number of ways to choose a set of edges to remove. A matching in the graph is a subset of its edges such that ther...
2,400
false
false
false
true
false
false
false
false
false
false
5,537
1948G
You are given an undirected connected graph on $$$n$$$ vertices. Each edge of this graph has a weight; the weight of the edge connecting vertices $$$i$$$ and $$$j$$$ is $$$w_{i,j}$$$ (or $$$w_{i,j} = 0$$$ if there is no edge between $$$i$$$ and $$$j$$$). All weights are positive integers. You are also given a positive ...
3,100
false
false
false
false
false
false
true
false
false
false
593
665F
Problem - 665F - Codeforces =============== xa0 ]( "Educational Codeforces Round 12") — number of integers between 1 and _n_ (inclusive) which has exactly four positive divisors. Between 1 and 10 only the integers 6, 8 and 10 has exactly four positive divisors. So, _D_(10)u2009=u20093. You are given an int...
2,400
true
false
false
true
true
false
false
false
true
false
7,156
374C
Inna and Dima bought a table of size _n_u2009×u2009_m_ in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A". Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna acts as follows: 1. initially, Inna chooses some cell of ...
1,900
false
false
true
true
false
false
false
false
false
true
8,334
1833G
Ksyusha has a pet chinchilla, a tree on $$$n$$$ vertices and huge scissors. A tree is a connected graph without cycles. During a boring physics lesson Ksyusha thought about how to entertain her pet. Chinchillas like to play with branches. A branch is a tree of $$$3$$$ vertices. The branch looks like this. A cut is the...
1,800
false
true
true
true
false
true
false
false
false
false
1,285
870C
Problem - 870C - Codeforces =============== xa0 ") ") xa0— the number of queries. _q_ lines follow. The (_i_u2009+u20091)-th line contains single integer _n__i_ (1u2009≤u2009_n__i_u2009≤u2009109)xa0— the _i_-th query. Output For each query print the maximum possible number of summands in a valid splitting ...
1,300
true
true
false
true
false
false
false
false
false
false
6,259
817E
As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors. Each...
2,000
false
false
false
false
true
false
false
false
false
false
6,489
1778D
You are given two binary strings $$$a$$$ and $$$b$$$ of length $$$n$$$. In each move, the string $$$a$$$ is modified in the following way. An index $$$i$$$ ($$$1 leq i leq n$$$) is chosen uniformly at random. The character $$$a_i$$$ will be flipped. That is, if $$$a_i$$$ is $$$0$$$, it becomes $$$1$$$, and if $$$a_i$$...
2,100
true
false
false
true
false
false
false
false
false
false
1,605
1325C
Problem - 1325C - 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
true
false
false
false
false
4,091
1344C
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($$$forall$$$) and existential ($$$exists$$$). You can read more about th...
2,600
true
false
false
true
false
false
false
false
false
true
3,985
690D3
So many wall designs to choose from! Even modulo 106u2009+u20093, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them down. Heidi is quick to come up with criteria for a useful wall: In a useful wall, at lea...
2,100
false
false
false
true
false
false
false
false
false
false
7,053
1453A
Gildong's town has a train system that has $$$100$$$ trains that travel from the bottom end to the top end and $$$100$$$ trains that travel from the left end to the right end. The trains starting from each side are numbered from $$$1$$$ to $$$100$$$, respectively, and all trains have the same speed. Let's take a look a...
800
false
false
true
false
false
false
false
false
false
false
3,414
1365E
# Maximum Subsequence Value Input file: standard input Output file: standard output Time limit: 2 seconds Memory limit: 256 megabytes Ridhiman challenged Ashish to find the maximum valued subsequence of an array a of size n consisting of positive integers. The value of a non-empty subsequence of k elements of a is d...
1,900
false
false
false
false
false
true
true
false
false
false
3,853
609F
There are _n_ frogs sitting on the coordinate axis _Ox_. For each frog two values _x__i_,u2009_t__i_ are known — the position and the initial length of the tongue of the _i_-th frog (it is guaranteed that all positions _x__i_ are different). _m_ mosquitoes one by one are landing to the coordinate axis. For each mosquit...
2,500
false
true
false
false
true
false
false
false
false
false
7,407
609B
Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are _n_ books on sale from one of _m_ genres. In the bookshop, Jack decides to buy two books of different genres. Based on the genre of books on sale in the shop, find the ...
1,100
false
false
true
false
false
true
false
false
false
false
7,411
1997C
Monocarp had a regular bracket sequence $$$s$$$ of length $$$n$$$ ($$$n$$$ is even). He even came up with his own way to calculate its cost. He knows that in a regular bracket sequence (RBS), each opening bracket is paired up with the corresponding closing bracket. So he decided to calculate the cost of RBS as the sum ...
1,100
false
true
false
false
true
true
false
false
false
false
281
1844G
You are given a tree with $$$n$$$ nodes labelled $$$1,2,dots,n$$$. The $$$i$$$-th edge connects nodes $$$u_i$$$ and $$$v_i$$$ and has an unknown positive integer weight $$$w_i$$$. To help you figure out these weights, you are also given the distance $$$d_i$$$ between the nodes $$$i$$$ and $$$i+1$$$ for all $$$1 le i le...
3,000
true
false
true
false
true
true
false
false
false
false
1,216
1466B
Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception. His song consists of $$$n$$$ notes, which we will treat as positive integers. The diversity of a song i...
800
false
true
false
true
false
false
false
false
false
false
3,365
527B
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings _S_ and _T_ of equal length to be "similar". After a brief search on th...
1,500
false
true
false
false
false
false
false
false
false
false
7,723
1344E
That's right. I'm a Purdue student, and I shamelessly wrote a problem about trains. There are $$$n$$$ stations and $$$m$$$ trains. The stations are connected by $$$n-1$$$ one-directional railroads that form a tree rooted at station $$$1$$$. All railroads are pointed in the direction from the root station $$$1$$$ to the...
3,100
false
false
false
false
true
false
false
false
false
false
3,983
1711B
A club plans to hold a party and will invite some of its $$$n$$$ members. The $$$n$$$ members are identified by the numbers $$$1, 2, dots, n$$$. If member $$$i$$$ is not invited, the party will gain an unhappiness value of $$$a_i$$$. There are $$$m$$$ pairs of friends among the $$$n$$$ members. As per tradition, if bot...
1,300
false
false
false
false
false
false
true
false
false
true
2,014
818A
There are _n_ students who have taken part in an olympiad. Now it's time to award the students. Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the number of diplomas and c...
800
true
false
true
false
false
false
false
false
false
false
6,487
1560E
Polycarp has a string $$$s$$$. Polycarp performs the following actions until the string $$$s$$$ is empty ($$$t$$$ is initially an empty string): he adds to the right to the string $$$t$$$ the string $$$s$$$, i.e. he does $$$t = t + s$$$, where $$$t + s$$$ is a concatenation of the strings $$$t$$$ and $$$s$$$; he sele...
1,800
false
false
true
false
false
false
false
true
true
false
2,826
1929B
Even in kindergarten, Sasha liked a girl. Therefore, he wanted to give her a drawing and attract her attention. As a drawing, he decided to draw a square grid of size $$$n imes n$$$, in which some cells are colored. But coloring the cells is difficult, so he wants to color as few cells as possible. But at the same tim...
800
true
true
false
false
false
true
false
false
false
false
716
111D
Problem - 111D - 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
9,439
720A
The closing ceremony of Squanch Code Cup is held in the big hall with _n_u2009×u2009_m_ seats, arranged in _n_ rows, _m_ seats in a row. Each seat has two coordinates (_x_,u2009_y_) (1u2009≤u2009_x_u2009≤u2009_n_, 1u2009≤u2009_y_u2009≤u2009_m_). There are two queues of people waiting to enter the hall: _k_ people are s...
2,000
false
true
false
false
false
false
false
false
false
false
6,937
1867D
Egor has an array $$$a$$$ of length $$$n$$$, initially consisting of zeros. However, he wanted to turn it into another array $$$b$$$ of length $$$n$$$. Since Egor doesn't take easy paths, only the following operation can be used (possibly zero or several times): choose an array $$$l$$$ of length $$$k$$$ ($$$1 leq l_i ...
1,800
false
true
true
false
false
true
true
false
false
true
1,072
582A
Problem - 582A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,700
false
true
false
false
false
true
false
false
false
false
7,517
1527D
You are given a tree with $$$n$$$ nodes, numerated from $$$0$$$ to $$$n-1$$$. For each $$$k$$$ between $$$0$$$ and $$$n$$$, inclusive, you have to count the number of unordered pairs $$$(u,v)$$$, $$$u eq v$$$, such that the MEX of all the node labels in the shortest path from $$$u$$$ to $$$v$$$ (including end points) ...
2,400
true
false
true
false
false
false
false
false
false
false
3,025
182E
Vasya has recently bought some land and decided to surround it with a wooden fence. He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company has at its disposal _n_ different types of wood. The company uses the _i_-th type of wood to produ...
1,800
false
false
false
true
false
false
false
false
false
false
9,110
1828A
You are given a positive integer $$$n$$$. Please find an array $$$a_1, a_2, ldots, a_n$$$ that is perfect. A perfect array $$$a_1, a_2, ldots, a_n$$$ satisfies the following criteria: $$$1 le a_i le 1000$$$ for all $$$1 le i le n$$$. $$$a_i$$$ is divisible by $$$i$$$ for all $$$1 le i le n$$$. $$$a_1 + a_2 + ldots +...
800
true
false
false
false
false
true
false
false
false
false
1,316
1669H
Let $$$mathsf{AND}$$$ denote the and replace $$$a_i$$$ with $$$a_i$$$ $$$mathsf{OR}$$$ $$$2^j$$$ where $$$j$$$ is any integer between $$$0$$$ and $$$30$$$ inclusive. In other words, in an operation you can choose an index $$$i$$$ ($$$1 leq i leq n$$$) and set the $$$j$$$-th bit of $$$a_i$$$ to $$$1$$$ ($$$0 leq j leq 3...
1,300
true
true
false
false
false
false
false
false
false
false
2,258
702E
You are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to _n_u2009-u20091. Graph is given as the array _f_0,u2009_f_1,u2009...,u2009_f__n_u2009-u20091, where _f__i_ — the number of vertex to which goes the only arc from the vertex _i_....
2,100
false
false
false
false
true
false
false
false
false
true
7,013
374B
Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number _a_, consisting of digits from 1 to 9. Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine...
1,500
false
true
false
false
false
false
false
false
false
false
8,335
1037F
Given an array $$$a$$$ of $$$n$$$ integers and an integer $$$k$$$ ($$$2 le k le n$$$), where each element of the array is denoted by $$$a_i$$$ ($$$0 le i < n$$$). Perform the operation $$$z$$$ given below on $$$a$$$ and print the value of $$$z(a,k)$$$ modulo $$$10^{9}+7$$$. function z(array a, integer k): if length...
2,500
true
false
false
false
true
false
false
false
false
false
5,511
1660F2
This is the hard version of Problem F. The only difference between the easy version and the hard version is the constraints. We will call a non-empty string balanced if it contains the same number of plus and minus signs. For example: strings "+--+" and "++-+--" are balanced, and strings "+--", "--" and "" are not bala...
2,100
true
false
true
false
true
false
false
false
false
false
2,320
1845E
There are $$$n$$$ boxes placed in a line. The boxes are numbered from $$$1$$$ to $$$n$$$. Some boxes contain one ball inside of them, the rest are empty. At least one box contains a ball and at least one box is empty. In one move, you have to choose a box with a ball inside and an adjacent empty box and move the ball f...
2,500
true
false
true
true
false
false
false
false
false
false
1,210
1060B
Problem - 1060B - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - ...
1,100
false
true
false
false
false
false
false
false
false
false
5,415
1814E
You are given an undirected graph consisting of $$$n$$$ vertices and $$$n-1$$$ edges. The $$$i$$$-th edge has weight $$$a_i$$$; it connects the vertices $$$i$$$ and $$$i+1$$$. Initially, each vertex contains a chip. Each chip has an integer written on it; the integer written on the chip in the $$$i$$$-th vertex is $$$i...
2,300
false
false
false
true
true
false
false
false
false
false
1,383
1763F
You are given an undirected, connected graph of $$$n$$$ nodes and $$$m$$$ edges. All nodes $$$u$$$ of the graph satisfy the following: Let $$$S_u$$$ be the set of vertices in the longest simple cycle starting and ending at $$$u$$$. Let $$$C_u$$$ be the union of the sets of vertices in any simple cycle starting and en...
3,000
false
false
false
true
true
false
false
false
false
true
1,728
713A
Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her _t_ queries, each of one of the following type: 1. u2009+u2009 _a__i_xa0— add non-negative integer _a__i_ to the multiset. Note, that she has a multiset, thus there...
1,400
false
false
true
false
true
false
false
false
false
false
6,966
1776L
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it. Initially, your score is $$$0$$$. The game is composed of $$$n$$$ rounds. For each $$$1le ile n$$$, the $$$i$$$-th round works as follows. On t...
1,500
true
false
false
false
false
false
false
true
false
false
1,617
33D
Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came _n_ knights. After long discussions it became clear that the kingdom has exactly _n_ control points (if the enemy conquers at least one o...
2,000
false
false
false
false
false
false
false
false
true
true
9,830
1985A
Problem - 1985A - 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
false
false
true
false
false
false
false
false
false
false
374
2021D
Pak Chanek has a friend who runs a drink stall in a canteen. His friend will sell drinks for $$$n$$$ days, numbered from day $$$1$$$ to day $$$n$$$. There are also $$$m$$$ types of drinks, numbered from $$$1$$$ to $$$m$$$. The profit gained from selling a drink on a particular day can vary. On day $$$i$$$, the projecte...
2,500
false
true
true
true
false
false
false
false
false
false
142
1992F
In his favorite cafe Kmes once again wanted to try the herring under a fur coat. Previously, it would not have been difficult for him to do this, but the cafe recently introduced a new purchasing policy. Now, in order to make a purchase, Kmes needs to solve the following problem: $$$n$$$ cards with prices for different...
1,900
false
true
false
true
false
false
true
false
false
false
314
1773E
Emma loves playing with blocks. She has several cubic blocks of the same size that are numbered with distinct integers written on them. She assembles towers from those blocks by stacking them vertically. A configuration of her game is a set of towers that she has assembled from the blocks. Emma can perform two kinds of...
1,400
false
true
false
false
false
false
false
false
true
false
1,652
1036D
Vasya has two arrays $$$A$$$ and $$$B$$$ of lengths $$$n$$$ and $$$m$$$, respectively. He can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a single element, equal to the sum of all elements on this subsegment. For examp...
1,600
false
true
false
false
false
false
false
false
false
false
5,520
1981E
Turtle just received $$$n$$$ segments and a sequence $$$a_1, a_2, ldots, a_n$$$. The $$$i$$$-th segment is $$$[l_i, r_i]$$$. Turtle will create an undirected graph $$$G$$$. If segment $$$i$$$ and segment $$$j$$$ intersect, then Turtle will add an undirected edge between $$$i$$$ and $$$j$$$ with a weight of $$$a_i - a_j...
2,600
false
true
false
false
true
false
false
false
false
true
398
584C
Problem - 584C - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,700
false
true
false
false
false
true
false
false
false
false
7,508
772E
This is an interactive problem. The judge has a hidden rooted full binary tree with _n_ leaves. A full binary tree is one where every node has either 0 or 2 children. The nodes with 0 children are called the leaves of the tree. Since this is a full binary tree, there are exactly 2_n_u2009-u20091 nodes in the tree. The ...
3,200
false
false
false
false
false
false
false
true
false
false
6,688
1092B
There are $$$n$$$ students in a university. The number of students is even. The $$$i$$$-th student has programming skill equal to $$$a_i$$$. The coach wants to form $$$frac{n}{2}$$$ teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team ...
800
false
false
false
false
false
false
false
false
true
false
5,250
289A
Problem - 289A - Codeforces =============== xa0 ]( --- Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - s...
1,100
false
false
true
false
false
false
true
false
false
false
8,679
487E
There are _n_ cities in Cyberland, numbered from 1 to _n_, connected by _m_ bidirectional roads. The _j_-th road connects city _a__j_ and _b__j_. For tourists, souvenirs are sold in every city of Cyberland. In particular, city _i_ sell it at a price of _w__i_. Now there are _q_ queries for you to handle. There are two ...
3,200
false
false
false
false
true
false
false
false
false
true
7,886
851A
Problem - 851A - 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
true
false
true
false
false
false
false
false
false
false
6,345
254B
In 2013, the writers of Berland State University should prepare problems for _n_ Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to _n_. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the prob...
1,500
false
false
true
false
false
false
true
false
false
false
8,818
592A
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess». This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed ...
1,200
false
false
true
false
false
false
false
false
false
false
7,482
862F
Mahmoud and Ehab solved Dr. Evil's questions so he gave them the password of the door of the evil land. When they tried to open the door using it, the door gave them a final question to solve before they leave (yes, the door is digital, Dr. Evil is modern). If they don't solve it, all the work will be useless and they ...
2,900
false
false
false
false
true
false
false
false
false
false
6,295
169A
Petya and Vasya are brothers. Today is a special day for them as their parents left them home alone and commissioned them to do _n_ chores. Each chore is characterized by a single parameter — its complexity. The complexity of the _i_-th chore equals _h__i_. As Petya is older, he wants to take the chores with complexity...
800
false
false
false
false
false
false
false
false
true
false
9,188
1551D1
The only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2. There's a table of $$$n imes m$$$ cells ($$$n$$$ rows and $$$m$$$ columns). The value of $$$n cdot m$$$ is even. A domino is a figure that consists of two cell...
1,700
true
false
false
false
false
true
false
false
false
false
2,888
1706D1
This is the easy version of the problem. The only difference between the versions is the constraints on $$$n$$$, $$$k$$$, $$$a_i$$$, and the sum of $$$n$$$ over all test cases. You can make hacks only if both versions of the problem are solved. Note the unusual memory limit. You are given an array of integers $$$a_1, a...
1,700
false
true
false
false
false
true
true
true
false
false
2,037
798C
Mike has a sequence _A_u2009=u2009[_a_1,u2009_a_2,u2009...,u2009_a__n_] of length _n_. He considers the sequence _B_u2009=u2009[_b_1,u2009_b_2,u2009...,u2009_b__n_] beautiful if the _gcd_ of all its elements is bigger than 1, i.e. . Mike wants to change his sequence in order to make it beautiful. In one move he can cho...
1,700
false
true
false
true
false
false
false
false
false
false
6,579
1447B
You are given a rectangular grid with $$$n$$$ rows and $$$m$$$ columns. The cell located on the $$$i$$$-th row from the top and the $$$j$$$-th column from the left has a value $$$a_{ij}$$$ written in it. You can perform the following operation any number of times (possibly zero): Choose any two adjacent cells and mult...
1,000
true
true
false
false
false
false
false
false
false
false
3,439
1468K
There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates $$$(0, 0)$$$. He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U'. When a command is executed, the robot simply moves in the correspondin...
1,600
false
false
true
false
false
false
true
false
false
false
3,342
1243A
Ujan decided to make a new wooden roof for the house. He has $$$n$$$ rectangular planks numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th plank has size $$$a_i imes 1$$$ (that is, the width is $$$1$$$ and the height is $$$a_i$$$). Now, Ujan wants to make a square roof. He will first choose some of the planks and place ...
800
false
false
true
false
false
false
false
false
false
false
4,484
286D
A double tourist path, located at a park in Ultima Thule, is working by the following principle: We introduce the Cartesian coordinate system. At some points of time there are two tourists going (for a walk) from points (u2009-u20091,u20090) and (1,u20090) simultaneously. The first one is walking from (u2009-u20091,u...
2,600
false
false
false
false
true
false
false
false
true
false
8,688
1328D
The round carousel consists of $$$n$$$ figures of animals. Figures are numbered from $$$1$$$ to $$$n$$$ in order of the carousel moving. Thus, after the $$$n$$$-th figure the figure with the number $$$1$$$ follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger ...
1,800
true
true
false
true
false
true
false
false
false
true
4,068
107A
The German University in Cairo (GUC) dorm houses are numbered from 1 to _n_. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa), and diameter (which characterizes the maximal amount of water it can handle). For each house, th...
1,400
false
false
false
false
false
false
false
false
false
true
9,456
883L
Berland.Taxi is a new taxi company with _k_ cars which started operating in the capital of Berland just recently. The capital has _n_ houses on a straight line numbered from 1 (leftmost) to _n_ (rightmost), and the distance between any two neighboring houses is the same. You have to help the company schedule all the ta...
2,500
false
false
false
false
true
false
false
false
false
false
6,216
1249A
You are a coach of a group consisting of $$$n$$$ students. The $$$i$$$-th student has programming skill $$$a_i$$$. All students have distinct programming skills. You want to divide them into teams in such a way that: No two students $$$i$$$ and $$$j$$$ such that $$$a_i - a_j = 1$$$ belong to the same team (i.e. skills...
800
true
false
false
false
false
false
false
false
false
false
4,464
1239D
In the Catowice city next weekend the cat contest will be held. However, the jury members and the contestants haven't been selected yet. There are $$$n$$$ residents and $$$n$$$ cats in the Catowice, and each resident has exactly one cat living in his house. The residents and cats are numbered with integers from $$$1$$$...
2,400
false
false
false
false
false
false
false
false
false
true
4,493
1907A
Problem - 1907A - 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
false
false
true
false
false
false
false
false
false
false
864
1615A
There are $$$n$$$ block towers in a row, where tower $$$i$$$ has a height of $$$a_i$$$. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation: Choose two indices $$$i$$$ and $$$j$$$ ($$$1 leq i, j leq n$$$; $$$i eq j$$$), ...
800
true
true
false
false
false
false
false
false
false
false
2,564
1909E
You have $$$n$$$ lamps, numbered from $$$1$$$ to $$$n$$$. Initially, all the lamps are turned off. You also have $$$n$$$ buttons. The $$$i$$$-th button toggles all the lamps whose index is a multiple of $$$i$$$. When a lamp is toggled, if it was off it turns on, and if it was on it turns off. You have to press some but...
2,400
true
false
false
false
false
true
true
false
false
false
853
1466F
You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. In his bad dream Euclid has a set $$$S$$$ of $$$n$$$ $$$m$$$-dimensional vectors over the $$$mathbb{Z}_2$$$ field and can perform vector addi...
2,100
true
true
false
false
false
false
false
false
true
true
3,361
2023E
In the heart of an ancient kingdom grows the legendary Tree of Life — the only one of its kind and the source of magical power for the entire world. The tree consists of $$$n$$$ nodes. Each node of this tree is a magical source, connected to other such sources through magical channels (edges). In total, there are $$$n-...
3,300
false
true
false
true
false
false
false
false
false
false
127
1666E
A revolution has recently happened in Segmentland. The new government is committed to equality, and they hired you to help with land redistribution in the country. Segmentland is a segment of length $$$l$$$ kilometers, with the capital in one of its ends. There are $$$n$$$ citizens in Segmentland, the home of $$$i$$$-t...
2,500
true
true
false
false
false
true
false
true
false
false
2,281
496D
Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores _t_ points, he wins the set; then the ...
1,900
false
false
false
false
false
false
false
true
false
false
7,848
515A
Problem - 515A - 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
true
false
false
false
false
false
false
false
false
false
7,775
151B
Winters are just damn freezing cold in Nvodsk! That's why a group of _n_ friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size _s__i_ (that's the number of phone numbers). We know that tax...
1,200
false
false
true
false
false
false
false
false
false
false
9,270
1204D2
The only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems. Kirk has a binary string $$$s$$$ (a string which consists of zeroes and ones) of length $$$n$$$ and he is asking you to find a...
2,100
true
true
false
false
true
false
false
false
false
false
4,671
1884B
You are given a number in binary representation consisting of exactly $$$n$$$ bits, possibly, with leading zeroes. For example, for $$$n = 5$$$ the number $$$6$$$ will be given as $$$00110$$$, and for $$$n = 4$$$ the number $$$9$$$ will be given as $$$1001$$$. Let's fix some integer $$$i$$$ such that $$$1 le i le n$$$....
1,100
true
true
false
false
false
false
false
true
false
false
982
1632B
It has finally been decided to build a roof over the football field in School 179. Its construction will require placing $$$n$$$ consecutive vertical pillars. Furthermore, the headmaster wants the heights of all the pillars to form a permutation $$$p$$$ of integers from $$$0$$$ to $$$n - 1$$$, where $$$p_i$$$ is the he...
1,000
false
false
false
false
false
true
false
false
false
false
2,457
67B
Problem - 67B - Codeforces =============== xa0 . For example, if _n_u2009=u20095, a possible _A_ is {5,u20091,u20094,u20092,u20093}. For _k_u2009=u20092, _B_ is given by {1,u20092,u20091,u20090,u20090}. But if _k_u2009=u20093, then _B_u2009=u2009{1,u20091,u20090,u20090,u20090}. For two sequences _X_u2009=u200...
1,800
false
true
false
false
false
false
false
false
false
false
9,635
1365A
Ashish and Vivek play a game on a matrix consisting of $$$n$$$ rows and $$$m$$$ columns, where they take turns claiming cells. Unclaimed cells are represented by $$$0$$$, while claimed cells are represented by $$$1$$$. The initial state of the matrix is given. There can be some claimed cells in the initial state. In ea...
1,100
false
true
true
false
false
false
false
false
false
false
3,857
1824B1
This is the easy version of the problem. The only difference is that in this version $$$klemin(n,3)$$$. You can make hacks only if both versions of the problem are solved. Chtholly and the floating islands. LuoTianyi now lives in a world with $$$n$$$ floating islands. The floating islands are connected by $$$n-1$$$ un...
1,800
true
false
false
false
false
false
false
false
false
false
1,336
1183A
Problem - 1183A - 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
false
false
true
false
false
false
false
false
false
false
4,802
1839D
There are $$$n$$$ colorful balls arranged in a row. The balls are painted in $$$n$$$ distinct colors, denoted by numbers from $$$1$$$ to $$$n$$$. The $$$i$$$-th ball from the left is painted in color $$$c_i$$$. You want to reorder the balls so that the $$$i$$$-th ball from the left has color $$$i$$$. Additionally, you ...
2,100
false
false
false
true
true
false
false
false
true
false
1,255
1141B
Each day in Berland consists of $$$n$$$ hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence $$$a_1, a_2, dots, a_n$$$ (each $$$a_i$$$ is either $$$0$$$ or $$$1$$$), where $$$a_i=0$$$ if Polycarp works during the $$$i$$$-th hour of the day and $$$a_i=1$$$ if Polycarp...
900
false
false
true
false
false
false
false
false
false
false
5,020
1361D
# Johnny and James Input file: standard input Output file: standard output Time limit: 2 seconds Memory limit: 256 megabytes James Bond, Johnny’s favorite secret agent, has a new mission. There are n enemy bases, each of them is described by its coordinates so that we can think about them as points in the Cartesian ...
2,900
true
true
true
false
false
false
false
false
false
false
3,874
1971G
You are given an array $$$a$$$ consisting of $$$n$$$ nonnegative integers. You can swap the elements at positions $$$i$$$ and $$$j$$$ if $$$a_i~mathsf{XOR}~a_j < 4$$$, where $$$mathsf{XOR}$$$ is the xa0— the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 leq n leq 2cdot10...
1,700
false
false
false
false
true
false
false
false
true
false
459
313C
Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve. He's got a square 2_n_u2009×u20092_n_-sized matrix and 4_n_ integers. You need to arrange all these numbers in the matrix (put each number in a sin...
1,400
false
true
true
false
false
true
false
false
true
false
8,593
1798A
You are given two arrays $$$a_1, a_2, ldots, a_n$$$ and $$$b_1, b_2, ldots, b_n$$$. In one operation, you can choose any integer $$$i$$$ from $$$1$$$ to $$$n$$$ and swap the numbers $$$a_i$$$ and $$$b_i$$$. Determine whether, after using any (possibly zero) number of operations, the following two conditions can be sati...
800
false
true
true
false
false
false
false
false
true
false
1,490