task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Casinos and travel Time Limit: None seconds Memory Limit: None megabytes Problem Description: John has just bought a new car and is planning a journey around the country. Country has *N* cities, some of which are connected by bidirectional roads. There are *N*<=-<=1 roads and every city is reachable from any ...
3,200
Title: Epidemic in Monstropolis Time Limit: None seconds Memory Limit: None megabytes Problem Description: There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city. Soon, monsters became hungry and began to eat e...
3,201
Title: The World is a Theatre Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* boys and *m* girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly *t* actors containing no less than 4 boys and no less than one girl. ...
3,202
Title: Mrs. Hudson's Pancakes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mrs. Hudson hasn't made her famous pancakes for quite a while and finally she decided to make them again. She has learned *m* new recipes recently and she can't wait to try them. Those recipes are based on *n* sp...
3,203
Title: Dasha and friends Time Limit: None seconds Memory Limit: None megabytes Problem Description: Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation: The track is the circle with length *L*, in distinc...
3,204
Title: Anagram Time Limit: None seconds Memory Limit: None megabytes Problem Description: String *x* is an anagram of string *y*, if we can rearrange the letters in string *x* and get exact string *y*. For example, strings "DOG" and "GOD" are anagrams, so are strings "BABA" and "AABB", but strings "ABBAC" and "CAABA...
3,205
Title: Vowels Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahubina is tired of so many complicated languages, so she decided to invent a new, simple language. She already made a dictionary consisting of *n* 3-words. A 3-word is a sequence of exactly 3 lowercase letters of the first 24 ...
3,206
Title: Lucky String Time Limit: 2 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,207
Title: Insertion Sort Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that i...
3,208
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. T...
3,209
Title: Random Query Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array *a* consisting of *n* positive integers. You pick two integer numbers *l* and *r* from 1 to *n*, inclusive (numbers are picked randomly, equiprobably and independently). If *l*<=&gt;<=*r*, then you s...
3,210
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Дано целое неотрицательное число *k* и *n* неотрицательных целых чисел *a*1,<=*a*2,<=...,<=*a**n*. Записывая некоторые из этих чисел друг за другом в произвольном порядке и, возможно, используя какие-то из них несколько раз (а как...
3,211
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing. You consider several coinciding straight lin...
3,212
Title: Feed the Golorp Time Limit: None seconds Memory Limit: None megabytes Problem Description: Golorps are mysterious creatures who feed on variables. Golorp's name is a program in some programming language. Some scientists believe that this language is Befunge; golorps are tantalizingly silent. Variables consum...
3,213
Title: Strings of Power Time Limit: None seconds Memory Limit: None megabytes Problem Description: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style. Volodya calls a string powerful if it starts with "heavy" an...
3,214
Title: Delivering Carcinogen Time Limit: None seconds Memory Limit: None megabytes Problem Description: Qwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to get to the planet as...
3,215
Title: Fairy Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man will meet the most beautiful princess eve...
3,216
Title: Triangle Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer co...
3,217
Title: BF Calculator Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem you will write a simple generator of Brainfuck ([https://en.wikipedia.org/wiki/Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)) calculators. You are given an arithmetic expression consisting of intege...
3,218
Title: Mister B and Beacons on Field Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mister B has a house in the middle of a giant plain field, which attracted aliens life. For convenience, aliens specified the Cartesian coordinate system on the field in such a way that Mister B's house ha...
3,219
Title: Mathematical Analysis Rocks! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group f...
3,220
Title: Circular RMQ Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: You are given circular array *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. There are two types of operations with it: - *inc*(*lf*,<=*rg*,<=*v*) — this operation increases each element on the segment [*lf*,<=*rg*] (inclusively) by *v*;...
3,221
Title: Lucky Permutation Time Limit: None seconds Memory Limit: None megabytes Problem Description: A permutation *p* of size *n* is the sequence *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct integers, each of them is from 1 to *n* (1<=≤<=*p**i*<=≤<=*n*). A lucky permutation is such permutation *p*, that a...
3,222
Title: Director Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya is a born Berland film director, he is currently working on a new blockbuster, "The Unexpected". Vasya knows from his own experience how important it is to choose the main characters' names and surnames wisely. He made up a ...
3,223
Title: Prefix Sums Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider the function *p*(*x*), where *x* is an array of *m* integers, which returns an array *y* consisting of *m*<=+<=1 integers such that *y**i* is equal to the sum of first *i* elements of array *x* (0<=≤<=*i*<=≤<=*m*)....
3,224
Title: Data Center Drama Time Limit: None seconds Memory Limit: None megabytes Problem Description: The project of a data center of a Big Software Company consists of *n* computers connected by *m* cables. Simply speaking, each computer can be considered as a box with multiple cables going out of the box. Very Impor...
3,225
Title: Phone numbers Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Phone number in Berland is a sequence of *n* digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33....
3,226
Title: Kitahara Haruki's Gift Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kitahara Haruki has bought *n* apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends. Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't w...
3,227
Title: Line Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: A line on the plane is described by an equation *Ax*<=+<=*By*<=+<=*C*<==<=0. You are to find any point on this line, whose coordinates are integer numbers from <=-<=5·1018 to 5·1018 inclusive, or to find out that such points do not ex...
3,228
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alyona's mother wants to present an array of *n* non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she inspects *m* of its subarrays. Subarray is a set of some...
3,229
Title: Sereja and Coat Rack Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja owns a restaurant for *n* people. The restaurant hall has a coat rack with *n* hooks. Each restaurant visitor can use a hook to hang his clothes on it. Using the *i*-th hook costs *a**i* rubles. Only one per...
3,230
Title: Text Document Analysis Time Limit: None seconds Memory Limit: None megabytes Problem Description: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the...
3,231
Title: Hack it! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little X has met the following problem recently. Let's define *f*(*x*) as the sum of digits in decimal representation of number *x* (for example, *f*(1234)<==<=1<=+<=2<=+<=3<=+<=4). You are to calculate Of course Little X ...
3,232
Title: Anton and Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are *n* vertices in the tree, each of them is painted black or white. Anton doesn't like multicolored tr...
3,233
Title: Space Rescuers Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The Galaxy contains *n* planets, there are many different living creatures inhabiting each planet. And each creature can get into troubles! Space rescuers know it perfectly well and they are always ready to help anyone who r...
3,234
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: As you know, lemmings like jumping. For the next spectacular group jump *n* lemmings gathered near a high rock with *k* comfortable ledges on it. The first ledge is situated at the height of *h* meters, the second one is at the he...
3,235
Title: Bulmart Time Limit: None seconds Memory Limit: None megabytes Problem Description: A new trade empire is rising in Berland. Bulmart, an emerging trade giant, decided to dominate the market of ... shovels! And now almost every city in Berland has a Bulmart store, and some cities even have several of them! The ...
3,236
Title: Fence Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has a crooked fence, consisting of *n* rectangular planks, lined up from the left to the right: the plank that goes *i*-th (1<=≤<=*i*<=≤<=*n*) (from left to right) has width 1 and height *h**i*. We will assume that the p...
3,237
Title: Fly, freebies, fly! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Everyone loves a freebie. Especially students. It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flo...
3,238
Title: Parliament of Berland Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* parliamentarians in Berland. They are numbered with integers from 1 to *n*. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indices are Republi...
3,239
Title: New Year and Days Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015. Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming ye...
3,240
Title: Petya and Strings Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. ...
3,241
Title: Coprime Permutation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two positive integers are coprime if and only if they don't have a common divisor greater than 1. Some bear doesn't want to tell Radewoosh how to solve some algorithmic problem. So, Radewoosh is going to break into...
3,242
Title: Darth Vader and Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly *n* sons, at that for each node, the distance between it an its *i*-th left c...
3,243
Title: Shortest path of the king Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square *t*. As the king ...
3,244
Title: Indivisibility Time Limit: None seconds Memory Limit: None megabytes Problem Description: IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of ...
3,245
Title: Demiurges Play Again Time Limit: None seconds Memory Limit: None megabytes Problem Description: Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game. There is a rooted tree on *n* nodes, *m* of which are leaves (a leaf is a nod...
3,246
Title: Mr. Kitayuta, the Treasure Hunter Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known...
3,247
Title: Pie or die Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Volodya and Vlad play the following game. There are *k* pies at the cells of *n*<=<=×<=<=*m* board. Each turn Volodya moves one pie to the neighbouring (by side) cell. If the pie lies at the border of the board then Volodya can ...
3,248
Title: Dasha and Password Time Limit: None seconds Memory Limit: None megabytes Problem Description: After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length *n* which satisfies the following requirements: - There is at least one dig...
3,249
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kleofáš is participating in an *n*-thlon - a tournament consisting of *n* different competitions in *n* different disciplines (numbered 1 through *n*). There are *m* participants in the *n*-thlon and each of them participates in a...
3,250
Title: Mister B and Boring Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens. All characters in this game are lowercase English letters...
3,251
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: This is an interactive problem. Bob lives in a square grid of size $n \times n$, with rows numbered $1$ through $n$ from top to bottom, and columns numbered $1$ through $n$ from left to right. Every cell is either allowed or bloc...
3,252
Title: Dynamic Shortest Path Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a weighted directed graph, consisting of *n* vertices and *m* edges. You should answer *q* queries of two types: - 1 v — find the length of shortest path from vertex 1 to vertex *v*. - 2 c *l*1 *l...
3,253
Title: Awards For Contestants Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alexey recently held a programming contest for students from Berland. *n* students participated in a contest, *i*-th of them solved *a**i* problems. Now he wants to award some contestants. Alexey can award the st...
3,254
Title: Homework Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today Peter has got an additional homework for tomorrow. The teacher has given three integers to him: *n*, *m* and *k*, and asked him to mark one or more squares on a square grid of size *n*<=×<=*m*. The marked squares must ...
3,255
Title: Letters Cyclic Shift Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a non-empty string *s* consisting of lowercase English letters. You have to pick exactly one non-empty substring of *s* and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each cha...
3,256
Title: Pipeline Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe c...
3,257
Title: Legen... Time Limit: None seconds Memory Limit: None megabytes Problem Description: Barney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible. Initially, happiness level of Nora is 0. ...
3,258
Title: Guess That Car! Time Limit: None seconds Memory Limit: None megabytes Problem Description: A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called "Guess That Car!". The game show takes pl...
3,259
Title: Contact ATC Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady the air traffic controller is now working with *n* planes in the air. All planes move along a straight coordinate axis with Arkady's station being at point 0 on it. The *i*-th plane, small enough to be represented by...
3,260
Title: Counting Rectangles is Fun Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is an *n*<=×<=*m* rectangular grid, each cell of the grid contains a single integer: zero or one. Let's call the cell on the *i*-th row and the *j*-th column as (*i*,<=*j*). Let's define a "rectangle" ...
3,261
Title: Rotate, Flip and Zoom Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally...
3,262
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it int...
3,263
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to...
3,264
Title: Vasya's Function Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya is studying number theory. He has denoted a function *f*(*a*,<=*b*) such that: - *f*(*a*,<=0)<==<=0; - *f*(*a*,<=*b*)<==<=1<=+<=*f*(*a*,<=*b*<=-<=*gcd*(*a*,<=*b*)), where *gcd*(*a*,<=*b*) is the greatest commo...
3,265
Title: Interesting Game Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Two best friends Serozha and Gena play a game. Initially there is one pile consisting of *n* stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of *a*1<=...
3,266
Title: Winter is here Time Limit: None seconds Memory Limit: None megabytes Problem Description: Winter is here at the North and the White Walkers are close. John Snow has an army consisting of *n* soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the W...
3,267
Title: New Year and Boolean Bridges Time Limit: None seconds Memory Limit: None megabytes Problem Description: Your friend has a hidden directed graph with *n* nodes. Let *f*(*u*,<=*v*) be true if there is a directed path from node *u* to node *v*, and false otherwise. For each pair of distinct nodes, *u*,<=*v*, yo...
3,268
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Malek is a rich man. He also is very generous. That's why he decided to split his money between poor people. A charity institute knows *n* poor people numbered from 1 to *n*. The institute gave Malek *q* recommendations. A recomme...
3,269
Title: Chilly Willy Time Limit: None seconds Memory Limit: None megabytes Problem Description: Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected wit...
3,270
Title: Petr and Permutations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from...
3,271
Title: Guard Towers Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: In a far away kingdom lives a very greedy king. To defend his land, he built *n* guard towers. Apart from the towers the kingdom has two armies, each headed by a tyrannical and narcissistic general. The generals can't stand ea...
3,272
Title: The Smallest String Concatenation Time Limit: None seconds Memory Limit: None megabytes Problem Description: You're given a list of *n* strings *a*1,<=*a*2,<=...,<=*a**n*. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest. Given the list ...
3,273
Title: Acyclic Organic Compounds Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a tree *T* with *n* vertices (numbered 1 through *n*) and a letter in each vertex. The tree is rooted at vertex 1. Let's look at the subtree *T**v* of some vertex *v*. It is possible to read a s...
3,274
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given set of *n* points in 5-dimensional space. The points are labeled from 1 to *n*. No two points coincide. We will call point *a* bad if there are different points *b* and *c*, not equal to *a*, from the given set such...
3,275
Title: May Holidays 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...
3,276
Title: ...Dary! Time Limit: None seconds Memory Limit: None megabytes Problem Description: Barney has finally found the one, a beautiful young lady named Lyanna. The problem is, Lyanna and Barney are trapped in Lord Loss' castle. This castle has shape of a convex polygon of *n* points. Like most of castles in Demona...
3,277
Title: The Overdosing Ubiquity Time Limit: None seconds Memory Limit: None megabytes Problem Description: The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor. The Cinderswarm Bee. Koyomi knows it. The bees, according to their nature, live in a tr...
3,278
Title: Renovation Time Limit: None seconds Memory Limit: None megabytes Problem Description: The mayor of the Berland city S sees the beauty differently than other city-dwellers. In particular, he does not understand at all, how antique houses can be nice-looking. So the mayor wants to demolish all ancient buildings...
3,279
Title: Blackboard Fibonacci Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fibonacci numbers are the sequence of integers: *f*0<==<=0, *f*1<==<=1, *f*2<==<=1, *f*3<==<=2, *f*4<==<=3, *f*5<==<=5, ..., *f**n*<==<=*f**n*<=-<=2<=+<=*f**n*<=-<=1. So every next number is the sum of the previous...
3,280
Title: Red-Black Cobweb Time Limit: None seconds Memory Limit: None megabytes Problem Description: Slastyona likes to watch life of nearby grove's dwellers. This time she watches a strange red-black spider sitting at the center of a huge cobweb. The cobweb is a set of *n* nodes connected by threads, each of the tre...
3,281
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery. Soon the expenses started to overcome the incom...
3,282
Title: Black-and-White Cube Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a cube of size *k*<=×<=*k*<=×<=*k*, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face. Your task is to paint each of *k*3 unit cubes one of two colour...
3,283
Title: Sereja and Bottles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja and his friends went to a picnic. The guys had *n* soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the *i*-th...
3,284
Title: Alternating Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Given a tree with $n$ nodes numbered from $1$ to $n$. Each node $i$ has an associated value $V_i$. If the simple path from $u_1$ to $u_m$ consists of $m$ nodes namely $u_1 \rightarrow u_2 \rightarrow u_3 \rightarrow \...
3,285
Title: Fight Against Traffic Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little town Nsk consists of *n* junctions connected by *m* bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junctio...
3,286
Title: Mammoth's Genome Decoding Time Limit: None seconds Memory Limit: None megabytes Problem Description: The process of mammoth's genome decoding in Berland comes to its end! One of the few remaining tasks is to restore unrecognized nucleotides in a found chain *s*. Each nucleotide is coded with a capital letter...
3,287
Title: Sinking Ship Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All *n* crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to ...
3,288
Title: The Time Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given the current time in 24-hour format hh:mm. Find and print the time after *a* minutes. Note that you should find only the time after *a* minutes, see the examples to clarify the problem statement. You can read mo...
3,289
Title: The New Year: Meeting Friends Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are three friend living on the straight line *Ox* in Lineland. The first friend lives at the point *x*1, the second friend lives at the point *x*2, and the third friend lives at the point *x*3. They ...
3,290
Title: Romaji Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant. In Berlanese, there has to be a vowel after eve...
3,291
Title: Two Sets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little X has *n* distinct integers: *p*1,<=*p*2,<=...,<=*p**n*. He wants to divide all of them into two sets *A* and *B*. The following two conditions must be satisfied: - If number *x* belongs to set *A*, then number *a*<=-...
3,292
Title: Ber Patio Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp is a regular customer at the restaurant "Ber Patio". He likes having lunches there. "Ber Patio" has special discount program for regular customers. A customer can collect bonuses and partially cover expenses in the ...
3,293
Title: Memory and Scores Time Limit: None seconds Memory Limit: None megabytes Problem Description: Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score *a* and Lexa starts with score *b*. In a single turn, both Memory and Lexa get some integer in the ra...
3,294
Title: Solution for Cube Time Limit: None seconds Memory Limit: None megabytes Problem Description: During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2. It's too hard to learn to solve Rubik's cube instantly,...
3,295
Title: Laser Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of *n*<=×<=*m* cells an...
3,296
Title: Oranges and Apples Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: In 2*N*<=-<=1 boxes there are apples and oranges. Your task is to choose *N* boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges. Input Specification: The firs...
3,297
Title: Dishonest Sellers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Igor found out discounts in a shop and decided to buy *n* items. Discounts at the store will last for a week and Igor knows about each item that its price now is *a**i*, and after a week of discounts its price will be...
3,298
Title: Chess Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Two chess pieces, a rook and a knight, stand on a standard chessboard 8<=×<=8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one. Your task is to find the number of wa...
3,299