task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Segments Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a straight line colored in white. *n* black segments are added on it one by one. After each segment is added, determine the number of connected components of black segments (i. e. the number of black segments in the ...
2,600
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: На тренировку по подготовке к соревнованиям по программированию пришли *n* команд. Тренер для каждой команды подобрал тренировку, комплект задач для *i*-й команды занимает *a**i* страниц. В распоряжении тренера есть *x* листов бум...
2,601
Title: Sofa Thief Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss? Fortunately, the thief had left a note for G...
2,602
Title: Friends or Not Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus has a hobby — he develops an unusual social network. His work is almost completed, and there is only one more module to implement — the module which determines friends. Oh yes, in this social network one won't...
2,603
Title: A Shade of Moonlight Time Limit: None seconds Memory Limit: None megabytes Problem Description: "To curtain off the moonlight should be hardly possible; the shades present its mellow beauty and restful nature." Intonates Mino. "See? The clouds are coming." Kanno gazes into the distance. "That can't be bette...
2,604
Title: Alyona and Spreadsheet Time Limit: None seconds Memory Limit: None megabytes Problem Description: During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables. Now she has a table filled with integers. The table consists of *n* rows and *m* columns. By ...
2,605
Title: Knights Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came *n* knights. After long discussions it became cl...
2,606
Title: Semifinals Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two semifinals have just been in the running tournament. Each semifinal had *n* participants. There are *n* participants advancing to the finals, they are chosen as follows: from each semifinal, we choose *k* people (0<=≤<=2...
2,607
Title: Pumping Stations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mad scientist Mike has applied for a job. His task is to manage a system of water pumping stations. The system consists of *n* pumping stations, which are numbered by integers from 1 to *n*. Some pairs of stations are...
2,608
Title: Chtholly's request Time Limit: None seconds Memory Limit: None megabytes Problem Description: — I experienced so many great things. — You gave me memories like dreams... But I have to leave now... — One last request, can you... — Help me solve a Codeforces problem? — ...... — What? Chtholly has been thi...
2,609
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare. The f...
2,610
Title: Hexagons Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexa...
2,611
Title: Jzzhu and Chocolate Time Limit: None seconds Memory Limit: None megabytes Problem Description: Jzzhu has a big rectangular chocolate bar that consists of *n*<=×<=*m* unit squares. He wants to cut this bar exactly *k* times. Each cut must meet the following requirements: - each cut should be straight (horizo...
2,612
Title: Candy Boxes Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {*x*1,<=*x...
2,613
Title: Double Happiness Time Limit: 3 seconds Memory Limit: 128 megabytes Problem Description: On the math lesson a teacher asked each pupil to come up with his own lucky numbers. As a fan of number theory Peter chose prime numbers. Bob was more original. He said that number *t* is his lucky number, if it can be rep...
2,614
Title: Is it rated? Time Limit: None seconds Memory Limit: None megabytes Problem Description: Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number ...
2,615
Title: George and Sleep Time Limit: None seconds Memory Limit: None megabytes Problem Description: George woke up and saw the current time *s* on the digital clock. Besides, George knows that he has slept for time *t*. Help George! Write a program that will, given time *s* and *t*, determine the time *p* when Geor...
2,616
Title: Eternal Victory Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal! He decided to visit a...
2,617
Title: Vladik and Complicated Book Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vladik had started reading a complicated book about algorithms containing *n* pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation *P*<...
2,618
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Petya likes points a lot. Recently his mom has presented him *n* points lying on the line *OX*. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of th...
2,619
Title: Array Queries Time Limit: None seconds Memory Limit: None megabytes Problem Description: *a* is an array of *n* positive integers, all of which are not greater than *n*. You have to process *q* queries to this array. Each query is represented by two numbers *p* and *k*. Several operations are performed in ea...
2,620
Title: Triangles Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Little Petya likes to draw. He drew *N* red and *M* blue points on the plane in such a way that no three points lie on the same line. Now he wonders what is the number of distinct triangles with vertices in red points which do not...
2,621
Title: Perfect Security Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice has a very important message *M* consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random ke...
2,622
Title: University Schedule Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem your task is to come up with a week schedule of classes in university for professors and student groups. Consider that there are 6 educational days in week and maximum number of classes per education...
2,623
Title: Wilbur and Trees Time Limit: None seconds Memory Limit: None megabytes Problem Description: Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. There are *n* trees located at various positions on a line. Tree *i* is located at position...
2,624
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Duff has been a soldier in the army. Malek is her commander. Their country, Andarz Gu has *n* cities (numbered from 1 to *n*) and *n*<=-<=1 bidirectional roads. Each road connects two different cities. There exist a uniq...
2,625
Title: Read Time 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 track...
2,626
Title: Roads in Yusland Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mayor of Yusland just won the lottery and decided to spent money on something good for town. For example, repair all the roads in the town. Yusland consists of *n* intersections connected by *n*<=-<=1 bidirectional ro...
2,627
Title: Misha and Permutations Summation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's define the sum of two permutations *p* and *q* of numbers 0,<=1,<=...,<=(*n*<=-<=1) as permutation , where *Perm*(*x*) is the *x*-th lexicographically permutation of numbers 0,<=1,<=...,<=(*n*<=-<...
2,628
Title: Smart Boy Time Limit: 4 seconds Memory Limit: 256 megabytes Problem Description: Once Petya and Vasya invented a new game and called it "Smart Boy". They located a certain set of words — the dictionary — for the game. It is admissible for the dictionary to contain similar words. The rules of the game are as...
2,629
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has been making good progress with her studies and now knows the first *k* E...
2,630
Title: Dijkstra? Time Limit: 1 seconds Memory Limit: 64 megabytes Problem Description: You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*. Input Specification: The first line contains two integers *n* a...
2,631
Title: 2-3-numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: A positive integer is called a 2-3-integer, if it is equal to 2*x*·3*y* for some non-negative integers *x* and *y*. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For exa...
2,632
Title: One-Way Reform Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* cities and *m* two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itse...
2,633
Title: Sockets Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya has got many devices that work on electricity. He's got *n* supply-line filters to plug the devices, the *i*-th supply-line filter has *a**i* sockets. Overall Vasya has got *m* devices and *k* electrical sockets in his f...
2,634
Title: Anatoly and Cockroaches Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are *n* cockroaches...
2,635
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a sequence *a*1,<=*a*2,<=...,<=*a**n* consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing ord...
2,636
Title: Did you mean... Time Limit: None seconds Memory Limit: None megabytes Problem Description: Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (...
2,637
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Вдоль дороги стоят *n* путешественников. Дорога представляет собой прямую, размерами путешественников можно пренебречь, считая их точками. Водитель автобуса Василий, благодаря мобильному приложению, знает для каждого путешественн...
2,638
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly *n* skills. Each skill is represented by a non-negative...
2,639
Title: Kuriyama Mirai's Stones Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones s...
2,640
Title: Compartments Time Limit: None seconds Memory Limit: None megabytes Problem Description: A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of *n* compartments (each compartment...
2,641
Title: Cards Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* cards (*n* is even) in the deck. Each card has a positive integer written on it. *n*<=/<=2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one p...
2,642
Title: Convert to Ones Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones. Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$. You can a...
2,643
Title: Moodular Arithmetic Time Limit: None seconds Memory Limit: None megabytes Problem Description: As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin w...
2,644
Title: Valera and Queries Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valera loves segments. He has recently come up with one interesting problem. The *Ox* axis of coordinates has *n* segments, the *i*-th segment starts in position *l**i* and ends in position *r**i* (we will mark it a...
2,645
Title: Days of Floral Colours Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days. On the rim of the Floral Clock are 2*n* flower...
2,646
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules. The game is played on the following field. Players are mak...
2,647
Title: Nudist Beach Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nudist Beach is planning a military operation to attack the Life Fibers. In this operation, they will attack and capture several cities which are currently under the control of the Life Fibers. There are *n* cities, label...
2,648
Title: Parking Lot Time Limit: None seconds Memory Limit: None megabytes Problem Description: A parking lot in the City consists of *n* parking spaces, standing in a line. The parking spaces are numbered from 1 to *n* from left to right. When a car arrives at the lot, the operator determines an empty parking space...
2,649
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are *n*<=+<=1...
2,650
Title: Valhalla Siege Time Limit: None seconds Memory Limit: None megabytes Problem Description: Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle. Ivar has $n$ warriors, he places them on a straight line ...
2,651
Title: Water Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mad scientist Mike has constructed a rooted tree, which consists of *n* vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numbered from 1 to *n* with the root ...
2,652
Title: New Skateboard Time Limit: None seconds Memory Limit: None megabytes Problem Description: Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother...
2,653
Title: Perfectionist Arkadiy Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkadiy has lots square photos with size *a*<=×<=*a*. He wants to put some of them on a rectangular wall with size *h*<=×<=*w*. The photos which Arkadiy will put on the wall must form a rectangular grid and the ...
2,654
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pari wants to buy an expensive chocolate from Arya. She has *n* coins, the value of the *i*-th coin is *c**i*. The price of the chocolate is *k*, so Pari will take a subset of her coins with sum equal to *k* and give it to Arya. ...
2,655
Title: Helpful Maths Time Limit: None seconds Memory Limit: None megabytes Problem Description: Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation. The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To mak...
2,656
Title: Kicker Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each tea...
2,657
Title: Vitya in the Countryside Time Limit: None seconds Memory Limit: None megabytes Problem Description: Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the momen...
2,658
Title: Evacuation Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: They've screwed something up yet again... In one nuclear reactor of a research station an uncontrolled reaction is in progress and explosion which will destroy the whole station will happen soon. The station is represented by a...
2,659
Title: The number of positions Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petr stands in line of *n* people, but he doesn't know exactly which position he occupies. He can say that there are no less than *a* people standing in front of him and no more than *b* people standing behind h...
2,660
Title: Double Cola Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resultin...
2,661
Title: Let's Play Osu! Time Limit: None seconds Memory Limit: None megabytes Problem Description: You're playing a game called Osu! Here's a simplified version of it. There are *n* clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as "O", bad as "X", then the whole play c...
2,662
Title: Power Tower Time Limit: None seconds Memory Limit: None megabytes Problem Description: Priests of the Quetzalcoatl cult want to build a tower to represent a power of their god. Tower is usually made of power-charged rocks. It is built with the help of rare magic by levitating the current top of tower and addi...
2,663
Title: USB vs. PS/2 Time Limit: None seconds Memory Limit: None megabytes Problem Description: Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the c...
2,664
Title: Toys Time Limit: 5 seconds Memory Limit: 256 megabytes Problem Description: Little Masha loves arranging her toys into piles on the floor. And she also hates it when somebody touches her toys. One day Masha arranged all her *n* toys into several piles and then her elder brother Sasha came and gathered all the...
2,665
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: They say that Berland has exactly two problems, fools and roads. Besides, Berland has *n* cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between ...
2,666
Title: Keyboard Time Limit: None seconds Memory Limit: None megabytes Problem Description: Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way: Unfortunately Mole is blind, so sometimes it is problem for him to put his hands accurately....
2,667
Title: The Child and Polygon Time Limit: None seconds Memory Limit: None megabytes Problem Description: This time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements: - each vertex of each triangle is...
2,668
Title: Pocket Book Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day little Vasya found mom's pocket book. The book had *n* names of her friends and unusually enough, each name was exactly *m* letters long. Let's number the names from 1 to *n* in the order in which they are written. ...
2,669
Title: Appleman and Complicated Task Time Limit: None seconds Memory Limit: None megabytes Problem Description: Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him? Given a *n*<=×<=*n* checkerboard. Each cell of the board has either cha...
2,670
Title: Berland SU Computer Network Time Limit: None seconds Memory Limit: None megabytes Problem Description: In the computer network of the Berland State University there are *n* routers numbered from 1 to *n*. Some pairs of routers are connected by patch cords. Information can be transmitted over patch cords in bo...
2,671
Title: none 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 of two types: 1. ...
2,672
Title: Quick Tortoise Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has a field, which is a rectangular table of size *n*<=×<=*m*. We assume that the field rows are numbered from 1 to *n* from top to bottom, and the field columns are numbered from 1 to *m* from left to right. Th...
2,673
Title: Greg's Workout Time Limit: None seconds Memory Limit: None megabytes Problem Description: Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg ...
2,674
Title: Multicolored Marbles Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus plays with red and blue marbles. He put *n* marbles from the left to the right in a row. As it turned out, the marbles form a zebroid. A non-empty sequence of red and blue marbles is a zebroid, if the c...
2,675
Title: I'm Feeling Lucky! Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have one chip and one chance to play roulette. Are you feeling lucky? Input Specification: none Output Specification: Print your bet. Your chip must be placed entirely within some square (not on an edge or a co...
2,676
Title: Interesting Sequence Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the momen...
2,677
Title: Tanya and Password Time Limit: None seconds Memory Limit: None megabytes Problem Description: While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of *n*<=+<=2 characters. She has written all the possible *n* three-letter ...
2,678
Title: King's Problem? Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom. King Copa has already done the first three things. Now he ju...
2,679
Title: Memory and Trident Time Limit: None seconds Memory Limit: None megabytes Problem Description: Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string *s* with his directions for motion: - An 'L' indicates he should move one unit left. - An 'R' indicates he shou...
2,680
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay at integer points (it is possible that the cube's sides are not parallel to the coordinate axes). Th...
2,681
Title: Cool Slogans Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bomboslav set up a branding agency and now helps companies to create new logos and advertising slogans. In term of this problems, slogan of the company should be a non-empty substring of its name. For example, if the compa...
2,682
Title: Artem and Array Time Limit: None seconds Memory Limit: None megabytes Problem Description: Artem has an array of *n* positive integers. Artem decided to play with it. The game consists of *n* moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets *min*(*a*,...
2,683
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A festival will be held in a town's main street. There are *n* sections in the main street. The sections are numbered 1 through *n* from left to right. The distance between each adjacent sections is 1. In the festival *m* firewor...
2,684
Title: PE Lesson Time Limit: None seconds Memory Limit: None megabytes Problem Description: Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-...
2,685
Title: Vitaliy and Pie Time Limit: None seconds Memory Limit: None megabytes Problem Description: After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with *n* room located in a line and numbered starting from one from...
2,686
Title: The Classic Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a weighted undirected graph on *n* vertices and *m* edges. Find the shortest path from vertex *s* to vertex *t* or else state that such path doesn't exist. Input Specification: The first line of the i...
2,687
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \cdot (q + 1)$ rectangles were left after the cutting. After the c...
2,688
Title: Main Sequence Time Limit: None seconds Memory Limit: None megabytes Problem Description: As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different t...
2,689
Title: Gambling Nim Time Limit: None seconds Memory Limit: None megabytes Problem Description: As you know, the game of "Nim" is played with *n* piles of stones, where the *i*-th pile initially contains *a**i* stones. Two players alternate the turns. During a turn a player picks any non-empty pile and removes any po...
2,690
Title: Alyona and Mex Time Limit: None seconds Memory Limit: None megabytes Problem Description: Someone gave Alyona an array containing *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is small...
2,691
Title: Letter Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading *s*1 and text *s*2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to...
2,692
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Drazil is a monkey. He lives in a circular park. There are *n* trees around the park. The distance between the *i*-th tree and (*i*<=+<=1)-st trees is *d**i*, the distance between the *n*-th tree and the first tree is *d**n*. The ...
2,693
Title: New Year and Counting Cards Time Limit: None seconds Memory Limit: None megabytes Problem Description: Your friend has *n* cards. You know that each card has a lowercase English letter on one side and a digit on the other. Currently, your friend has laid out the cards on a table so only one side of each car...
2,694
Title: Presents Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: The Hedgehog likes to give presents to his friend, but no less he likes to receive them. Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the spec...
2,695
Title: Cubical Planet Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite v...
2,696
Title: Switches and Lamps Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* switches and *m* lamps. The *i*-th switch turns on some subset of the lamps. This information is given as the matrix *a* consisting of *n* rows and *m* columns where *a**i*,<=*j*<==<=1 if the *i*-th...
2,697
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel is participating in a party in Prime Kingdom. There are *n* foxes there (include Fox Ciel). The i-th fox is *a**i* years old. They will have dinner around some round tables. You want to distribute foxes such that: 1. E...
2,698
Title: Journey Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are *n* showplaces in the city, numbered from 1 to *n*, and some of them are connected by one-directional roads. The roads in Berlato...
2,699