problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 β | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
E2. Space Voyagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is a... | Input2 51 52 4 | Output1 | 2 seconds | 256 megabytes | ['binary search', '*1900'] |
E1. Space Voyagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is a... | Input2 51 52 4 | Output1 | 2 seconds | 256 megabytes | ['binary search', '*1700'] |
D2. Encrypting Messagestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contesta... | Input4 3 21 1 1 11 1 1 | Output0 1 1 0 | 2 seconds | 256 megabytes | ['data structures', '*1500'] |
D1. Encrypting Messagestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contesta... | Input4 3 21 1 1 11 1 1 | Output0 1 1 0 | 2 seconds | 256 megabytes | ['brute force', '*1200'] |
C2. Partytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To... | Input981 21 32 34 56 77 88 99 621 67 9 | Output3 | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dsu', 'graphs', '*1500'] |
C1. Partytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To... | Input981 21 32 34 56 77 88 99 621 67 9 | Output3 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', '*1500'] |
B2. Rectangular Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. H... | Input10 | Output16 | 2 seconds | 256 megabytes | ['number theory', '*1200'] |
B1. Rectangular Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. H... | Input10 | Output16 | 2 seconds | 256 megabytes | ['number theory', '*1000'] |
A2. Good Matrix Elementstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an nβΓβn size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Element... | Input31 2 34 5 67 8 9 | Output45 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
A1. Good Matrix Elementstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an nβΓβn size matrix, where n is odd. The Smart Beaver considers the following matrix elements good: Element... | Input31 2 34 5 67 8 9 | Output45 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Archaeologytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time you should help a team of researchers on an island in the Pacific Ocean. They research the culture of the ancient tribes that used to inhabit the island many years ago.Overall they've dug out n ... | Input61 2 11 3 54 1 74 5 36 4 210+ 3+ 1?+ 6?+ 5?- 6- 3? | Output5141710 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*3100'] |
D. Hyper Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPaul ErdΕs's prediction came true. Finally an alien force landed on the Earth. In contrary to our expectation they didn't asked the humans to compute the value of a Ramsey number (maybe they had solved i... | Input2cbadgh21 2aedfhr | Output3 | 2 seconds | 256 megabytes | ['dp', '*2500'] |
C. Playing with Supergluetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo players play a game. The game is played on a rectangular board with nβΓβm squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is... | Input1 6 1 2 1 6 | OutputFirst | 2 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', '*2000'] |
B. Word Cuttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word w, let's split this word into two non-empty parts x and y ... | Inputabab2 | Output1 | 2 seconds | 256 megabytes | ['dp', '*1700'] |
A. Trading Businesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and t... | Input3 3 10Venus6 5 37 6 58 6 10Earth10 9 08 6 410 9 3Mars4 3 08 4 127 2 5 | Output16 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1200'] |
F. Gnomes of Might and Magictime limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays a popular game the Gnomes of Might and Magic.In this game Vasya manages the kingdom of gnomes, consisting of several castles, connected by bidirectional roads. The kingdom road n... | Input6 31 2 33 1 4 23 2 5 33 3 6 110+ 1 2+ 4 2+ 1 3+ 2 3? 1 2+ 2 5? 1 2? 1 2+ 1 2? 1 2 | Output0101 | 8 seconds | 256 megabytes | ['data structures', 'graphs', 'implementation', 'shortest paths', '*3000'] |
E. Power Defencetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays the Power Defence. He must pass the last level of the game. In order to do this he must kill the Main Villain, who moves in a straight line at speed 1 meter per second from the point (β-ββ,β... | Input1 0 010 10 10100 100 | Output1989.97487421 | 3 seconds | 256 megabytes | ['brute force', 'dp', 'geometry', 'greedy', '*2600'] |
D. Plane of Tanks: Dueltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya 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 pro... | Input100 3 50 50 0100 3 50 50 0 | Output1.000000 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'math', 'probabilities', '*2400'] |
C. Geometry Horsetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays the Geometry Horse.The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the curre... | Input15 1023 6 | Output70 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'sortings', 'two pointers', '*1600'] |
B. Plane of Tanks: Protime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. A player is given a non-negativ... | Input5vasya 100vasya 200artem 100kolya 200igor 250 | Output4artem noobigor prokolya randomvasya random | 2 seconds | 256 megabytes | ['implementation', '*1400'] |
A. Robot Bicorn Attacktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays Robot Bicorn Attack.The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has al... | Input1234 | Output37 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1400'] |
C. Range Incrementstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus 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 ... | Input61 2 1 1 4 1 | Output52 25 55 55 51 6 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*1800'] |
B. File Listtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEudokimus, a system administrator is in trouble again. As a result of an error in some script, a list of names of very important files has been damaged. Since they were files in the BerFS file system, it is... | Inputread.meexample.txtb.cpp | OutputYESread.meexample.txtb.cpp | 2 seconds | 256 megabytes | ['dp', 'greedy', 'implementation', '*1400'] |
A. Problem About Equationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA group of n merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is rea... | Input5 501 2 3 4 5 | Output12.00000011.00000010.0000009.0000008.000000 | 2 seconds | 256 megabytes | ['math', '*1100'] |
E. Camping Groupstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA club wants to take its members camping. In order to organize the event better the club directors decided to partition the members into several groups. Club member i has a responsibility value ri and ... | Input5 11 5 4 1 24 4 3 2 245 32 32 54 1 | Output43-14 | 2 seconds | 256 megabytes | ['data structures', 'sortings', '*2600'] |
D. Deputiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Trinitarian kingdom has exactly nβ=β3k cities. All of them are located on the shores of river Trissisipi, which flows through the whole kingdom. Some of the cities are located on one side of the river, a... | Input6 61 24 13 56 52 64 6 | OutputYES1 2 1 2 2 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'implementation', '*2500'] |
C. Spiral Maximumtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider a kβΓβk square, divided into unit squares. Please note that kββ₯β3 and is odd. We'll paint squares starting from the upper left square in the following order: first we move to the right, ... | Input6 50 0 0 0 01 1 1 1 10 0 0 0 11 1 1 0 11 0 0 0 11 1 1 1 1 | Output17 | 3 seconds | 256 megabytes | ['brute force', 'dp', '*1900'] |
B. Chamber of Secretstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output"The Chamber of Secrets has been opened again" β this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry... | Input3 3.#.....#. | Output2 | 2 seconds | 256 megabytes | ['dfs and similar', 'shortest paths', '*1800'] |
A. Rock-Paper-Scissorstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!).Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round... | Input7RPSRSPP | Output3 2 | 3 seconds | 256 megabytes | ['implementation', 'math', '*1300'] |
E. BHTML+BCSStime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is about imaginary languages BHTML and BCSS, which slightly resemble HTML and CSS. Read the problem statement carefully as the resemblance is rather slight and the problem uses very simplified... | Input<a><b><b></b></b></a><a><b></b><b><v/></b></a><b></b>4aa b ba bb a | Output2140 | 4 seconds | 256 megabytes | ['*special problem', 'dfs and similar', 'expression parsing', '*2200'] |
D. Calendar Reformtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputReforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calenda... | Input25 3 | Output30 | 2 seconds | 256 megabytes | ['*special problem', 'number theory', '*1500'] |
C. Bustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a bus stop near the university. The lessons are over, and n students come to the stop. The i-th student will appear at the bus stop at time ti (all ti's are distinct).We shall assume that the stop is loca... | Input1 103 5 | Output8 | 1 second | 256 megabytes | ['*special problem', 'implementation', 'sortings', '*1500'] |
B. Pseudorandom Sequence Periodtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: (for iββ₯β1). Here a, b, ... | Input2 6 12 11 | Output2 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', 'number theory', '*1200'] |
A. Phone Codetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has n friends in Tarasov city. Polycarpus knows phone numbers of all his friends: they are strings s1,βs2,β...,βsn. All these strings consist only of digits and have the same length. Once Polyca... | Input400209002190099900909 | Output2 | 2 seconds | 256 megabytes | ['*special problem', 'brute force', 'implementation', '*800'] |
H. A polylinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output InputThe input contains two integers a,βb (1ββ€βaββ€β10,β0ββ€βbββ€β22Β·aβ-β1) separated by a single space.OutputOutput two integers separated by a single space.ExamplesInput1 0Output0 0Input2 15Output3 0Input... | Input1 0 | Output0 0 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1700'] |
G. Mysterious numbers - 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputInputThe only line of input contains three integers a1,βa2,βa3 (1ββ€βa1,βa2,βa3ββ€β20), separated by spaces.OutputOutput a single integer.ExamplesInput2 3 2Output5Input13 14 1Output14Input14 5 9O... | Input2 3 2 | Output5 | 2 seconds | 256 megabytes | ['*special problem', '*1600'] |
F. ucyhftime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputqd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.Inputjxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1ββ€βdββ€β11184) β jxu edu-rqiut ydtun ev jxu ucyhf je vydt.O... | Input1 | Output13 | 2 seconds | 64 megabytes | ['*special problem', 'brute force', 'implementation', 'number theory', '*1600'] |
C. A Piece of Caketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHow to make a cake you'll never eat.Ingredients. 2 carrots 0 calories 100 g chocolate spread 1 pack of flour 1 egg Method. Put calories into the mixing bowl. Take carrots from refrigerator. ... | Input4 1 2 3 4 | Output30 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*2000'] |
B. Startime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output InputThe input contains a single integer a (1ββ€βaββ€β18257).OutputPrint a single integer output (1ββ€βoutputββ€β2Β·109).ExamplesInput2Output13 | Input2 | Output13 | 2 seconds | 256 megabytes | ['*special problem', 'combinatorics', '*1300'] |
A. Mysterious numbers - 1time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputInputThe input contains two integers a1,βa2 (0ββ€βaiββ€β109), separated by a single space.OutputOutput a single integer.ExamplesInput3 14Output44Input27 12Output48Input100 200Output102 | Input3 14 | Output44 | 2 seconds | 256 megabytes | ['*special problem', 'constructive algorithms', '*1200'] |
B. Replacing Digitstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1ββ€βjββ€βm) of sequence s means that you can choose an arbitrary p... | Input1024010 | Output1124 | 2 seconds | 256 megabytes | ['greedy', '*1100'] |
A. Chorestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya and Vasya are brothers. Today is a special day for them as their parents left them home alone and commissioned them to do n chores. Each chore is characterized by a single parameter β its complexity. The... | Input5 2 36 2 3 100 1 | Output3 | 2 seconds | 256 megabytes | ['sortings', '*800'] |
B. Wizards and Minimal Spelltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's dive into one of the most interesting areas of magic β writing spells. Learning this exciting but challenging science is very troublesome, so now you will not learn the magic words, bu... | Input # include <cstdio>using namespace std;int main ( ){puts("Hello # World"); ##} | Output # include <cstdio>usingnamespacestd;intmain(){puts("Hello#World");##} | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1700'] |
A. Wizards and Demonstrationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome country is populated by wizards. They want to organize a demonstration.There are n people living in the city, x of them are the wizards who will surely go to the demonstration. Other ci... | Input10 1 14 | Output1 | 2 seconds | 256 megabytes | ['implementation', 'math', '*900'] |
E. Wizards and Betstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn some country live wizards. They like to make weird bets.Two wizards draw an acyclic directed graph with n vertices and m edges (the graph's vertices are numbered from 1 to n). A source is a vertex... | Input4 2 10000031 32 4 | Output1 | 3 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'math', 'matrices', '*2900'] |
D. Wizards and Roadstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn some country live wizards. They love to build cities and roads.The country used to have k cities, the j-th city (1ββ€βjββ€βk) was located at a point (xj, yj). It was decided to create another nβ-βk... | Input6 60 01 12 23 34 45 52 3 3 240 51 42 33 3 | Output3210 | 3 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'graph matchings', 'graphs', 'greedy', '*3000'] |
C. Wizards and Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn some country live wizards. They love playing with numbers. The blackboard has two numbers written on it β a and b. The order of the numbers is not important. Let's consider aββ€βb for the sake o... | Input410 2131 100 110 30 | OutputFirstSecondSecondFirst | 2 seconds | 256 megabytes | ['games', 'math', '*2300'] |
B. Wizards and Huge Prizetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne must train much to do well on wizardry contests. So, there are numerous wizardry schools and magic fees.One of such magic schools consists of n tours. A winner of each tour gets a huge priz... | Input3 1 010 20 30-1 -1 2 | Output0.300000000000 | 2 seconds | 256 megabytes | ['dp', 'math', 'probabilities', '*1800'] |
A. Wizards and Trolleybusestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn some country live wizards. They love to ride trolleybuses.A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to... | Input3 10 100000 105 111000 1 | Output1000.50000000001000.500000000011000.0500000000 | 1 second | 256 megabytes | ['implementation', 'math', '*1600'] |
E. Tetrahedrontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. ... | Input2 | Output3 | 2 seconds | 256 megabytes | ['dp', 'math', 'matrices', '*1500'] |
D. Shoe Storetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe warehouse in your shop has n shoe pairs. Each pair is characterized by two integers: its price ci and its size si. We know that on this very day all numbers si are different, that is, there is no more ... | Input310 130 220 3220 120 2 | Output3022 31 1 | 2 seconds | 256 megabytes | ['dp', 'graph matchings', 'greedy', 'sortings', 'two pointers', '*2500'] |
C. Mediantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA 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 ... | Input3 1010 20 30 | Output1 | 2 seconds | 256 megabytes | ['greedy', 'math', 'sortings', '*1500'] |
B. Polygonstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections an... | Input6-2 10 33 34 13 -22 -240 12 23 11 0 | OutputYES | 2 seconds | 256 megabytes | ['geometry', 'sortings', '*2100'] |
A. Rank Listtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnother programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty... | Input7 24 104 104 103 202 12 11 10 | Output3 | 2 seconds | 256 megabytes | ['binary search', 'implementation', 'sortings', '*1100'] |
E. Compatible Numberstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo integers x and y are compatible, if the result of their bitwise "AND" equals zero, that is, a & bβ=β0. For example, numbers 90 (10110102) and 36 (1001002) are compatible, as 10110102 & 1001002β... | Input290 36 | Output36 90 | 4 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'dp', '*2200'] |
D. Beard Graphtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define a non-oriented connected graph of n vertices and nβ-β1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than one vertex,... | Input31 22 373 1 23 1 33 2 32 23 1 23 1 33 2 3 | Output1211-1-1 | 4 seconds | 256 megabytes | ['data structures', 'dsu', 'trees', '*2100'] |
C. Another Problem on Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string is binary, if it consists only of characters "0" and "1".String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. Fo... | Input11010 | Output6 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'dp', 'math', 'strings', 'two pointers', '*1600'] |
B. Burning Midnight Oiltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day a highly important task was commissioned to Vasya β writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writ... | Input7 2 | Output4 | 2 seconds | 256 megabytes | ['binary search', 'implementation', '*1500'] |
A. Supercentral Pointtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1,βy1),β(x2,βy2),β...,β(xn,βyn). Let's define neighbors for some fixed point from the given s... | Input81 14 23 11 20 20 11 01 3 | Output2 | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
E. Polycarpus and Taskstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has many tasks. Each task is characterized by three integers li, ri and ti. Three integers (li,βri,βti) mean that to perform task i, one needs to choose an integer si (liββ€βsi;Β siβ+βti... | Input51 8 52 9 33 10 38 11 411 12 2 | Output0 0 1 0 -1 | 3 seconds | 256 megabytes | ['*3100'] |
D. Minimum Diametertime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points on the plane. You need to delete exactly k of them (kβ<βn) so that the diameter of the set of the remaining nβ-βk points were as small as possible. The diameter of a set of p... | Input5 21 20 02 21 13 3 | Output5 2 | 1.5 seconds | 256 megabytes | ['binary search', 'brute force', '*3100'] |
C. Machine Programmingtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne remarkable day company "X" received k machines. And they were not simple machines, they were mechanical programmers! This was the last unsuccessful step before switching to android programmers... | Input3 12 7 51 3 34 1 3 | Output0 1 1 | 5 seconds | 256 megabytes | ['flows', 'graphs', '*2400'] |
B. Ancient Berland Hieroglyphstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occ... | Input5 41 2 3 4 51 3 5 6 | Output2 | 1.5 seconds | 256 megabytes | ['two pointers', '*2000'] |
A. Variable, or There and Back Againtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLife is not easy for the perfectly common variable named Vasya. Wherever it goes, it is either assigned a value, or simply ignored, or is being used!Vasya's life goes in states of a ... | Input4 31 0 0 21 22 33 4 | Output1111 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*1700'] |
E. e-Governmenttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe best programmers of Embezzland compete to develop a part of the project called "e-Government" β the system of automated statistic collecting and press analysis.We know that any of the k citizens can b... | Input7 3aaaab?aaab-2?aaab-3?aaab+2?aabbaa | Output6436 | 1 second | 256 megabytes | ['data structures', 'dfs and similar', 'dp', 'strings', 'trees', '*2800'] |
D. Large Refrigeratortime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya wants to buy a new refrigerator. He believes that a refrigerator should be a rectangular parallelepiped with integer edge lengths. Vasya calculated that for daily use he will need a refrigera... | Input312 3117 133 12 35 1 | Output24 2 2 270 1 1 17148 4 6 5 | 5 seconds | 256 megabytes | ['brute force', '*2900'] |
C. Conveyortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton came to a chocolate factory. There he found a working conveyor and decided to run on it from the beginning to the end.The conveyor is a looped belt with a total length of 2l meters, of which l meters ar... | Input1 1 1 10 | Output0.750000000000000000000.25000000000000000000 | 1 second | 256 megabytes | ['sortings', 'two pointers', '*2100'] |
B. Lemmingstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at the height of h meters, the second ... | Input5 3 21 2 3 2 11 2 1 2 10 | Output5 2 4 | 1 second | 256 megabytes | ['binary search', '*2000'] |
A. Substring and Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pai... | Inputaaaa | Output5 | 2 seconds | 256 megabytes | ['dp', '*1700'] |
J. Bracketstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters "+" and "1". For example, sequences "(())()", "()" and "(()(()))" are balanced, while ")(", "(()... | Input(()(()))() | OutputYES | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
I. Truncatable primestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA truncatable prime is a prime number which contains no zeros in decimal notation and all its suffixes are primes. 1 is considered to be not a prime.You are given a positive integer n. Figure out w... | Input19 | OutputNO | 3 seconds | 256 megabytes | ['*special problem', '*2000'] |
H. Alternating casetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string consisting of alphabet letters. Convert it to alternating case: the letters on odd positions should be in uppercase, and the letters on even positions should be lowercase. The ... | InputCodeforces | OutputCoDeFoRcEs | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
G. Non-decimal sumtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of integers written in base radix. Calculate their sum and output it written in the same base.InputThe first line of the input contains an integer n (1ββ€βnββ€β10) β the size of t... | Input316F020B004 | Output2FF | 3 seconds | 256 megabytes | ['*special problem', '*2000'] |
F. Factorial zerostime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Output the number of trailing zeros in n! (n! denotes a product of integers between 1 and n, inclusive).InputThe only line of input contains an integer n (1ββ€βnββ€β1... | Input6 | Output1 | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
E. HQ9+time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHQ9+ is a joke programming language which has only four one-character instructions: "H" prints "Hello, World!", "Q" prints the whole source code of the program itself (at each call), "9" prints the lyrics of "99... | InputHello! | OutputYES | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
D. Remove digitstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string. Remove all digits from it. When a character is removed from a string, all characters to the right of it are shifted one position to the left.InputThe only line of input contains ... | InputVK-Cup-2012! | OutputVK-Cup-! | 3 seconds | 256 megabytes | ['*special problem', '*1900'] |
C. Prime factorizationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Output its prime factorization.If n = a1b1 a2b2 ... akbk (biβ>β0), where ak are prime numbers, the output of your program should look as follows: a1*...*a1*a2*.... | Input245 | Output5*7*7 | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
B. Binary notationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Output its binary notation.InputThe only line of input data contains an integer n (1ββ€βnββ€β106).OutputOutput the binary notation of n (without any leading zeros).Ex... | Input5 | Output101 | 3 seconds | 256 megabytes | ['*special problem', '*1800'] |
A. Pentagonal numberstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPentagonal numbers are figurate numbers which can be calculated using the formula pnβ=β(3n2β-βn)β/β2 (always integer). You are given n; calculate n-th pentagonal number.InputThe only line of input ... | Input2 | Output5 | 3 seconds | 256 megabytes | ['*special problem', 'implementation', '*1100'] |
E. Polycarpus the Safecrackertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has t safes. The password for each safe is a square matrix consisting of decimal digits '0' ... '9' (the sizes of passwords to the safes may vary). Alas, Polycarpus has forgotten... | Input4112394019001 | Output428612834 | 3 seconds | 256 megabytes | ['brute force', 'dp', '*2500'] |
D. Distance in Treetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA tree is a connected graph that doesn't contain any cycles.The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.You are given a tree with ... | Input5 21 22 33 42 5 | Output4 | 3 seconds | 512 megabytes | ['dfs and similar', 'dp', 'trees', '*1800'] |
C. Abracadabratime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: On the first step the string consists of a single character "a". On the k-th step Polycarpus co... | Input3 6 1 4 | Output2 | 1 second | 256 megabytes | ['divide and conquer', '*2400'] |
B. Discountstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least ... | Input3 22 13 23 1 | Output5.52 1 21 3 | 3 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1700'] |
A. Dress'em in Vests!time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ulti... | Input5 3 0 01 2 3 3 41 3 5 | Output21 13 2 | 3 seconds | 256 megabytes | ['binary search', 'brute force', 'greedy', 'two pointers', '*1300'] |
E. Buses and Peopletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe main Bertown street is represented by a straight line. There are 109 bus stops located on the line. The stops are numbered with integers from 1 to 109 in the order in which they follow on the road... | Input4 31 10 105 6 26 7 35 7 45 7 11 2 11 10 11 | Output4 1 -1 | 1 second | 256 megabytes | ['binary search', 'data structures', 'sortings', '*2400'] |
D. Edges in MSTtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a connected weighted undirected graph without any loops and multiple edges. Let us remind you that a graph's spanning tree is defined as an acyclic connected subgraph of the given graph tha... | Input4 51 2 1011 3 1002 3 22 4 23 4 1 | Outputnoneanyat least oneat least oneany | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'sortings', '*2300'] |
C. Find Pairtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got another problem dealing with arrays. Let's consider an arbitrary sequence containing n (not necessarily different) integers a1, a2, ..., an. We are interested in all possible pairs of numbers (ai,... | Input2 42 1 | Output2 2 | 1 second | 256 megabytes | ['implementation', 'math', 'sortings', '*1700'] |
B. Unlucky Tickettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks ... | Input22421 | OutputYES | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1100'] |
A. Twinstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputImagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a tw... | Input23 3 | Output2 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*900'] |
E. Zebra Towertime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters β color ci an... | Input41 21 32 43 3 | Output932 3 1 | 1.5 seconds | 256 megabytes | ['*special problem', 'data structures', 'greedy', 'sortings', '*1700'] |
D. Palindrome pairstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.In a more formal way, you have to find the quanti... | Inputaa | Output1 | 3 seconds | 256 megabytes | ['*special problem', 'brute force', 'dp', 'strings', '*1500'] |
C. String Manipulation 1.0time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number ... | Input2bac32 a1 b2 c | Outputacb | 3 seconds | 256 megabytes | ['*special problem', 'binary search', 'brute force', 'data structures', 'strings', '*1400'] |
B. Matchmakertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is... | Input3 41 23 42 45 42 41 11 2 | Output3 2 | 3 seconds | 256 megabytes | ['*special problem', 'greedy', 'sortings', '*1100'] |
A. Friends or Nottime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus 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 socia... | Input4 1vasya petya 1petya vasya 2anya ivan 2ivan anya 4 | Output1petya vasya | 3 seconds | 256 megabytes | ['*special problem', 'greedy', 'implementation', '*1400'] |
E. Phone Talkstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCool J has recently become a businessman Mr. Jackson, and he has to make a lot of phone calls now. Today he has n calls planned. For each call we know the moment ti (in seconds since the start of the day)... | Input3 230000 1500040000 1500050000 15000 | Output49999 | 3 seconds | 256 megabytes | ['*special problem', 'dp', 'sortings', '*1900'] |
D. Ice Sculpturestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the camp... | Input81 2 -3 4 -5 5 2 3 | Output14 | 3 seconds | 256 megabytes | ['*special problem', 'brute force', 'number theory', '*1300'] |
C. Cd and pwd commandstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and ... | Input7pwdcd /home/vasyapwdcd ..pwdcd vasya/../petyapwd | Output//home/vasya//home//home/petya/ | 3 seconds | 256 megabytes | ['*special problem', 'data structures', 'implementation', '*1400'] |
B. Taxitime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1ββ€βsiββ€β4), and they want to go to Polyca... | Input51 2 4 3 3 | Output4 | 3 seconds | 256 megabytes | ['*special problem', 'greedy', 'implementation', '*1100'] |
A. Next Roundtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." β an excerpt from contest rules.A... | Input8 510 9 8 7 7 7 5 5 | Output6 | 3 seconds | 256 megabytes | ['*special problem', 'implementation', '*800'] |
B. Tracetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that ... | Input11 | Output3.1415926536 | 2 seconds | 256 megabytes | ['geometry', 'sortings', '*1000'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.