task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Coloring a Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rooted tree with *n* vertices. The vertices are numbered from 1 to *n*, the root is the vertex number 1. Each vertex has a color, let's denote the color of vertex *v* by *c**v*. Initially *c**v*<==<=0. ...
1,000
Title: st-Spanning Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected connected graph consisting of *n* vertices and *m* edges. There are no loops and no multiple edges in the graph. You are also given two distinct vertices *s* and *t*, and two values *d**s* ...
1,001
Title: Frog Fights Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ostap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into *m* cells. Cells are numbered from 1 to *m*, but the board is cyclic, so ...
1,002
Title: Interactive Bulls and Cows (Hard) Time Limit: None seconds Memory Limit: None megabytes Problem Description: The only difference from the previous problem is the constraint on the number of requests. In this problem your program should guess the answer doing at most 7 requests. This problem is a little bit u...
1,003
Title: Video Cards Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to ...
1,004
Title: Trial for Chief Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Having unraveled the Berland Dictionary, the scientists managed to read the notes of the chroniclers of that time. For example, they learned how the chief of the ancient Berland tribe was chosen. As soon as enough pretende...
1,005
Title: Exams Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasiliy has an exam period which will continue for *n* days. He has to pass exams on *m* subjects. Subjects are numbered from 1 to *m*. About every day we know exam for which one of *m* subjects can be passed on that day. Perhap...
1,006
Title: Ant Man Time Limit: None seconds Memory Limit: None megabytes Problem Description: Scott Lang is at war with Darren Cross. There are *n* chairs in a hall where they are, numbered with 1,<=2,<=...,<=*n* from left to right. The *i*-th chair is located at coordinate *x**i*. Scott is on chair number *s* and Cross...
1,007
Title: Bets Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allow...
1,008
Title: Water Taps Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider a system of *n* water taps all pouring water into the same container. The *i*-th water tap can be set to deliver any amount of water from 0 to *a**i* ml per second (this amount may be a real number). The water deliv...
1,009
Title: Polyline Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only s...
1,010
Title: Restore Cube Time Limit: None seconds Memory Limit: None megabytes Problem Description: Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay at integer points (it is possible that the cube's sides are not parallel to the coordinate ...
1,011
Title: Mashmokh's Designed Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: After a lot of trying, Mashmokh designed a problem and it's your job to solve it. You have a tree *T* with *n* vertices. Each vertex has a unique index from 1 to *n*. The root of *T* has index 1. For each v...
1,012
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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. Petya has ...
1,013
Title: A Simple Task Time Limit: None seconds Memory Limit: None megabytes Problem Description: This task is very simple. Given a string *S* of length *n* and *q* queries each query is on the format *i* *j* *k* which means sort the substring consisting of the characters from *i* to *j* in non-decreasing order if *k*...
1,014
Title: Tram Time Limit: None seconds Memory Limit: None megabytes Problem Description: The tram in Berland goes along a straight line from the point 0 to the point *s* and back, passing 1 meter per *t*1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly...
1,015
Title: Guard Duty (medium) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Princess Heidi decided to give orders to all her *K* Rebel ship commanders in person. Unfortunately, she is currently travelling through hyperspace, and will leave it only at *N* specific moments *t*1,<=*t*2,<=...,<...
1,016
Title: Olympiad Time Limit: None seconds Memory Limit: None megabytes Problem Description: A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least *x* points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but th...
1,017
Title: The Wall (medium) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC2 (Handbook of Crazy Constructions) and looks ...
1,018
Title: Three Sons Time Limit: None seconds Memory Limit: None megabytes Problem Description: Three sons inherited from their father a rectangular corn fiend divided into *n*<=×<=*m* squares. For each square we know how many tons of corn grows on it. The father, an old farmer did not love all three sons equally, whic...
1,019
Title: Buns Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Lavrenty, a baker, is going to make several buns with stuffings and sell them. Lavrenty has *n* grams of dough as well as *m* different stuffing types. The stuffing types are numerated from 1 to *m*. Lavrenty knows that he has *a**i*...
1,020
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Artem has an array of *n* positive integers. Artem decided to play with it. The game consists of *n* moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets *min*(*a*,<=*b*) point...
1,021
Title: PolandBall and Gifts Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are *n* Balls overall. Each Ball has someone for whom he should bring a present according to some permutation *p*, *p**i*<=≠<=*...
1,022
Title: Fancy Number Time Limit: None seconds Memory Limit: None megabytes Problem Description: A car number in Berland consists of exactly *n* digits. A number is called beautiful if it has at least *k* equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace...
1,023
Title: Playing Cubes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya and Vasya decided to play a little. They found *n* red cubes and *m* blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (...
1,024
Title: Tree of Life (hard) Time Limit: None seconds Memory Limit: None megabytes Problem Description: To add insult to injury, the zombies have taken all but two drawings from Heidi! Please help her recover the Tree of Life from only these two drawings. Input Specification: The input format is the same as in the me...
1,025
Title: Inverse Function Time Limit: 5 seconds Memory Limit: 64 megabytes Problem Description: Petya wrote a programme on C++ that calculated a very interesting function *f*(*n*). Petya ran the program with a certain value of *n* and went to the kitchen to have some tea. The history has no records concerning how long...
1,026
Title: Sereja and Table Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja has an *n*<=×<=*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 re...
1,027
Title: Tree and Table Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya likes trees a lot. Recently his mother has presented him a tree with 2*n* nodes. Petya immediately decided to place this tree on a rectangular table consisting of 2 rows and *n* columns so as to fulfill the ...
1,028
Title: Sereja and Prefixes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm. Sereja takes a blank piece of paper. Then he starts writing out the sequence in *m* stages. Ea...
1,029
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vova has recently learned what a circulaton in a graph is. Recall the definition: let $G = (V, E)$ be a directed graph. A circulation $f$ is such a collection of non-negative real numbers $f_e$ ($e \in E$), that for each vertex $v...
1,030
Title: One-dimensional Japanese Crossword Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized *a*<=×<=*b* squares, and each square is colored white or black. There are integers to the...
1,031
Title: Fibonotci Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fibonotci sequence is an integer recursive sequence defined by the recurrence relation Sequence *s* is an infinite and almost cyclic sequence with a cycle of length *N*. A sequence *s* is called almost cyclic with a cycle o...
1,032
Title: Two Problems Time Limit: None seconds Memory Limit: None megabytes Problem Description: A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as *x* points for his first contest. But Arkady did not believe his frien...
1,033
Title: How many trees? Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong — the oldest among the inhabitants of Mainframe. But still he managed to get some information from ...
1,034
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are *n* bott...
1,035
Title: April Fools' Problem (easy) Time Limit: None seconds Memory Limit: None megabytes Problem Description: The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers *n*, *k* and a sequence of *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*. They also came up with a beautif...
1,036
Title: Devu and his Brother Time Limit: None seconds Memory Limit: None megabytes Problem Description: Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays *a* and *b* by their father. The array *a* is given to Devu and *b* to his brother....
1,037
Title: Help Greg the Dwarf 2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: Greg the Dwarf has been really busy recently with excavations by the Neverland Mountain. However for the well-known reasons (as you probably remember he is a very unusual dwarf and he cannot stand sunlight) Greg c...
1,038
Title: Right Triangles Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: You are given a *n*<=×<=*m* field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. ...
1,039
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal nu...
1,040
Title: One Bomb Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a description of a depot. It is a rectangular checkered field of *n*<=×<=*m* size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the ce...
1,041
Title: Parallelepiped Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped. Input S...
1,042
Title: Bear and Tree Jumps Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them. Limak is a little polar bear. He lives in a tree that consists of *n* ...
1,043
Title: XOR and OR Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. A Bitlandish string is a string made only of characters "0" and "1". ...
1,044
Title: Driving Test Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types. - speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (c...
1,045
Title: Thwarting Demonstrations Time Limit: None seconds Memory Limit: None megabytes Problem Description: It is dark times in Berland. Berlyand opposition, funded from a neighboring state, has organized a demonstration in Berland capital Bertown. Through the work of intelligence we know that the demonstrations are ...
1,046
Title: Visible Black Areas Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya has a polygon consisting of $n$ vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the p...
1,047
Title: Arpa’s obvious problem and Mehrdad’s terrible solution Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious problem: Given an array and a number *x*, count the number of pairs of indice...
1,048
Title: Labyrinth-13 Time Limit: None seconds Memory Limit: None megabytes Problem Description: See the problem statement here: [http://codeforces.com/contest/921/problem/01](//codeforces.com/contest/921/problem/01). Input Specification: none Output Specification: none Note: none
1,049
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation *p* of length *n* or its cyclic shift. For the further investigation ...
1,050
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arpa has found a list containing *n* numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is 1. Arpa can perform two types of operations: - Choose a...
1,051
Title: Rectangular Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has *n* pebbles. He arranges them in...
1,052
Title: Special Offer! Super Price 999 Bourles! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus is an amateur businessman. Recently he was surprised to find out that the market for paper scissors is completely free! Without further ado, Polycarpus decided to start producing and s...
1,053
Title: Petya and Divisors Time Limit: 5 seconds Memory Limit: 256 megabytes Problem Description: Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given *n* queries in the form "*x**i* *y**i*". For each query Petya should count how many divisors of number *x*...
1,054
Title: Book of Evil Time Limit: None seconds Memory Limit: None megabytes Problem Description: Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains *n* settlements numbered from 1 to *n*. Moving through the swamp is very difficult, so people tramped exactly *n*<=-<=1 paths....
1,055
Title: Multitasking Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahub wants to enhance his multitasking abilities. In order to do this, he wants to sort *n* arrays simultaneously, each array consisting of *m* integers. Iahub can choose a pair of distinct indices *i* and *j* (1<=≤<=*i*...
1,056
Title: Delivery Bears Time Limit: None seconds Memory Limit: None megabytes Problem Description: Niwel is a little golden bear. As everyone knows, bears live in forests, but Niwel got tired of seeing all the trees so he decided to move to the city. In the city, Niwel took on a job managing bears to deliver goods. T...
1,057
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as: - ...
1,058
Title: Bear and Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Lim...
1,059
Title: Two Sets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya likes numbers a lot. Recently his mother has presented him a collection of *n* non-negative integers. There's only one thing Petya likes more than numbers: playing with little Masha. He immediately decided to give...
1,060
Title: Valera and Plates Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valera is a lazy student. He has *m* clean bowls and *k* clean plates. Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, ...
1,061
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus has a chessboard of size *n*<=×<=*m*, where *k* rooks are placed. Polycarpus hasn't yet invented the rules of the game he will play. However, he has already allocated *q* rectangular areas of special strategic importanc...
1,062
Title: Interval Cubing Time Limit: None seconds Memory Limit: None megabytes Problem Description: While learning Computational Geometry, Tiny is simultaneously learning a useful data structure called segment tree or interval tree. He has scarcely grasped it when comes out a strange problem: Given an integer sequenc...
1,063
Title: Divisiblity of Differences Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a multiset of *n* integers. You should select exactly *k* of them in a such way that the difference between any two of them is divisible by *m*, or tell that it is impossible. Numbers can be re...
1,064
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road. We assume that the a...
1,065
Title: Numbers Exchange Time Limit: None seconds Memory Limit: None megabytes Problem Description: Eugeny has *n* cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and th...
1,066
Title: Clues Time Limit: None seconds Memory Limit: None megabytes Problem Description: As Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the direct link ...
1,067
Title: Ilya and Two Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ilya has recently taken up archaeology. He's recently found two numbers, written in the *m*-based notation. Each of the found numbers consisted of exactly *n* digits. Ilya immediately started looking for informatio...
1,068
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water. The only dry land there is an archipelago of *n* narrow islands located in a ...
1,069
Title: Network Configuration Time Limit: None seconds Memory Limit: None megabytes Problem Description: The R1 company wants to hold a web search championship. There were *n* computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly a...
1,070
Title: King Moves Time Limit: None seconds Memory Limit: None megabytes Problem Description: The only king stands on the standard chess board. You are given his position in format "cd", where *c* is the column from 'a' to 'h' and *d* is the row from '1' to '8'. Find the number of moves permitted for the king. Check...
1,071
Title: Terse princess Time Limit: None seconds Memory Limit: None megabytes Problem Description: «Next please», — the princess called and cast an estimating glance at the next groom. The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each ...
1,072
Title: Points on the line Time Limit: None seconds Memory Limit: None megabytes Problem Description: We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round. The diameter of a multiset of points on the line is the largest dista...
1,073
Title: Minimal Labels Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a directed acyclic graph with *n* vertices and *m* edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected. You should assign labels to all vertices in such...
1,074
Title: Thief in a Shop Time Limit: None seconds Memory Limit: None megabytes Problem Description: A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain *k* objects. There are *n* kinds of products in the shop and an infinite number of products of each kind. The cost o...
1,075
Title: GCD of Polynomials Time Limit: None seconds Memory Limit: None megabytes Problem Description: Suppose you have two polynomials and . Then polynomial can be uniquely represented in the following way: This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, denot...
1,076
Title: Boxes And Balls Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ivan has *n* different boxes. The first of them contains some balls of *n* different colors. Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every *i* (1<=≤<=*i*<=≤...
1,077
Title: Gena and Second Distance Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gena doesn't like geometry, so he asks you to solve this problem for him. A rectangle with sides parallel to coordinate axes contains *n* dots. Let's consider some point of the plane. Let's count the distances...
1,078
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has found the beautiful permutation formula. Let's take permutation *p*<==<=*p*1,<=*p*2,<=...,<=*p**n*. Let's define transformation *f* of this permutation: where *k* (*k*<=&gt;<=1) is an integer, the transformation pa...
1,079
Title: Alyona and copybooks Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the sh...
1,080
Title: Office Keys Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* people and *k* keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office...
1,081
Title: cAPS lOCK Time Limit: None seconds Memory Limit: None megabytes Problem Description: wHAT DO WE NEED cAPS LOCK FOR? Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in th...
1,082
Title: The Closest Pair Time Limit: None seconds Memory Limit: None megabytes Problem Description: Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time L...
1,083
Title: Nineteen Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice likes word "nineteen" very much. She has a string *s* and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiinetee...
1,084
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Память компьютера состоит из *n* ячеек, которые выстроены в ряд. Пронумеруем ячейки от 1 до *n* слева направо. Про каждую ячейку известно, свободна она или принадлежит какому-либо процессу (в таком случае известен процесс, котором...
1,085
Title: Minimum Binary Number Time Limit: None seconds Memory Limit: None megabytes Problem Description: String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001". You are given a correct string *s*. You can perform two...
1,086
Title: Red and Blue Balls Time Limit: None seconds Memory Limit: None megabytes Problem Description: User ainta has a stack of *n* red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack. - While the top ball inside the stack is red, pop the ball from the top of ...
1,087
Title: Color the Carpet Time Limit: None seconds Memory Limit: None megabytes Problem Description: Even polar bears feel cold when lying on the ice. Therefore, a polar bear Alice is going to make a carpet. The carpet can be viewed as a grid with height *h* and width *w*. Then the grid is divided into *h*<=×<=*w* squ...
1,088
Title: Random Teams Time Limit: None seconds Memory Limit: None megabytes Problem Description: *n* participants of the competition were split into *m* teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is ...
1,089
Title: Pyramids Time Limit: None seconds Memory Limit: None megabytes Problem Description: IT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is that it...
1,090
Title: Word Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it ei...
1,091
Title: Crazy Town Time Limit: None seconds Memory Limit: None megabytes Problem Description: Crazy Town is a plane on which there are *n* infinite line roads. Each road is defined by the equation *a**i**x*<=+<=*b**i**y*<=+<=*c**i*<==<=0, where *a**i* and *b**i* are not both equal to the zero. The roads divide the pl...
1,092
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array *a*1,<=*a*2,<=...,<=*a**n* consisting of *n* integers, and an integer *k*. You have to split the array into exactly *k* non-empty subsegments. You'll then compute the minimum integer on each subsegment, and ...
1,093
Title: Ann and Books Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Ann's favorite book shop are as many as *n* books on math and economics. Books are numbered from 1 to *n*. Each of them contains non-negative number of problems. Today there is a sale: any subsegment of a segment from...
1,094
Title: Ilya and Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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*<=×<=2*n*-sized matrix ...
1,095
Title: DZY Loves Games Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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 c...
1,096
Title: Accounting Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself. The total income *A* of his kingdom during 0-th year is known, as well as th...
1,097
Title: Ivan the Fool VS Gorynych the Dragon Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Once upon a time in a kingdom far, far away… Okay, let’s start at the point where Ivan the Fool met Gorynych the Dragon. Ivan took out his magic sword and the battle began. First Gorynych had *h* heads ...
1,098
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu... Whereas on the other end of the world Pentagon is actively coll...
1,099