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 |
|---|---|---|---|---|---|
B. Batch Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a table consisting of n rows and m columns.Numbers in each row form a permutation of integers from 1 to m.You are allowed to pick two elements in one row and swap them, but no more than once ... | Input2 41 3 2 41 3 4 2 | OutputYES | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'math', '*1500'] |
A. Checking the Calendartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given names of two days of the week.Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are give... | Inputmondaytuesday | OutputNO | 1 second | 256 megabytes | ['implementation', '*1000'] |
F. st-Spanning Treetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected connected graph consisting of n vertices and m edges. There are no loops and no multiple edges in the graph.You are also given two distinct vertices s and t, and two value... | Input3 31 22 33 11 2 1 1 | OutputYes3 21 3 | 4 seconds | 256 megabytes | ['dsu', 'graphs', 'greedy', 'implementation', '*2300'] |
E. One-Way Reformtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere 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... | Input25 52 14 52 31 33 57 23 74 2 | Output31 33 55 43 22 132 43 7 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'flows', 'graphs', 'greedy', '*2200'] |
D. Lakes in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of wat... | Input5 4 1*****..*******.*..** | Output1*****..*********..** | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'greedy', 'implementation', '*1600'] |
C. Polycarp at the Radiotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Pol... | Input4 21 2 3 2 | Output2 11 2 1 2 | 2 seconds | 256 megabytes | ['greedy', '*1600'] |
B. Text Document Analysistime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputModern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.In this problem you shou... | Input37_Hello_Vasya(and_Petya)__bye_(and_OK) | Output5 4 | 1 second | 256 megabytes | ['expression parsing', 'implementation', 'strings', '*1100'] |
A. The New Year: Meeting Friendstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point... | Input7 1 4 | Output6 | 1 second | 256 megabytes | ['implementation', 'math', 'sortings', '*800'] |
F. Cyclic Ciphertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n sequences. Each sequence consists of positive integers, not exceeding m. All integers in one sequence are distinct, but the same integer may appear in multiple sequences. The length of t... | Input3 43 3 4 14 1 3 4 23 3 1 4 | Output2132 | 2 seconds | 256 megabytes | ['chinese remainder theorem', 'data structures', 'implementation', 'number theory', 'two pointers', '*2800'] |
E. Research Rovertime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUnfortunately, the formal description of the task turned out to be too long, so here is the legend.Research rover finally reached the surface of Mars and is ready to complete its mission. Unfortunate... | Input3 3 2 112 12 3 | Output333333342 | 2.5 seconds | 256 megabytes | ['combinatorics', 'dp', '*2900'] |
D. Generating Setstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a set Y of n distinct positive integers y1, y2, ..., yn.Set X of n distinct positive integers x1, x2, ..., xn is said to generate set Y if one can transform X to Y by applying some numbe... | Input51 2 3 4 5 | Output4 5 2 3 1 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dfs and similar', 'greedy', 'strings', 'trees', '*1900'] |
C. Destroying Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array consisting of n non-negative integers a1, a2, ..., an.You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to n defi... | Input41 3 2 53 4 1 2 | Output5430 | 1 second | 256 megabytes | ['data structures', 'dsu', '*1600'] |
B. Verse Patterntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.We define a syllable as a string that contains exactly one vowel and any... | Input32 2 3intelcodech allenge | OutputYES | 1 second | 256 megabytes | ['implementation', 'strings', '*1200'] |
A. Broken Clocktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both f... | Input2417:30 | Output17:30 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1300'] |
E. Road to Hometime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x = 0 to x... | Input17 2 2 60 913 17 | Output5 | 2 seconds | 256 megabytes | ['binary search', 'dp', '*2700'] |
D. Maxim and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary arra... | Input5 3 15 4 3 5 2 | Output5 4 3 5 -1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'math', '*2000'] |
C. Journeytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently 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 r... | Input4 3 131 2 52 3 72 4 8 | Output31 2 4 | 3 seconds | 256 megabytes | ['dp', 'graphs', '*1800'] |
B. Passwordstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.Vanya will ... | Input5 2cbaabcbb1abCABCabc | Output1 15 | 2 seconds | 256 megabytes | ['implementation', 'math', 'sortings', 'strings', '*1100'] |
A. One-dimensional Japanese Crosswordtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are int... | Input3BBW | Output12 | 1 second | 256 megabytes | ['implementation', '*800'] |
F. Array Coveringtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMisha has an array of integers of length n. He wants to choose k different continuous subarrays, so that each element of the array belongs to at least one of the chosen subarrays.Misha wants to choose ... | Input5 46 -4 -10 -4 7 | Output11 | 3 seconds | 256 megabytes | ['data structures', '*3100'] |
E. Ciphertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBorya has recently found a big electronic display. The computer that manages the display stores some integer number. The number has n decimal digits, the display shows the encoded version of the number, where ... | Input3242abcdefghijjihgfedcba242aaaaaaaaaaaaaaaaaaaa12abcdabcdff | Output0582 | 2 seconds | 256 megabytes | ['implementation', '*3100'] |
D. Slalomtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle girl Masha likes winter sports, today she's planning to take part in slalom skiing.The track is represented as a grid composed of n × m squares. There are rectangular obstacles at the track, composed of... | Input3 3 0 | Output1 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'sortings', '*3100'] |
C. Homeworktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Peter has got an additional homework for tomorrow. The teacher has given three integers to him: n, m and k, and asked him to mark one or more squares on a square grid of size n × m. The marked squares ... | Input33 3 43 3 53 3 3 | Output.*.***.*.**.**.*...*.****.. | 3 seconds | 256 megabytes | ['constructive algorithms', '*3100'] |
B. Cactusophobiatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTree is a connected undirected graph that has no cycles. Edge cactus is a connected undirected graph without loops and parallel edges, such that each edge belongs to at most one cycle.Vasya has an edge ... | Input4 41 2 42 3 13 4 24 2 3 | Output3 | 2 seconds | 256 megabytes | ['dfs and similar', 'flows', '*2400'] |
A. Closing ceremonytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe closing ceremony of Squanch Code Cup is held in the big hall with n × m seats, arranged in n rows, m seats in a row. Each seat has two coordinates (x, y) (1 ≤ x ≤ n, 1 ≤ y ≤ m). There are two que... | Input2 23 3 3 21 3 | OutputYES | 2 seconds | 256 megabytes | ['greedy', '*2000'] |
B. Anatoly and Cockroachestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnatoly 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 a... | Input5rbbrr | Output1 | 1 second | 256 megabytes | ['greedy', '*1400'] |
A. Vitya in the Countrysidetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvery 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 ... | Input53 4 5 6 7 | OutputUP | 1 second | 256 megabytes | ['implementation', '*1100'] |
E. Matvey's Birthdaytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday is Matvey's birthday. He never knows what to ask as a present so friends gave him a string s of length n. This string consists of only first eight English letters: 'a', 'b', ..., 'h'.First que... | Input3abc | Output2 1 | 2 seconds | 256 megabytes | ['bitmasks', 'graphs', '*3300'] |
D. Andrew and Chemistrytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the chemistry lesson Andrew learned that the saturated hydrocarbons (alkanes) enter into radical chlorination reaction. Andrew is a very curious boy, so he wondered how many different prod... | Input41 22 32 4 | Output2 | 2 seconds | 256 megabytes | ['dp', 'hashing', 'trees', '*2900'] |
C. Sasha and Arraytime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r x — increase all integers on the segment from l to r by values x; 2 l r — fi... | Input5 41 1 2 1 12 1 51 2 4 22 2 42 1 5 | Output579 | 5 seconds | 256 megabytes | ['data structures', 'math', 'matrices', '*2300'] |
A. Efim and Strange Gradetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEfim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more p... | Input6 110.245 | Output10.25 | 1 second | 256 megabytes | ['dp', 'implementation', 'math', '*1700'] |
I. Cowboy Beblop at his computertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's n... | Input40 0 02 0 02 2 00 2 041 1 -11 1 11 3 11 3 -1 | OutputYES | 1 second | 256 megabytes | ['geometry', '*2800'] |
H. Pokermon League challengetime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWelcome to the world of Pokermon, yellow little mouse-like creatures, who absolutely love playing poker! Yeah, right… In the ensuing Pokermon League, there are n registered Pokermon trainers... | Input4 31 22 34 1161 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15162 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18162 3 4 5 6 7 8 9 10 11 12 13 14 15 18 19161 2 3 4 5 6 7 8 9 10 11 12 13 14 16 19 | Output16 15 19 14 2 2 2 1 1 1 2 1 1 2 1 1 1 2 2 1 1 1 1 | 5 seconds | 256 megabytes | ['math', 'probabilities', '*2400'] |
G. Underfailtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountere... | Input6abacba2aba 6ba 33 | Output12 | 1 second | 256 megabytes | ['flows', '*2400'] |
F. Heroes of Making Magic IIItime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputI’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of Making Magic, who are casually walking on a one-directional road, fighting imps... | Input32 2 232 0 21 1 1 12 0 2 | Output01 | 3 seconds | 256 megabytes | ['data structures', '*2600'] |
E. Paint it really, really dark graytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputI see a pink boar and I want it painted black. Black boars look much more awesome and mighty than the pink ones. Since Jaggy became the ruler of the forest, he has been trying his bes... | Input511-11-12 54 32 44 1 | Output1 4 2 5 2 4 3 4 1 4 1 | 1 second | 256 megabytes | ['dfs and similar', '*1900'] |
D. Dexterina’s Labtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes in a peaceful and nonvio... | Input2 20.500000 0.250000 0.250000 | Output0.62500000 | 1 second | 256 megabytes | ['games', 'matrices', 'probabilities', '*1900'] |
C. Potions Homeworktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHarry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a l... | Input213 | Output6 | 1 second | 256 megabytes | ['implementation', 'sortings', '*1200'] |
B. R3D3’s Summer Adventuretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputR3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and goin... | Input4 1 2 | Output12 | 1 second | 256 megabytes | ['dp', 'greedy', '*2700'] |
A. Festival Organizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Prodiggers are quite a cool band and for this reason, they have been the surprise guest at the ENTER festival for the past 80 years. At the beginning of their careers, they weren’t so success... | Input1 1 2 | Output5 | 1 second | 256 megabytes | ['combinatorics', 'math', 'number theory', '*2900'] |
B. Complete the Wordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears ... | InputABC??FGHIJK???OPQR?TUVWXY? | OutputABCDEFGHIJKLMNOPQRZTUVWXYS | 2 seconds | 256 megabytes | ['greedy', 'two pointers', '*1300'] |
A. Crazy Computertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS 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 wor... | Input6 51 3 8 14 19 20 | Output3 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Complete the Permutationstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder is given two permutations p and q of {1, 2, ..., n}, but some of their elements are replaced with 0. The distance between two permutations p and q is defined as the minimum numb... | Input31 0 00 2 0 | Output1 2 1 | 5 seconds | 256 megabytes | ['combinatorics', 'fft', 'graphs', 'math', '*3400'] |
D. Create a Mazetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of n × m rooms, and the rooms are arranged in n rows (numbered from the top to the bottom starting from 1... | Input3 | Output3 20 | 2 seconds | 256 megabytes | ['constructive algorithms', '*3100'] |
C. Digit Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder has a large tree. It can be represented as an undirected connected graph of n vertices numbered from 0 to n - 1 and n - 1 edges between them. There is a single nonzero digit written on each ed... | Input6 70 1 24 2 42 0 13 0 92 5 7 | Output7 | 3 seconds | 256 megabytes | ['dfs and similar', 'divide and conquer', 'dsu', 'trees', '*2700'] |
B. Complete The Graphtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder has drawn an undirected graph of n vertices numbered from 0 to n - 1 and m edges between them. Each edge of the graph is weighted, each weight is a positive integer.The next day, ZS th... | Input5 5 13 0 40 1 52 1 23 2 31 4 04 3 4 | OutputYES0 1 52 1 23 2 31 4 84 3 4 | 4 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'graphs', 'shortest paths', '*2300'] |
A. Plus and Square Roottime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS 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 a... | Input3 | Output141646 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*1600'] |
B. Filya and Homeworktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.Filya is given an array of non-negative integers a1, a2... | Input51 3 3 2 1 | OutputYES | 1 second | 256 megabytes | ['implementation', 'sortings', '*1200'] |
A. Meeting of Old Friendstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minut... | Input1 10 9 20 1 | Output2 | 1 second | 256 megabytes | ['implementation', 'math', '*1100'] |
E. Sonya Partymakertime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOwl Sonya decided to become a partymaker. To train for this role she gather all her owl friends in the country house. There are m chairs located in a circle and consequently numbered with integers ... | Input631 3 5 | Output1 | 1.5 seconds | 256 megabytes | ['binary search', 'dp', '*3300'] |
D. Animals and Puzzletime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOwl Sonya gave a huge lake puzzle of size n × m to hedgehog Filya as a birthday present. Friends immediately started to assemble the puzzle, but some parts of it turned out to be empty — there was ... | Input3 41 1 0 10 1 1 00 1 1 051 1 2 32 1 3 23 2 3 41 1 3 41 2 3 4 | Output11122 | 5 seconds | 512 megabytes | ['binary search', 'data structures', '*2700'] |
C. Sonya and Problem Wihtout a Legendtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSonya 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 elem... | Input72 1 5 11 5 9 11 | Output9 | 5 seconds | 256 megabytes | ['dp', 'sortings', '*2300'] |
B. Searching Rectanglestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFilya 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 lef... | Input521011101 | Output? 1 1 5 5? 1 1 3 3? 1 1 3 1? 2 2 2 2? 3 3 5 5? 3 3 3 5? 3 3 3 4? 3 4 3 5! 2 2 2 2 3 4 3 5 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'interactive', '*2200'] |
A. Sonya and Queriestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following typ... | Input12+ 1+ 241? 1+ 361- 241? 0101+ 101? 101- 101? 101+ 4000? 0 | Output21211 | 1 second | 256 megabytes | ['data structures', 'implementation', '*1400'] |
E. Memory and Casinostime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n casinos lined in a row. If Memory plays at casino i, he has probability pi to win and move to the casino on the right (i + 1) or exit the row (if i = n), and a probability 1 - pi to los... | Input3 131 31 22 32 1 12 1 22 1 32 2 22 2 32 3 31 2 2 32 1 12 1 22 1 32 2 22 2 32 3 3 | Output0.33333333330.20000000000.16666666670.50000000000.40000000000.66666666670.33333333330.25000000000.22222222220.66666666670.57142857140.6666666667 | 4 seconds | 512 megabytes | ['data structures', 'math', 'probabilities', '*2500'] |
D. Memory and Scorestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMemory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some in... | Input1 2 2 1 | Output6 | 2 seconds | 512 megabytes | ['combinatorics', 'dp', 'math', '*2200'] |
C. Memory and De-Evolutiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMemory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equil... | Input6 3 | Output4 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1600'] |
B. Memory and Tridenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMemory 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' indic... | InputRRU | Output-1 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1100'] |
A. Memory and Crowtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure: The crow sets ai initially 0. The crow then adds ... | Input56 -4 8 -2 3 | Output2 4 6 1 3 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
E. ZS and The Birthday Paradoxtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share t... | Input3 2 | Output1 8 | 2 seconds | 256 megabytes | ['math', 'number theory', 'probabilities', '*2300'] |
D. Directed Roadstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n. There are n directed roads in the Udayland. i-th of them goes... | Input32 3 1 | Output6 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'graphs', 'math', '*1900'] |
C. Coloring Treestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers f... | Input3 2 20 0 01 23 45 6 | Output10 | 2 seconds | 256 megabytes | ['dp', '*1700'] |
B. Chris and Magic Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris noticed that exactly one of the cells in ... | Input34 0 23 5 78 1 6 | Output9 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*1400'] |
A. Bus to Udaylandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are s... | Input6OO|OXXO|XXOX|OOXX|OXOO|OOOO|XX | OutputYES++|OXXO|XXOX|OOXX|OXOO|OOOO|XX | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*800'] |
F. String Set Queriestime limit per test3 secondsmemory limit per test768 megabytesinputstandard inputoutputstandard outputYou should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. It is guaranteed that the string s was not added before. Delete a string s fro... | Input51 abc3 abcabc2 abc1 aba3 abababc | Output22 | 3 seconds | 768 megabytes | ['brute force', 'data structures', 'hashing', 'interactive', 'string suffix structures', 'strings', '*2400'] |
E. Generate a Stringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputzscoder wants to generate an input file for some programming competition problem.His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate t... | Input8 1 1 | Output4 | 2 seconds | 512 megabytes | ['dfs and similar', 'dp', '*2000'] |
D. Two Arithmetic Progressionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R and x = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0.InputThe only... | Input2 0 3 3 5 21 | Output3 | 1 second | 256 megabytes | ['math', 'number theory', '*2500'] |
C. Magic Odd Squaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFind an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.InputThe only line contains odd integer n (1 ≤ n ≤ 49).OutputPrint n lines with... | Input1 | Output1 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1500'] |
B. Optimal Point on a Linetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.InputThe first line contains integer n (1 ≤ n ≤ 3·105) — the ... | Input41 2 3 4 | Output2 | 1 second | 256 megabytes | ['brute force', 'sortings', '*1400'] |
A. King Movestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for th... | Inpute4 | Output8 | 1 second | 256 megabytes | ['implementation', '*800'] |
B. Checkpointstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x1, x2, ..., xn. Vasya starts at the point with coordinate a. His goal is to visit at least n... | Input3 101 7 12 | Output7 | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*1500'] |
A. Juicertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To ... | Input2 7 105 6 | Output1 | 1 second | 256 megabytes | ['implementation', '*900'] |
E. Student's Camptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex studied well and won the trip to student camp Alushta, located on the seashore. Unfortunately, it's the period of the strong winds now and there is a chance the camp will be destroyed! Camp buildi... | Input2 21 21 | Output937500007 | 3 seconds | 256 megabytes | ['dp', 'math', '*3100'] |
D. Incorrect Flowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAt 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... | Input2 11 2 2 1 | Output0 | 1 second | 256 megabytes | ['flows', '*2900'] |
C. Centroidstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTree is a connected acyclic graph. Suppose you are given a tree consisting of n vertices. The vertex of this tree is called centroid if the size of each connected component that appears if this vertex is re... | Input31 22 3 | Output1 1 1 | 4 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'dp', 'graphs', 'greedy', 'trees', '*2300'] |
B. Recover the Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is the number of subsequences of length 2 of the string s equal to the sequence {... | Input1 2 3 4 | OutputImpossible | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*1900'] |
A. Letters Cyclic Shifttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other w... | Inputcodeforces | Outputbncdenqbdr | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'strings', '*1200'] |
E. Garlandstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLike all children, Alesha loves New Year celebration. During the celebration he and his whole family dress up the fir-tree. Like all children, Alesha likes to play with garlands — chains consisting of a ligh... | Input4 4 351 1 21 2 32 2 12 1 43 1 741 3 12 3 32 4 31 4 174 1 14 2 93 2 83 3 34 3 44 4 13 4 12ASK 2 2 3 3ASK 1 1 4 4 | Output1552 | 3 seconds | 256 megabytes | ['data structures', '*2400'] |
D. Persistent Bookcase time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently in school Alina has learned what are the persistent data structures: they are data structures that always preserves the previous version of itself and access to it when it is modified.Af... | Input2 3 31 1 13 24 0 | Output140 | 2 seconds | 512 megabytes | ['bitmasks', 'data structures', 'dfs and similar', 'implementation', '*2200'] |
C. Pythagorean Triplestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKatya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right ... | Input3 | Output4 5 | 1 second | 256 megabytes | ['math', 'number theory', '*1500'] |
B. Bakerytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMasha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.To bake muffins in her bakery, Masha... | Input5 4 21 2 51 2 32 3 41 4 101 5 | Output3 | 2 seconds | 256 megabytes | ['graphs', '*1300'] |
A. Brain's Photostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmall, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.As ... | Input2 2C MY Y | Output#Color | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Working routinetime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy finally got to work, where there is a huge amount of tasks waiting for him. Vasiliy is given a matrix consisting of n rows and m columns and q tasks. Each task is to swap two submatrices of ... | Input4 4 21 1 2 21 1 2 23 3 4 43 3 4 41 1 3 3 2 23 1 1 3 2 2 | Output4 4 3 34 4 3 32 2 1 12 2 1 1 | 2.5 seconds | 256 megabytes | ['data structures', 'implementation', '*2500'] |
D. Vasiliy's Multisettime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAuthor has gone out of the stories about Vasiliy, so here is just a formal task description.You are given q queries and a multiset A, initially containing only integer 0. There are three types of q... | Input10+ 8+ 9+ 11+ 6+ 1? 3- 8? 3? 8? 11 | Output11101413 | 4 seconds | 256 megabytes | ['binary search', 'bitmasks', 'data structures', 'trees', '*1800'] |
C. Hard problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help.Vasiliy is given n strings consisting of lowercase English letters. He wants them to ... | Input21 2baac | Output1 | 1 second | 256 megabytes | ['dp', 'strings', '*1600'] |
B. Interesting drinktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the cit... | Input53 10 8 6 114110311 | Output0415 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'implementation', '*1100'] |
A. Beru-taxitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is loca... | Input0 022 0 10 2 2 | Output1.00000000000000000000 | 1 second | 256 megabytes | ['brute force', 'geometry', 'implementation', '*900'] |
B. Spider Mantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, wh... | Input31 2 3 | Output211 | 2 seconds | 256 megabytes | ['games', 'math', '*1100'] |
A. Hulktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.Hulk likes the Incept... | Input1 | OutputI hate it | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Iron Mantime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTony Stark is playing a game with his suits (they have auto-pilot now). He lives in Malibu. Malibu has n junctions numbered from 1 to n, connected with n - 1 roads. One can get from a junction to any other j... | Input6 42 56 53 64 64 127 6 1 39 5 1 627 4 3 411 29 2 6 | Output27.3 | 5 seconds | 256 megabytes | ['data structures', 'geometry', 'trees', '*3300'] |
D. Captain Americatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSteve Rogers is fascinated with new vibranium shields S.H.I.E.L.D gave him. They're all uncolored. There are n shields in total, the i-th shield is located at point (xi, yi) of the coordinate plane. I... | Input5 68 32 101 59 109 102 81 9 11 2 12 10 32 10 21 1 12 5 2 | Output25rbrbb | 2 seconds | 256 megabytes | ['flows', 'greedy', '*3100'] |
C. Black Widowtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNatalia Romanova is trying to test something on the new gun S.H.I.E.L.D gave her. In order to determine the result of the test, she needs to find the number of answers to a certain equation. The equation ... | Input6 72 4 -22 6 32 -7 12 -5 12 3 62 -2 -5 | Output48 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'implementation', 'math', '*2900'] |
B. Ant Mantime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputScott Lang is at war with Darren Cross. There are n chairs in a hall where they are, numbered with 1, 2, ..., n from left to right. The i-th chair is located at coordinate xi. Scott is on chair number s and C... | Input7 4 38 11 12 16 17 18 2017 16 20 2 20 5 1317 8 8 16 12 15 1312 4 16 4 15 7 68 14 2 11 17 12 8 | Output139 | 4 seconds | 256 megabytes | ['dp', 'graphs', 'greedy', '*2500'] |
A. Thortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread... | Input3 41 31 11 22 3 | Output1232 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'implementation', '*1600'] |
E. Mishka and Divisorstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter playing with her beautiful array, Mishka decided to learn some math. After learning how to multiply, divide and what is divisibility, she is now interested in solving the following problem.Yo... | Input5 602 4 6 5 2 | Output34 3 1 | 1 second | 256 megabytes | ['dp', 'number theory', '*2600'] |
D. Mishka and Interesting sumtime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with array of non-negative integers a1, a2, ..., an of n elements!Mishka loved the... | Input33 7 811 3 | Output0 | 3.5 seconds | 256 megabytes | ['data structures', '*2100'] |
C. Chris and Roadtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnd while Mishka is enjoying her trip...Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best frien... | Input5 5 1 21 23 14 33 41 4 | Output5.0000000000 | 2 seconds | 256 megabytes | ['geometry', 'implementation', '*2100'] |
B. Mishka and triptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.Here are some interesting... | Input4 12 3 1 23 | Output17 | 1 second | 256 megabytes | ['implementation', 'math', '*1400'] |
A. Mishka and Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend ... | Input33 52 14 2 | OutputMishka | 1 second | 256 megabytes | ['implementation', '*800'] |
F. T-Shirtstime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThe big consignment of t-shirts goes on sale in the shop before the beginning of the spring. In all n types of t-shirts go on sale. The t-shirt of the i-th type has two integer parameters — ci and qi, where... | Input37 53 54 3213 14 | Output2 3 | 4 seconds | 1024 megabytes | ['data structures', '*2800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.