task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Bear and Friendship Condition Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures). There are *n* members, numbered 1 through...
700
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kyoya Ootori has a bag with *n* colored balls that are colored with *k* different colors. The colors are labeled from 1 to *k*. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag is...
701
Title: Symmetric Projections 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. ...
702
Title: Greedy Merchants Time Limit: None seconds Memory Limit: None megabytes Problem Description: In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants. The Roman Empire consisted of *n* cities numbered from...
703
Title: Parametric Circulation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vova has recently learned what a circulaton in a graph is. Recall the definition: let $G = (V, E)$ be a directed graph. A circulation $f$ is such a collection of non-negative real numbers $f_e$ ($e \in E$), that ...
704
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Hamming distance between strings *a* and *b* of equal length (denoted by *h*(*a*,<=*b*)) is equal to the number of distinct integers *i* (1<=≤<=*i*<=≤<=|*a*|), such that *a**i*<=≠<=*b**i*, where *a**i* is the *i*-th symbol of stri...
705
Title: Scissors Time Limit: None seconds Memory Limit: None megabytes Problem Description: Jenya has recently acquired quite a useful tool — *k*-scissors for cutting strings. They are generally used for cutting out two non-intersecting substrings of length *k* from an arbitrary string *s* (its length should be at le...
706
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Вася купил стол, у которого *n* ножек. Каждая ножка состоит из двух частей, которые соединяются друг с другом. Каждая часть может быть произвольной положительной длины, но гарантируется, что из всех 2*n* частей возможно составить ...
707
Title: Vasya and Polynomial Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya is studying in the last class of school and soon he will take exams. He decided to study polynomials. Polynomial is a function *P*(*x*)<==<=*a*0<=+<=*a*1*x*1<=+<=...<=+<=*a**n**x**n*. Numbers *a**i* are calle...
708
Title: Ksusha and Square Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ksusha is a vigorous mathematician. She is keen on absolutely incredible mathematical riddles. Today Ksusha came across a convex polygon of non-zero area. She is now wondering: if she chooses a pair of distinct poin...
709
Title: Bombing Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The commanding officers decided to drop a nuclear bomb on the enemy's forces. You are ordered to determine the power of the warhead that needs to be used. The enemy has *N* strategically important objects. Their positions are know...
710
Title: Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's consider an *n*<=×<=*n* square matrix, consisting of digits one and zero. We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the mat...
711
Title: Fox Dividing Cheese Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two little greedy bears have found two pieces of cheese in the forest of weight *a* and *b* grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox com...
712
Title: Bear and Drawing Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little bear who learns to draw. People usually start with houses, fences and flowers but why would bears do it? Limak lives in the forest and he decides to draw a tree. Recall that tree is a connected graph...
713
Title: Nikita and string Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st ...
714
Title: Mahmoud and Ehab and yet another xor task Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ehab has an array *a* of *n* integers. He likes the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and he likes to bother Mahmoud so he came up with a problem. He ...
715
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a big polar bear. He prepared *n* problems for an algorithmic contest. The *i*-th problem has initial score *p**i*. Also, testers said that it takes *t**i* minutes to solve the *i*-th problem. Problems aren't necessarily ...
716
Title: Game with String Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string *s*, consisting of small English letters, and uniformly at random chooses an integer *k* from a segment [0,<=*len*...
717
Title: PolandBall and White-Red graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: PolandBall has an undirected simple graph consisting of *n* vertices. Unfortunately, it has no edges. The graph is very sad because of that. PolandBall wanted to make it happier, adding some red edges. Th...
718
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* beacons located at distinct positions on a number line. The *i*-th beacon has position *a**i* and power level *b**i*. When the *i*-th beacon is activated, it destroys all beacons to its left (direction of decreasing ...
719
Title: none 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* playe...
720
Title: Devu and Birthday Celebration Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today is Devu's birthday. For celebrating the occasion, he bought *n* sweets from the nearby market. He has invited his *f* friends. He would like to distribute the sweets among them. As he is a nice guy a...
721
Title: Mentors Time Limit: None seconds Memory Limit: None megabytes Problem Description: In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$. A programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of t...
722
Title: Two Paths Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Once archaeologists found *m* mysterious papers, each of which had a pair of integers written on them. Ancient people were known to like writing down the indexes of the roads they walked along, as «*a* *b*» or «*b* *a*», where *a*...
723
Title: Vladik and Entertaining Flags Time Limit: None seconds Memory Limit: None megabytes Problem Description: In his spare time Vladik estimates beauty of the flags. Every flag could be represented as the matrix *n*<=×<=*m* which consists of positive integers. Let's define the beauty of the flag as number of com...
724
Title: Bulbs Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya wants to turn on Christmas lights consisting of *m* bulbs. Initially, all bulbs are turned off. There are *n* buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is...
725
Title: Months and Years Time Limit: None seconds Memory Limit: None megabytes Problem Description: Everybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, ...
726
Title: Petya and Staircases Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump o...
727
Title: Sereja and Suffixes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sereja has an array *a*, consisting of *n* integers *a*1, *a*2, ..., *a**n*. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out *m* integers *l*1,<=*l*2,<=......
728
Title: Little Elephant and Shifts Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant has two permutations *a* and *b* of length *n*, consisting of numbers from 1 to *n*, inclusive. Let's denote the *i*-th (1<=≤<=*i*<=≤<=*n*) element of the permutation *a* as *a**i*, the *j...
729
Title: Petya and Square Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Little Petya loves playing with squares. Mum bought him a square 2*n*<=×<=2*n* in size. Petya marked a cell inside the square and now he is solving the following task. The task is to draw a broken line that would go along...
730
Title: Searching Rectangles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Filya just learned new geometry object — rectangle. He is given a field consisting of *n*<=×<=*n* unit cells. Rows are numbered from bottom to top with integer from 1 to *n*. Columns are numbered from left to right...
731
Title: Brain Network (hard) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In fact, whenever a zo...
732
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, th...
733
Title: Nearest Minimums Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array of *n* integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times. I...
734
Title: Center Alignment Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product. You ...
735
Title: Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. T...
736
Title: Cycle Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya very much likes rectangular tables that consist of characters "0" and "1". Recently he has received one such table as a gift from his mother. The table contained *n* rows and *m* columns. The rows are numbered from t...
737
Title: Plane of Tanks: Duel Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya plays the Plane of Tanks. Tanks are described with the following attributes: - the number of hit points; - the interval between two gun shots (the time required to recharge the gun); - the probability t...
738
Title: Information Reform Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Thought it is already the XXI century, the Mass Media isn't very popular in Walrusland. The cities get news from messengers who can only travel along roads. The network of roads in Walrusland is built so that it is possi...
739
Title: Planning The Expedition Time Limit: None seconds Memory Limit: None megabytes Problem Description: Natasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant. The warehouse has $m$ daily food packages. Each package has some food type $a_i$. E...
740
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. He loves connecting with other bears via social networks. He has *n* friends and his relation with the *i*-th of them is described by a unique integer *t**i*. The bigger this value is, the better the ...
741
Title: Multipliers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ayrat has number *n*, represented as it's prime factorization *p**i* of size *m*, i.e. *n*<==<=*p*1·*p*2·...·*p**m*. Ayrat got secret information that that the product of all divisors of *n* taken modulo 109<=+<=7 is the pa...
742
Title: Black and White Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: The board has got a painted tree graph, consisting of *n* nodes. Let us remind you that a non-directed graph is called a tree if it is connected and doesn't contain any cycles. Each node of the graph is painted bl...
743
Title: Sequence of points Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: You are given the following points with integer coordinates on the plane: *M*0,<=*A*0,<=*A*1,<=...,<=*A**n*<=-<=1, where *n* is odd number. Now we define the following infinite sequence of points *M**i*: *M**i* is symmet...
744
Title: DZY Loves Planting Time Limit: None seconds Memory Limit: None megabytes Problem Description: DZY loves planting, and he enjoys solving tree problems. DZY has a weighted tree (connected undirected graph without cycles) containing *n* nodes (they are numbered from 1 to *n*). He defines the function *g*(*x*,<=...
745
Title: none 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 is a mess. For ...
746
Title: A Good Contest Time Limit: None seconds Memory Limit: None megabytes Problem Description: Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part ...
747
Title: Robots protection Time Limit: None seconds Memory Limit: None megabytes Problem Description: Company "Robots industries" produces robots for territory protection. Robots protect triangle territories — right isosceles triangles with catheti parallel to North-South and East-West directions. Owner of some land ...
748
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing *n* positive integers. At one turn you can pick any element and increase or decrease it by 1. The goa...
749
Title: Playing the ball Time Limit: None seconds Memory Limit: None megabytes Problem Description: A coder cannot sit and code all day. Sometimes it is a good idea to rise from the desk, have a rest, have small talk with colleagues and even play. The coders of the F company have their favorite ball game. Let's imag...
750
Title: Towers Time Limit: None seconds Memory Limit: None megabytes Problem Description: As you know, all the kids in Berland love playing with cubes. Little Petya has *n* towers consisting of cubes of the same size. Tower with number *i* consists of *a**i* cubes stacked one on top of the other. Petya defines the in...
751
Title: Anton and Making Potions Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare *n* potions. Anton has a special kettle, that can prepare one potions in...
752
Title: Sereja and Dividing Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's assume that we have a sequence of doubles *a*1,<=*a*2,<=...,<=*a*|*a*| and a double variable *x*. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element *i*...
753
Title: Race Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Old City is a rectangular city represented as an *m*<=×<=*n* grid of blocks. This city contains many buildings, straight two-way streets and junctions. Each junction and each building is exactly one block. All the streets have...
754
Title: Captain Marmot Time Limit: None seconds Memory Limit: None megabytes Problem Description: Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has *n* regiments, each consisting of 4 moles. Initially, each mole *i* (1<=≤<=*i*<=≤<=4*n*) is placed at ...
755
Title: Colorful Stones (Simplified Edition) Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string *s*. The *i*-th (1-based) character of *s* represents the color of the *i*-th st...
756
Title: k-Factorization Time Limit: None seconds Memory Limit: None megabytes Problem Description: Given a positive integer *n*, find *k* integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to *n*. Input Specification: The first line contains two int...
757
Title: Plus and Square Root Time Limit: None seconds Memory Limit: None megabytes Problem Description: ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, '<=+<=' (plus) and '' (square root). Initially, the number 2 is displayed on the screen. There are *n*<=+<=1 leve...
758
Title: Below the Diagonal Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a square matrix consisting of *n* rows and *n* columns. We assume that the rows are numbered from 1 to *n* from top to bottom and the columns are numbered from 1 to *n* from left to right. Some cells (*...
759
Title: Effective Approach Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array. According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn c...
760
Title: Kefa and Park Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kefa decided to celebrate his first big salary by going to the restaurant. He lives by an unusual park. The park is a rooted tree consisting of *n* vertices with the root at vertex 1. Vertex 1 also contains Kefa's house...
761
Title: Incorrect Flow Time Limit: None seconds Memory Limit: None megabytes Problem Description: At the entrance examination for the magistracy of the MSU Cyber-Mechanics Department Sasha got the question about Ford-Fulkerson algorithm. He knew the topic perfectly as he worked with it many times on programming compe...
762
Title: Road Construction Time Limit: None seconds Memory Limit: None megabytes Problem Description: A country has *n* cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. He wants those roads to be constru...
763
Title: Range Increments Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array *a* for all indexes in the segment [*...
764
Title: BerSU Ball Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! *n* boys and *m* girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves. We know that several boy...
765
Title: Board Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are playing a board card game. In this game the player has two characteristics, *x* and *y* — the white magic skill and the black magic skill, respectively. There are *n* spell cards lying on the table, each of them has ...
766
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer *x*. You are given multiple queries consisting of pairs of integers *l* and *r*. For each query, find the *x*, such that ...
767
Title: Transmitting Levels Time Limit: None seconds Memory Limit: None megabytes Problem Description: Optimizing the amount of data transmitted via a network is an important and interesting part of developing any network application. In one secret game developed deep in the ZeptoLab company, the game universe consi...
768
Title: About Bacteria Time Limit: None seconds Memory Limit: None megabytes Problem Description: Qwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the s...
769
Title: Find Pair Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing *n* (not necessarily different) integers *a*1, *a*2, ..., *a**n*. We are interested in all possible pairs of numbers (*a**i*, *a*...
770
Title: New Year Candles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has *a* candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is s...
771
Title: Race Against Time Time Limit: None seconds Memory Limit: None megabytes Problem Description: Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time par...
772
Title: Bits of merry old England Time Limit: None seconds Memory Limit: None megabytes Problem Description: Another feature of Shakespeare language is that the variables are named after characters of plays by Shakespeare, and all operations on them (value assignment, output etc.) look like a dialog with other charac...
773
Title: Intersection Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: You are given two set of points. The first set is determined by the equation *A*1*x*<=+<=*B*1*y*<=+<=*C*1<==<=0, and the second one is determined by the equation *A*2*x*<=+<=*B*2*y*<=+<=*C*2<==<=0. Write the program which fin...
774
Title: Alice, Bob and Chocolate Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Alice and Bob like games. And now they are ready to start a new game. They have placed *n* chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. Fo...
775
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's ...
776
Title: Nearest Fraction Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given three positive integers *x*,<=*y*,<=*n*. Your task is to find the nearest fraction to fraction whose denominator is no more than *n*. Formally, you should find such pair of integers *a*,<=*b* (1<=≤<=*b...
777
Title: Little Artem and Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Arte...
778
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings *a* and *b* of equal length are called equivalent in one of the two cases: 1. They are equal. 1. If we split string *a* into t...
779
Title: Pacifist frogs Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much. One can get to the shore only by hills that are situated along a straight line that c...
780
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. A widget is some element ...
781
Title: A Leapfrog in the Array Time Limit: None seconds Memory Limit: None megabytes Problem Description: Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy s...
782
Title: Choosing Balls 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 ...
783
Title: Finding Team Member Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a programing contest named SnakeUp, 2*n* people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combinat...
784
Title: Irrational problem Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Little Petya was given this problem for homework: You are given function (here represents the operation of taking the remainder). His task is to count the number of integers *x* in range [*a*;*b*] with property *f*(*x...
785
Title: Photo Processing Time Limit: None seconds Memory Limit: None megabytes Problem Description: Evlampiy has found one more cool application to process photos. However the application has certain limitations. Each photo *i* has a contrast *v**i*. In order for the processing to be truly of high quality, the appli...
786
Title: Soap Time! - 2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: Imagine the Cartesian coordinate system. There are *k* different points containing subway stations. One can get from any subway station to any one instantly. That is, the duration of the transfer between any two subway s...
787
Title: T-shirt Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are going to work in Codeforces as an intern in a team of *n* engineers, numbered 1 through *n*. You want to give each engineer a souvenir: a T-shirt from your country (T-shirts are highly desirable in Codeforces). Unfortun...
788
Title: Crazy Computer Time Limit: None seconds Memory Limit: None megabytes Problem Description: ZS the Coder is coding on a crazy computer. If you don't type in a word for a *c* consecutive seconds, everything you typed disappear! More formally, if you typed a word at second *a* and then the next word at second *...
789
Title: Congruence Equation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants. Input Specificati...
790
Title: Berserk Robot Time Limit: None seconds Memory Limit: None megabytes Problem Description: Help! A robot escaped our lab and we need help finding it. The lab is at the point (0,<=0) of the coordinate plane, at time 0 the robot was there. The robot's movements are defined by a program — a string of length *l*...
791
Title: Olya and Graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: Olya has got a directed non-weighted graph, consisting of *n* vertexes and *m* edges. We will consider that the graph vertexes are indexed from 1 to *n* in some manner. Then for any graph edge that goes from vertex *v* t...
792
Title: Strictly Positive Matrix Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have matrix *a* of size *n*<=×<=*n*. Let's number the rows of the matrix from 1 to *n* from top to bottom, let's number the columns from 1 to *n* from left to right. Let's use *a**ij* to represent the eleme...
793
Title: Lomsat gelral Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour *c* dominating in the subtree of vertex *v* if there are no other colours that appear in the subtree of vertex ...
794
Title: Mischievous Mess Makers 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...
795
Title: Reverses Time Limit: None seconds Memory Limit: None megabytes Problem Description: Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting substrings. You have a photo of ...
796
Title: Valera and Fools Time Limit: None seconds Memory Limit: None megabytes Problem Description: One fine morning, *n* fools lined up in a row. After that, they numbered each other with numbers from 1 to *n*, inclusive. Each fool got a unique number. The fools decided not to change their numbers before the end of ...
797
Title: Icicles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Andrew's favourite Krakozyabra has recenly fled away and now he's eager to bring it back! At the moment the refugee is inside an icy cave with *n* icicles dangling from the ceiling located in integer coordinates numbered from ...
798
Title: Cyclic Coloring Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a directed graph *G* with *n* vertices and *m* arcs (multiple arcs and self-loops are allowed). You have to paint each vertex of the graph into one of the *k* (*k*<=≤<=*n*) colors in such way that for all ...
799