task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: User ainta decided to paint a wall. The wall consists of *n*2 tiles, that are arranged in an *n*<=Γ—<=*n* table. Some tiles are painted, and the others are not. As he wants to paint it beautifully, he will follow the rules below. ...
4,500
Title: Wilbur and Array Time Limit: None seconds Memory Limit: None megabytes Problem Description: Wilbur the pig is tinkering with arrays again. He has the array *a*1,<=*a*2,<=...,<=*a**n* initially consisting of *n* zeros. At one step, he can choose any index *i* and either add 1 to all elements *a**i*,<=*a**i*<=+...
4,501
Title: Lorenzo Von Matterhorn Time Limit: None seconds Memory Limit: None megabytes Problem Description: Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections *i* and 2*i* and another road between *i* and...
4,502
Title: Garland Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are connected by wires. Dima remembered that each two lamps in the garland were connected directly or...
4,503
Title: Little Artem and Grasshopper Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1<=Γ—<=*n*. Each cell contains the direction for the next jump and t...
4,504
Title: Christmas Spruce Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex *u* is called a child of vertex *v* and vertex *v* is called a parent of vertex *u* if there ex...
4,505
Title: Closest Equals Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given sequence *a*1,<=*a*2,<=...,<=*a**n* and *m* queries *l**j*,<=*r**j* (1<=≀<=*l**j*<=≀<=*r**j*<=≀<=*n*). For each query you need to print the minimum distance between such pair of elements *a**x* and *a**y* (...
4,506
Title: Olympic Medal Time Limit: None seconds Memory Limit: None megabytes Problem Description: The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of *r*1 cm, inner radius of *r*2 cm, (0<=&lt;<=*r*2<=&lt;<=*r*1) made of metal with density *p*1 g/...
4,507
Title: Wrong Floyd Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valera conducts experiments with algorithms that search for shortest paths. He has recently studied the Floyd's algorithm, so it's time to work with it. Valera's already written the code that counts the shortest distance b...
4,508
Title: Fox and Cross Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel has a board with *n* rows and *n* columns. So, the board consists of *n*<=Γ—<=*n* cells. Each cell contains either a symbol '.', or a symbol '#'. A cross on the board is a connected set of exactly five cells of t...
4,509
Title: Mashmokh and Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of *n* distinct integers on the board. Then Bimokh makes several (possibly zero) moves. ...
4,510
Title: Vanya and Books Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vanya got an important task β€” he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assig...
4,511
Title: Fox and Minimal path Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with *n* vertexes. Each its edge has unit length. You should calculate the number of shortest paths be...
4,512
Title: Triangles Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fe...
4,513
Title: Fedor and Essay Time Limit: None seconds Memory Limit: None megabytes Problem Description: After you had helped Fedor to find friends in the Β«Call of Soldiers 3Β» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked A...
4,514
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equ...
4,515
Title: Letter Time Limit: None seconds Memory Limit: None megabytes Problem Description: Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them...
4,516
Title: Summer Camp Time Limit: None seconds Memory Limit: None megabytes Problem Description: Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1...
4,517
Title: String Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string *s*. Each pair of numbers *l* and *r* that fulfill the condition 1<=≀<=*l*<=≀<=*r*<=≀<=|*s*|, correspond to a substring of the string *s*, starting in the position *l* and ending in the position *r* (inclu...
4,518
Title: Watering Flowers Time Limit: None seconds Memory Limit: None megabytes Problem Description: A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values *r*1(*r*1<=β‰₯<=0) and *r*2(*r*2<=β‰₯<=0), giving the distances at which the water is spread from the first and second f...
4,519
Title: Football Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process...
4,520
Title: NN country Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the NN country, there are $n$ cities, numbered from $1$ to $n$, and $n - 1$ roads, connecting them. There is a roads path between any two cities. There are $m$ bidirectional bus routes between cities. Buses drive between...
4,521
Title: Bear and Polynomials Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is *n* and its coefficients are integers not exceeding *k* by the abs...
4,522
Title: Dima and Containers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue a...
4,523
Title: Number Challenge Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's denote *d*(*n*) as the number of divisors of a positive integer *n*. You are given three integers *a*, *b* and *c*. Your task is to calculate the following sum: Find the sum modulo 1073741824 (230). Input Speci...
4,524
Title: Fence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya should paint a fence in front of his own cottage. The fence is a sequence of *n* wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1,<=2,<=...,<=...
4,525
Title: Donkey and Stars Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the chimney. Shrek's stars were to the r...
4,526
Title: Array GCD Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given array *a**i* of length *n*. You may consecutively apply two operations to this array: - remove some subsegment (continuous subsequence) of length *m*<=&lt;<=*n* and pay for it *m*Β·*a* coins; - change some ele...
4,527
Title: Challenging Balloons Time Limit: None seconds Memory Limit: None megabytes Problem Description: Martha β€” as a professional problemsetter β€” proposed a problem for a world-class contest. This is the problem statement: Tomorrow is Nadia's birthday, and Bardia (her brother) is assigned to make the balloons ready...
4,528
Title: Grandma Laura and Apples Time Limit: None seconds Memory Limit: None megabytes Problem Description: Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market. She precisely remembers sh...
4,529
Title: Drazil and Tiles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Drazil created a following problem about putting 1<=Γ—<=2 tiles into an *n*<=Γ—<=*m* grid: "There is a grid with some cells that are empty and some cells that are occupied. You should use 1<=Γ—<=2 tiles to cover all empt...
4,530
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Stepan has a very big positive integer. Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such shifts as go...
4,531
Title: Timofey and remoduling Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Timofey likes integers a lot. Unfortunately, he is very young and can't work with very big integers, so he does all the operations modulo his favorite prime *m*. Also, Timofey likes to look for arithmetica...
4,532
Title: s-palindrome Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second h...
4,533
Title: Tests Renumeration Time Limit: None seconds Memory Limit: None megabytes Problem Description: The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data i...
4,534
Title: Stages Time Limit: None seconds Memory Limit: None megabytes Problem Description: Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the stringΒ β€” conca...
4,535
Title: Polo the Penguin and Trees Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little penguin Polo has got a tree β€” a non-directed connected acyclic graph, containing *n* nodes and *n*<=-<=1 edges. We will consider the tree nodes numbered by integers from 1 to *n*. Today Polo wonders,...
4,536
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush, grassy fields of Bovinia. As any good horticulturist knows, each garden they p...
4,537
Title: Median Time Limit: None seconds Memory Limit: None megabytes Problem Description: A median in an array with the length of *n* is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2,<=6,<=1,...
4,538
Title: Minimal k-covering Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a bipartite graph *G*<==<=(*U*,<=*V*,<=*E*), *U* is the set of vertices of the first part, *V* is the set of vertices of the second part and *E* is the set of edges. There might be multiple edges. Let'...
4,539
Title: Anton and Ira Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them obtain the required permutation by paying as little money as possible. Mor...
4,540
Title: Bear and Big Brother Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or e...
4,541
Title: Levko and Array Recovery Time Limit: None seconds Memory Limit: None megabytes Problem Description: Levko loves array *a*1,<=*a*2,<=... ,<=*a**n*, consisting of integers, very much. That is why Levko is playing with array *a*, performing all sorts of operations with it. Each operation Levko performs is of one...
4,542
Title: Photographs (II) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Zombies seem to have become much more intelligent lately – a few have somehow wandered into the base through the automatic gate. Heidi has had to beef up security, and a new gate has been installed. Unfortunately, now ...
4,543
Title: Fedya and Maths Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression: for given value of *n*. Fedya managed to complete the task. Can you? Note that given number *n* can be extremely large (e.g...
4,544
Title: Unimodal Array Time Limit: None seconds Memory Limit: None megabytes Problem Description: Array of integers is unimodal, if: - it is strictly increasing in the beginning; - after that it is constant; - after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may ...
4,545
Title: Cashback Time Limit: None seconds Memory Limit: None megabytes Problem Description: Since you are the best Wraith King, Nizhniy Magazin Β«MirΒ» at the centre of Vinnytsia is offering you a discount. You are given an array *a* of length *n* and an integer *c*. The value of some array *b* of length *k* is the ...
4,546
Title: Holidays Time Limit: None seconds Memory Limit: None megabytes Problem Description: On the planet Mars a year lasts exactly *n* days (there are no leap years on Mars). But Martians have the same weeks as earthlingsΒ β€” 5 work days and then 2 days off. Your task is to determine the minimum possible and the maxim...
4,547
Title: Elections Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in the city you know whom he will vote for, and how much it will cost to bribe that person to vote for y...
4,548
Title: The Great Julya Calendar Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on i...
4,549
Title: Golden System Time Limit: None seconds Memory Limit: None megabytes Problem Description: Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number , in particular that *q*2<==<=*q*<=+<=1, and she thinks it would make a goo...
4,550
Title: To Add or Not to Add Time Limit: None seconds Memory Limit: None megabytes Problem Description: A piece of paper contains an array of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Your task is to find a number that occurs the maximum number of times in this array. However, before looking for such number, you are ...
4,551
Title: Functions again Time Limit: None seconds Memory Limit: None megabytes Problem Description: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found t...
4,552
Title: Trains Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some...
4,553
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It is a balmy spring afternoon, and Farmer John's *n* cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through *n*, are arranged so that the *i*-th cow occupies the *i*-th stall from the left. However,...
4,554
Title: Alarm Clock Time Limit: None seconds Memory Limit: None megabytes Problem Description: Every evening Vitalya sets *n* alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer *a**i*Β β€” number of minute after midnight in which it rings. Every alarm ...
4,555
Title: Jeff and Brackets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Jeff loves regular bracket sequences. Today Jeff is going to take a piece of paper and write out the regular bracket sequence, consisting of *nm* brackets. Let's number all brackets of this sequence from 0 to *nm* - ...
4,556
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: This is an interactive problem. In the interaction section below you will see the information about flushing the output. In this problem, you will be playing a game with Hongcow. How lucky of you! Hongcow has a hidden *n* by *n*...
4,557
Title: Phone Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: And where the are the phone numbers? You are given a string *s* consisting of lowercase English letters and an integer *k*. Find the lexicographically smallest string *t* of length *k*, such that its set of letters is a ...
4,558
Title: Drazil and Factorial Time Limit: None seconds Memory Limit: None megabytes Problem Description: Drazil is playing a math game with Varda. Let's define for positive integer *x* as a product of factorials of its digits. For example, . First, they choose a decimal number *a* consisting of *n* digits that cont...
4,559
Title: Map Time Limit: 2 seconds Memory Limit: 128 megabytes Problem Description: There is an area map that is a rectangular matrix *n*<=Γ—<=*m*, each cell of the matrix contains the average height of a corresponding area part. Peter works for a company that has to build several cities within this area, each of the c...
4,560
Title: Problem of offices Time Limit: None seconds Memory Limit: None megabytes Problem Description: Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices. Once Oleg the bank clie...
4,561
Title: Ralph And His Magic Field Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ralph has a magic field which is divided into *n*<=Γ—<=*m* blocks. That is to say, there are *n* rows and *m* columns on the field. Ralph can put an integer in each block. However, the magic field doesn't alway...
4,562
Title: Artsem and Saunders Time Limit: None seconds Memory Limit: None megabytes Problem Description: Artsem has a friend Saunders from University of Chicago. Saunders presented him with the following problem. Let [*n*] denote the set {1,<=...,<=*n*}. We will also write *f*:<=[*x*]<=β†’<=[*y*] when a function *f* is ...
4,563
Title: Dima and Bacteria Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima took up the biology of bacteria, as a result of his experiments, he invented *k* types of bacteria. Overall, there are *n* bacteria at his laboratory right now, and the number of bacteria of type *i* equals *c**i...
4,564
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In some country there are exactly *n* cities and *m* bidirectional roads connecting the cities. Cities are numbered with integers from 1 to *n*. If cities *a* and *b* are connected by a road, then in an hour you can go along this ...
4,565
Title: Degree Set Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a sequence of *n* positive integers *d*1,<=*d*2,<=...,<=*d**n* (*d*1<=&lt;<=*d*2<=&lt;<=...<=&lt;<=*d**n*). Your task is to construct an undirected graph such that: - there are exactly *d**n*<=+<=1 vertices; ...
4,566
Title: Little Girl and Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Girl loves problems on games very much. Here's one of them. Two players have got a string *s*, consisting of lowercase English letters. They play a game that is described by the following rules: - The...
4,567
Title: Batch Sort Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a table consisting of *n* rows and *m* columns. Numbers in each row form a permutation of integers from 1 to *m*. You are allowed to pick two elements in one row and swap them, but no more than once for each ...
4,568
Title: Odd sum Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given sequence *a*1,<=*a*2,<=...,<=*a**n* of integer numbers of length *n*. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains...
4,569
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but *n* different heads that can read data in parallel. When viewed from the side, Mike's hard drive is an endless array of tracks. Th...
4,570
Title: Lena and Queries Time Limit: None seconds Memory Limit: None megabytes Problem Description: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and *n* queries to process. Each query is one of three types: 1. Add a pair (*a*,<=*b*) to the set. 1. Remove a pair...
4,571
Title: Lucky Numbers (easy) Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. ...
4,572
Title: Two Tables Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got two rectangular tables with sizes *n**a*<=Γ—<=*m**a* and *n**b*<=Γ—<=*m**b* cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will de...
4,573
Title: Lucky Number 2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not....
4,574
Title: Cow Program Time Limit: None seconds Memory Limit: None megabytes Problem Description: Farmer John has just given the cows a program to play with! The program contains two integer variables, *x* and *y*, and performs the following operations on a sequence *a*1,<=*a*2,<=...,<=*a**n* of positive integers: 1. ...
4,575
Title: Fair Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya and Vasya decided to play a game. They have *n* cards (*n* is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (di...
4,576
Title: Forbidden Indices Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string *s* consisting of *n* lowercase Latin letters. Some indices in this string are marked as forbidden. You want to find a string *a* such that the value of |*a*|Β·*f*(*a*) is maximum possible, wher...
4,577
Title: Bear and Blocks Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built *n* towers in a row. The *i*-th tower is made of *h**i* identical blocks. For clarification see picture for the first sa...
4,578
Title: Vasya and Beautiful Arrays Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya's got a birthday coming up and his mom decided to give him an array of positive integers *a* of length *n*. Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His m...
4,579
Title: Lesha and array splitting Time Limit: None seconds Memory Limit: None megabytes Problem Description: One spring day on his way to university Lesha found an array *A*. Lesha likes to split arrays into several parts. This time Lesha decided to split the array *A* into several, possibly one, new arrays so that t...
4,580
Title: Roads in the Kingdom Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the Kingdom K., there are *n* towns numbered with integers from 1 to *n*. The towns are connected by *n* bi-directional roads numbered with integers from 1 to *n*. The *i*-th road connects the towns *u**i* and *...
4,581
Title: Compatible Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two integers *x* and *y* are compatible, if the result of their bitwise "AND" equals zero, that is, *a* &amp; *b*<==<=0. For example, numbers 90 (10110102) and 36 (1001002) are compatible, as 10110102 &amp; 1001002<=...
4,582
Title: Leaders Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: After a revolution in Berland the new dictator faced an unexpected challenge: the country has to be somehow ruled. The dictator is a very efficient manager, yet he can't personally give orders to each and every citizen. That's why ...
4,583
Title: Antichain Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a directed acyclic graph *G*, consisting of *n* vertexes, numbered from 0 to *n*<=-<=1. The graph contains *n* edges numbered from 0 to *n*<=-<=1. An edge with number *i* connects vertexes *i* and (*i*<=+<=1)Β *mod*Β *...
4,584
Title: Anti-Palindromize Time Limit: None seconds Memory Limit: None megabytes Problem Description: A string *a* of length *m* is called antipalindromic iff *m* is even, and for each *i* (1<=≀<=*i*<=≀<=*m*) *a**i*<=β‰ <=*a**m*<=-<=*i*<=+<=1. Ivan has a string *s* consisting of *n* lowercase Latin letters; *n* is even...
4,585
Title: Food on the Plane Time Limit: None seconds Memory Limit: None megabytes Problem Description: A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' ...
4,586
Title: Wonder Room Time Limit: None seconds Memory Limit: None megabytes Problem Description: The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a *a*<=Γ—<=*b* square meter wonder room. The caretaker wants to accommodate exactly *n* stu...
4,587
Title: GukiZ and GukiZiana Time Limit: None seconds Memory Limit: None megabytes Problem Description: Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called *GukiZiana*. For given array *a*, indexed with integers from 1 to *n*, and number *y*, *GukiZiana*(*a*,<=*y*) r...
4,588
Title: Marbles Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the spirit of the holidays, Saitama has given Genos two grid paths of length *n* (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are nei...
4,589
Title: Multicolored Cars Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice and Bob got very bored during a long car trip so they decided to play a game. From the window they can see cars of different colors running past them. Cars are going one after another. The game rules are like t...
4,590
Title: Beautiful Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vitaly is a very weird man. He's got two favorite digits *a* and *b*. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits *a* and *b*. Vitaly calls a good number ex...
4,591
Title: Path Counting Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rooted tree. Let's denote *d*(*x*) as depth of node *x*: depth of the root is 1, depth of any other node *x* is *d*(*y*)<=+<=1, where *y* is a parent of *x*. The tree has the following property: every nod...
4,592
Title: Death Stars (hard) Time Limit: None seconds Memory Limit: None megabytes Problem Description: The stardate is 2015, and Death Stars are bigger than ever! This time, two rebel spies have yet again given Heidi two maps with the possible locations of the Death Stars. Heidi has now received two maps with possibl...
4,593
Title: Berland.Taxi Time Limit: None seconds Memory Limit: None megabytes Problem Description: Berland.Taxi is a new taxi company with *k* cars which started operating in the capital of Berland just recently. The capital has *n* houses on a straight line numbered from 1 (leftmost) to *n* (rightmost), and the distanc...
4,594
Title: Yet Another Minimization Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array of *n* integers *a*1... *a**n*. The cost of a subsegment is the number of unordered pairs of distinct indices within the subsegment that contain equal elements. Split the given ar...
4,595
Title: Correcting Mistakes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use dif...
4,596
Title: Punctuation Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters. Your task is to ad...
4,597
Title: Infinite Sequence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider the infinite sequence of integers: 1,<=1,<=2,<=1,<=2,<=3,<=1,<=2,<=3,<=4,<=1,<=2,<=3,<=4,<=5.... The sequence is built in the following way: at first the number 1 is written out, then the numbers from 1 to 2,...
4,598
Title: Aquarium decoration Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady and Masha want to choose decorations for thier aquarium in Fishdom game. They have *n* decorations to choose from, each of them has some cost. To complete a task Arkady and Masha need to choose exactly *m* de...
4,599