task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Fashion in Berland Time Limit: None seconds Memory Limit: None megabytes Problem Description: According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened,...
3,700
Title: Subset Sums Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array *a*1,<=*a*2,<=...,<=*a**n* and *m* sets *S*1,<=*S*2,<=...,<=*S**m* of indices of elements of this array. Let's denote *S**k*<==<={*S**k*,<=*i*}Β (1<=≀<=*i*<=≀<=|*S**k*|). In other words, *S**k*,<=*i* i...
3,701
Title: Elimination Time Limit: None seconds Memory Limit: None megabytes Problem Description: The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination round...
3,702
Title: GukiZ and Binary Operations Time Limit: None seconds Memory Limit: None megabytes Problem Description: We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays *a*, of length *n*, with non-negative elements strictly less then 2*l* meet the following condition: ?...
3,703
Title: Divisors Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bizon the Champion isn't just friendly, he also is a rigorous coder. Let's define function *f*(*a*), where *a* is a sequence of integers. Function *f*(*a*) returns the following sequence: first all divisors of *a*1 go in the ...
3,704
Title: Polygon Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus loves convex polygons, especially if all their angles are the same and all their sides are different. Draw for him any such polygon with the given number of vertexes. Input Specification: The input contains a single...
3,705
Title: Swapping Characters Time Limit: None seconds Memory Limit: None megabytes Problem Description: We had a string *s* consisting of *n* lowercase Latin letters. We made *k* copies of this string, thus obtaining *k* identical strings *s*1,<=*s*2,<=...,<=*s**k*. After that, in each of these strings we swapped exac...
3,706
Title: Games Time Limit: None seconds Memory Limit: None megabytes Problem Description: Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. W...
3,707
Title: Airport Time Limit: None seconds Memory Limit: None megabytes Problem Description: Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: - it is up to a passenger to choose a plane to fly on; - if the chosen pl...
3,708
Title: Bear and Forgotten Tree 2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tree is a connected undirected graph consisting of *n* vertices and *n*<=<=-<=<=1 edges. Vertices are numbered 1 through *n*. Limak is a little polar bear. He once had a tree with *n* vertices but he lost i...
3,709
Title: Vanya and Label Time Limit: None seconds Memory Limit: None megabytes Problem Description: While walking down the street Vanya saw a label "Hide&amp;Seek". Because he is a programmer, he used &amp; as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of ...
3,710
Title: Polycarp at the Radio Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence *a*1,<=*a*2,<=...,<=*a**n*, where *a**i* is a band, which performs the *i*-th song. Polyc...
3,711
Title: Tree or not Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an undirected connected graph *G* consisting of *n* vertexes and *n* edges. *G* contains no self-loops or multiple edges. Let each edge has two states: on and off. Initially all edges are switched off. Y...
3,712
Title: Chores Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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 th...
3,713
Title: Page Numbers Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Β«BersoftΒ» company is working on a new version of its most popular text editor β€” Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page number...
3,714
Title: Eleven Time Limit: None seconds Memory Limit: None megabytes Problem Description: Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly *n* characters. Her friend suggested that her name should o...
3,715
Title: Lucky Sorting Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya...
3,716
Title: Ralph And His Tour in Binary Country Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ralph is in the Binary Country. The Binary Country consists of *n* cities and (*n*<=-<=1) bidirectional roads connecting the cities. The roads are numbered from 1 to (*n*<=-<=1), the *i*-th road con...
3,717
Title: Lostborn Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero ...
3,718
Title: Complicated GCD Time Limit: None seconds Memory Limit: None megabytes Problem Description: Greatest common divisor *GCD*(*a*,<=*b*) of two positive integers *a* and *b* is equal to the biggest integer *d* such that both integers *a* and *b* are divisible by *d*. There are many efficient algorithms to find gre...
3,719
Title: Cutting Rectangle Time Limit: None seconds Memory Limit: None megabytes Problem Description: A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \cdot (q + 1)$ rectangles were left after the cutting...
3,720
Title: Exam Cheating Time Limit: None seconds Memory Limit: None megabytes Problem Description: Zane and Zane's crush have just decided to date! However, the girl is having a problem with her Physics final exam, and needs your help. There are *n* questions, numbered from 1 to *n*. Question *i* comes before question...
3,721
Title: Sonya Partymaker Time Limit: None seconds Memory Limit: None megabytes Problem Description: Owl Sonya decided to become a partymaker. To train for this role she gather all her owl friends in the country house. There are *m* chairs located in a circle and consequently numbered with integers from 1 to *m*. Thus...
3,722
Title: String Compression Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ivan wants to write a letter to his friend. The letter is a string *s* consisting of lowercase Latin letters. Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the who...
3,723
Title: Tom Riddle's Diary Time Limit: None seconds Memory Limit: None megabytes Problem Description: Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber ...
3,724
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a grid with *n* rows and *n* columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). Two empty cells are directly connected if they share a side. Two cells (*r*1,<=*c*1) (located in the row *r*1 ...
3,725
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a set of *n* points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines. Multiset is a set...
3,726
Title: Chewbaсca and Number Time Limit: None seconds Memory Limit: None megabytes Problem Description: Luke Skywalker gave Chewbacca an integer number *x*. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit *t* means replacing it with digit 9<=-<=*t*. Help Chewbacca to transform...
3,727
Title: "Or" Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* numbers *a*1,<=*a*2,<=...,<=*a**n*. You can perform at most *k* operations. For each operation you can multiply one of the numbers by *x*. We want to make as large as possible, where denotes the bitwise OR...
3,728
Title: An unavoidable detour for home Time Limit: None seconds Memory Limit: None megabytes Problem Description: Those unwilling to return home from a long journey, will be affected by the oddity of the snail and lose their way. Mayoi, the oddity's carrier, wouldn't like this to happen, but there's nothing to do wit...
3,729
Title: Ralph and Mushrooms Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ralph is going to collect mushrooms in the Mushroom Forest. There are *m* directed paths connecting *n* trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the...
3,730
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's May in Flatland, and there are $m$ days in this month. Despite the fact that May Holidays are canceled long time ago, employees of some software company still have a habit of taking short or long vacations in May. Of course,...
3,731
Title: Pixels Time Limit: None seconds Memory Limit: None megabytes Problem Description: Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by ...
3,732
Title: Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly *n*1 balls and second player's box contains exactly *n*2 balls. In one move first player can take from 1 to *k*1 ba...
3,733
Title: XK Segments Time Limit: None seconds Memory Limit: None megabytes Problem Description: While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array *a* and integer *x*. He should ...
3,734
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two positive integers *a* and *b* have a sum of *s* and a bitwise XOR of *x*. How many possible values are there for the ordered pair (*a*,<=*b*)? Input Specification: The first line of the input contains two integers *s* and *x*...
3,735
Title: Robot Arm Time Limit: None seconds Memory Limit: None megabytes Problem Description: Roger is a robot. He has an arm that is a series of *n* segments connected to each other. The endpoints of the *i*-th segment are initially located at points (*i*<=-<=1,<=0) and (*i*,<=0). The endpoint at (*i*<=-<=1,<=0) is c...
3,736
Title: Random Elections Time Limit: None seconds Memory Limit: None megabytes Problem Description: The presidential election is coming in Bearland next year! Everybody is so excited about this! So far, there are three candidates, Alice, Bob, and Charlie. There are *n* citizens in Bearland. The election result wil...
3,737
Title: The Queue Time Limit: None seconds Memory Limit: None megabytes Problem Description: Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can queu...
3,738
Title: Tricky Function Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub,...
3,739
Title: Hacking Cypher Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained...
3,740
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Π’Π°ΠΌ Π·Π°Π΄Π°Π½ΠΎ ΠΏΡ€ΡΠΌΠΎΡƒΠ³ΠΎΠ»ΡŒΠ½ΠΎΠ΅ ΠΊΠ»Π΅Ρ‚Ρ‡Π°Ρ‚ΠΎΠ΅ ΠΏΠΎΠ»Π΅, состоящСС ΠΈΠ· *n* строк ΠΈ *m* столбцов. ПолС содСрТит Ρ†ΠΈΠΊΠ» ΠΈΠ· символов Β«*Β», Ρ‚Π°ΠΊΠΎΠΉ Ρ‡Ρ‚ΠΎ: - Ρ†ΠΈΠΊΠ» ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠ±ΠΎΠΉΡ‚ΠΈ, посСтив ΠΊΠ°ΠΆΠ΄ΡƒΡŽ Π΅Π³ΠΎ ΠΊΠ»Π΅Ρ‚ΠΊΡƒ Ρ€ΠΎΠ²Π½ΠΎ ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π·, ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Ρ‰Π°ΡΡΡŒ ΠΊΠ°ΠΆΠ΄Ρ‹ΠΉ Ρ€Π°Π· Π²Π²Π΅Ρ€Ρ…/Π²Π½ΠΈΠ·/Π²ΠΏΡ€Π°...
3,741
Title: Powers of Two Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Find the number of pairs of indexes *i*,<=*j* (*i*<=&lt;<=*j*) that *a**i*<=+<=*a**j* is a power of 2 (i. e. some integer *x* exists so that *a**i*<=+<=*a**j*<==<=2*x...
3,742
Title: Gargari and Permutations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found *k* permutations. Each of them consists of numbers 1,<=2,...
3,743
Title: Valera and Swaps Time Limit: None seconds Memory Limit: None megabytes Problem Description: A permutation *p* of length *n* is a sequence of distinct integers *p*1,<=*p*2,<=...,<=*p**n* (1<=≀<=*p**i*<=≀<=*n*). A permutation is an identity permutation, if for any *i* the following equation holds *p**i*<==<=*i*...
3,744
Title: High School: Become Human Time Limit: None seconds Memory Limit: None megabytes Problem Description: Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before. It turns out tha...
3,745
Title: Subsequence Counting Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pikachu had an array with him. He wrote down all the non-empty subsequences of the array on paper. Note that an array of size *n* has 2*n*<=-<=1 non-empty subsequences in it. Pikachu being mischievous as he alway...
3,746
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other words, for e...
3,747
Title: New Year Cards Time Limit: None seconds Memory Limit: None megabytes Problem Description: As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has *n* friends, and each of them sends to Alexander exactly one e-ca...
3,748
Title: Digits Time Limit: None seconds Memory Limit: None megabytes Problem Description: John gave Jack a very hard problem. He wrote a very big positive integer *A*0 on a piece of paper. The number is less than 10200000 . In each step, Jack is allowed to put '<=+<=' signs in between some of the digits (maybe none) ...
3,749
Title: Black and White Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: According to the legends the king of Berland Berl I was noted for his love of beauty and order. One day he ordered to tile the palace hall's floor where balls and receptions used to take place with black and white tiles acc...
3,750
Title: Beru-taxi Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasiliy lives at point (*a*,<=*b*) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested *n* available Beru-taxi nearby. The *i*-th taxi is located at po...
3,751
Title: Wet Shark and Flowers Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks *i* and *i*<=+<=1 are neighbours for all *i* from 1 to *n*<=-<=1. Sharks *n* and 1 are neighbours too. ...
3,752
Title: Dima and To-do List Time Limit: None seconds Memory Limit: None megabytes Problem Description: You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong. Inna and Dima are now in one room. Inna tells Dima off for everything h...
3,753
Title: Voting Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to on...
3,754
Title: Savior Time Limit: 4 seconds Memory Limit: 256 megabytes Problem Description: Misha decided to help Pasha and Akim be friends again. He had a cunning plan β€” to destroy all the laughy mushrooms. He knows that the laughy mushrooms can easily burst when they laugh. Mushrooms grow on the lawns. There are *a*[*t*]...
3,755
Title: Deletion of Repeats Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Once Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but at the same time each letter could be met in the string at most 10 times. Bob didn't like that string, because ...
3,756
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* balls. They are arranged in a row. Each ball has a color (for convenience an integer) and an integer value. The color of the *i*-th ball is *c**i* and the value of the *i*-th ball is *v**i*. Squirrel Liss chooses so...
3,757
Title: K Paths Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a tree of $n$ vertices. You are to select $k$ (not necessarily distinct) simple paths in such a way that it is possible to split all edges of the tree into three sets: edges not contained in any path, edges that a...
3,758
Title: DZY Loves Strings Time Limit: None seconds Memory Limit: None megabytes Problem Description: DZY loves strings, and he enjoys collecting them. In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh. Once DZY found a lucky string *s*. A lot of pairs of go...
3,759
Title: Practice Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little time is left before Berland annual football championship. Therefore the coach of team "Losewille Rangers" decided to resume the practice, that were indefinitely interrupted for uncertain reasons. Overall there are *n* p...
3,760
Title: Before Exam Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his ...
3,761
Title: Frequency of String Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string $s$. You should answer $n$ queries. The $i$-th query consists of integer $k_i$ and string $m_i$. The answer for this query is the minimum length of such a string $t$ that $t$ is a substring of...
3,762
Title: Two strings Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two strings *a* and *b*. You have to remove the minimum possible number of consecutive (standing one after another) characters from string *b* in such a way that it becomes a subsequence of string *a*. It can ...
3,763
Title: Captain America Time Limit: None seconds Memory Limit: None megabytes Problem Description: Steve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are *n* shields in total, the *i*-th shield is located at point (*x**i*,<=*y**i*) of the coordinate plane. It's po...
3,764
Title: Our Tanya is Crying Out Loud Time Limit: None seconds Memory Limit: None megabytes Problem Description: Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers *n*, *k*, *A* and *B*. There is a number *x*, which is initially equal to *n*. You are allowed to perf...
3,765
Title: Elevator Time Limit: None seconds Memory Limit: None megabytes Problem Description: And now the numerous qualifying tournaments for one of the most prestigious Russian contests Russian Codec Cup are over. All *n* participants who have made it to the finals found themselves in a huge *m*-floored 108-star hotel...
3,766
Title: Big Data Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift ...
3,767
Title: Anton and Lines Time Limit: None seconds Memory Limit: None megabytes Problem Description: The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of *n* lines defined by the equations *y*<==<=*k**i*Β·*...
3,768
Title: Simba on the Circle Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a circular array with *n* elements. The elements are numbered from some element with values from 1 to *n* in clockwise order. The *i*-th cell contains the value *a**i*. The robot Simba is in cell *s*. ...
3,769
Title: Suit and Tie Time Limit: None seconds Memory Limit: None megabytes Problem Description: Allen is hosting a formal dinner party. $2n$ people come to the event in $n$ pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The $2n$ people line up, but Allen doesn't like the o...
3,770
Title: Bear and Two Paths Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bearland has *n* cities, numbered 1 through *n*. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities. Bear Limak was once in a city *a* ...
3,771
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bearland is a big square on the plane. It contains all points with coordinates not exceeding 106 by the absolute value. There are *n* houses in Bearland. The *i*-th of them is located at the point (*x**i*,<=*y**i*). The *n* point...
3,772
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and eng...
3,773
Title: Pawn Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. O...
3,774
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You're trying to set the record on your favorite video game. The game consists of *N* levels, which must be completed sequentially in order to beat the game. You usually complete each level as fast as possible, but sometimes finis...
3,775
Title: Formurosa Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Bytelandian Institute for Biological Research (BIBR) is investigating the properties of two species of bacteria, named simply 0 and 1. Even under a microscope, bacteria of those two species are very difficult to distingui...
3,776
Title: Mister B and Angle in Polygon Time Limit: None seconds Memory Limit: None megabytes Problem Description: On one quiet day all of sudden Mister B decided to draw angle *a* on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex *...
3,777
Title: BHTML+BCSS Time Limit: None seconds Memory Limit: None megabytes Problem Description: This problem is about imaginary languages BHTML and BCSS, which slightly resemble HTML and CSS. Read the problem statement carefully as the resemblance is rather slight and the problem uses very simplified analogs. You are ...
3,778
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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 ...
3,779
Title: Anton and Chess Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead. The ...
3,780
Title: Neverending competitions Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from thei...
3,781
Title: Clothes Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap. Overall the ...
3,782
Title: Rook, Bishop and King Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya is learning to play chess. He has already learned how to move a king, a rook and a bishop. Let us remind you the rules of moving chess pieces. A chessboard is 64 square fields organized into an 8<=Γ—<=...
3,783
Title: World Football Cup Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup reg...
3,784
Title: Ilya and tic-tac-toe game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ilya is an experienced player in tic-tac-toe on the 4<=Γ—<=4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last...
3,785
Title: Little Elephant and Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant has got a problem β€” somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array. The Little Elephant doesn't want to c...
3,786
Title: Challenge Pennants Time Limit: None seconds Memory Limit: None megabytes Problem Description: Because of budget cuts one IT company established new non-financial reward system instead of bonuses. Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed ...
3,787
Title: Shopping Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect" service which allows users to shop online. The store contains *k* items. *n* customers have already used the above service...
3,788
Title: Counting-out Rhyme Time Limit: None seconds Memory Limit: None megabytes Problem Description: *n* children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to *n*. In the beginning, the first child is considered the leader. The game is played in *k* steps. In ...
3,789
Title: African Crossword Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: An African crossword is a rectangular table *n*<=Γ—<=*m* in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded. To s...
3,790
Title: Memory and Casinos Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* casinos lined in a row. If Memory plays at casino *i*, he has probability *p**i* to win and move to the casino on the right (*i*<=+<=1) or exit the row (if *i*<==<=*n*), and a probability 1<=-<=*p**i* t...
3,791
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: BigData Inc. is a corporation that has *n* data centers indexed from 1 to *n* that are located all over the world. These data centers provide storage for client data (you can figure out that client data is really big!). Main feat...
3,792
Title: Complete The Graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: ZS the Coder has drawn an undirected graph of *n* vertices numbered from 0 to *n*<=-<=1 and *m* edges between them. Each edge of the graph is weighted, each weight is a positive integer. The next day, ZS the Coder r...
3,793
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction. At some points on the road there are *n* friends, and *i*...
3,794
Title: Monitor Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Luba bought a monitor. Monitor is a rectangular matrix of size *n*<=Γ—<=*m*. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when ...
3,795
Title: Axis Walking Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahub wants to meet his girlfriend Iahubina. They both live in *Ox* axis (the horizontal axis). Iahub lives at point 0 and Iahubina at point *d*. Iahub has *n* positive integers *a*1, *a*2, ..., *a**n*. The sum of those n...
3,796
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got an array consisting of *n* integers: *a*[1],<=*a*[2],<=...,<=*a*[*n*]. Moreover, there are *m* queries, each query can be described by three integers *l**i*,<=*r**i*,<=*k**i*. Query *l**i*,<=*r**i*,<=*k**i* means that w...
3,797
Title: Forward, march! Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in whic...
3,798
Title: King's Path Time Limit: None seconds Memory Limit: None megabytes Problem Description: The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with int...
3,799