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 |
|---|---|---|---|---|---|
D. Boxes And Ballstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan has n different boxes. The first of them contains some balls of n different colors.Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every i (1... | Input31 2 3 | Output6 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2300'] |
C. Bertown Subwaytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.There are n stations in the subway. It was built according ... | Input32 1 3 | Output9 | 1 second | 256 megabytes | ['dfs and similar', 'greedy', 'math', '*1500'] |
B. Japanese Crosswords Strike Backtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed c... | Input2 41 3 | OutputNO | 1 second | 256 megabytes | ['implementation', '*1100'] |
A. Book Readingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wants to finish reading as fast as she can.But she has some work to do in each of n next days. T... | Input2 286400 86398 | Output2 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
M. Quadcopter Competitiontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp takes part in a quadcopter competition. According to the rules a flying robot should: start the race from some point of a field, go around the flag, close cycle returning back to th... | Input1 55 2 | Output18 | 3 seconds | 256 megabytes | ['greedy', 'math', '*1100'] |
L. Berland.Taxitime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland.Taxi is a new taxi company with k cars which started operating in the capital of Berland just recently. The capital has n houses on a straight line numbered from 1 (leftmost) to n (rightmost), an... | Input10 1 235 2 89 10 3 | Output1 11 5 | 3 seconds | 256 megabytes | ['data structures', '*2500'] |
K. Road Wideningtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!The Mayor thinks that one of the main city streets could be considerably widened on... | Input34 54 54 10 | Output169 9 10 | 3 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*1800'] |
J. Renovationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe mayor of the Berland city S sees the beauty differently than other city-dwellers. In particular, he does not understand at all, how antique houses can be nice-looking. So the mayor wants to demolish al... | Input2 32 46 2 31 3 2 | Output2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*2400'] |
I. Photo Processingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvlampiy has found one more cool application to process photos. However the application has certain limitations.Each photo i has a contrast vi. In order for the processing to be truly of high quality... | Input5 250 110 130 40 120 | Output20 | 3 seconds | 256 megabytes | ['binary search', 'dp', '*1900'] |
H. Palindromic Cuttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is ... | Input6aabaac | Output2aba aca | 3 seconds | 256 megabytes | ['brute force', 'implementation', 'strings', '*1800'] |
G. Orientation of Edgestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a graph containing both directed (oriented) and undirected (non-oriented) edges. There can be multiple edges between a pair of vertices.Vasya has picked a vertex s from the graph. Now V... | Input2 2 11 1 22 2 1 | Output2-2+ | 3 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*1900'] |
F. Lost in Transliterationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are some ambiguities when one writes Berland names with the letters of the Latin alphabet.For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written... | Input10mihailoolyanakooooperhoonulyanakooupermikhailkhunkuooperkkkhoon | Output4 | 3 seconds | 256 megabytes | ['implementation', '*1300'] |
E. Field of Wonderstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus takes part in the "Field of Wonders" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden.The game consis... | Input4a**d2abcdacbd | Output2 | 3 seconds | 256 megabytes | ['implementation', 'strings', '*1500'] |
D. Packmen Strike Backtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGame field is represented by a line of n square cells. In some cells there are packmen, in some cells there are asterisks and the rest of the cells are empty. Packmen eat asterisks.Before the game... | Input6*.P*P* | Output3 4 | 3 seconds | 256 megabytes | ['binary search', 'dp', 'math', '*2500'] |
C. Downloading B++time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnly T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f ... | Input120 964 2026 8 813 10 4 | Output40 | 3 seconds | 256 megabytes | ['binary search', 'implementation', '*2300'] |
B. Berland Armytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n military men in the Berland army. Some of them have given orders to other military men by now. Given m pairs (xi, yi), meaning that the military man xi gave the i-th order to another military... | Input5 3 30 3 0 0 22 43 43 5 | Output1 3 3 2 2 | 3 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', '*2600'] |
A. Automatic Doortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and ... | Input1 1 3 47 | Output1 | 1 second | 256 megabytes | ['implementation', '*2200'] |
B. Table Tennistime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from t... | Input2 21 2 | Output2 | 2 seconds | 256 megabytes | ['data structures', 'implementation', '*1200'] |
A. Borya's Diagnosistime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in... | Input32 21 22 2 | Output4 | 2 seconds | 256 megabytes | ['implementation', '*900'] |
E. Numbers on the blackboardtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA sequence of n integers is written on a blackboard. Soon Sasha will come to the blackboard and start the following actions: let x and y be two adjacent numbers (x before y), then he can rem... | Input3 31 2 31 31 22 3 | Output1758 | 2 seconds | 512 megabytes | ['combinatorics', 'dp', '*3300'] |
D. Magic Breedingtime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputNikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have k creatures numbered from 1 to k. Creatures have n different characteristics.Sasha has a spel... | Input2 2 41 22 11 1 22 1 23 3 13 4 2 | Output21 | 4 seconds | 1024 megabytes | ['bitmasks', '*2900'] |
C. Tournamenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently a tournament in k kinds of sports has begun in Berland. Vasya wants to make money on the bets.The scheme of the tournament is very mysterious and not fully disclosed. Competitions are held back to... | Input3 21 55 110 10 | Output121 | 2 seconds | 256 megabytes | ['data structures', 'graphs', '*2700'] |
B. Teams Formationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the ... | Input4 2 51 2 3 1 | Output12 | 2 seconds | 256 megabytes | ['data structures', 'implementation', '*2300'] |
A. Short Programtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.In the language, there are only three comma... | Input3| 3^ 2| 1 | Output2| 3^ 2 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', '*1600'] |
F. Ann and Bookstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n. Each of them contains non-negative number of problems.Today there is a sale: any subsegment of a... | Input4 11 1 1 21 1 1 141 21 31 43 4 | Output2341 | 2 seconds | 256 megabytes | ['data structures', 'flows', 'hashing', '*2300'] |
E. Danil and a Part-time Jobtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDanil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.Danil works in a rooted tree (undirected connected acyclic grap... | Input41 1 11 0 0 19get 1get 2get 3get 4pow 1get 1get 2get 3get 4 | Output20012110 | 2 seconds | 256 megabytes | ['bitmasks', 'data structures', 'trees', '*2000'] |
D. Olya and Energy Drinkstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks.Formally, her room can be represented as a field of n × m cells, each cell of which is em... | Input3 4 4....###.....1 1 3 1 | Output3 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'shortest paths', '*2100'] |
C. Slava and tankstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSlava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each... | Input2 | Output32 1 2 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1600'] |
B. Nikita and stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters... | Inputabba | Output4 | 2 seconds | 256 megabytes | ['brute force', 'dp', '*1500'] |
A. Alex and broken contesttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.But there are t... | InputAlex_and_broken_contest | OutputNO | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1100'] |
B. Divisiblity of Differencestime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible.Numbers... | Input3 2 31 8 4 | OutputYes1 4 | 1 second | 512 megabytes | ['implementation', 'math', 'number theory', '*1300'] |
A. Trip For Mealtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputWinnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths... | Input3231 | Output3 | 1 second | 512 megabytes | ['math', '*900'] |
F. Royal Questionstime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn a medieval kingdom, the economic crisis is raging. Milk drops fall, Economic indicators are deteriorating every day, money from the treasury disappear. To remedy the situation, King Charles Sunny... | Input2 31 2 51 2 12 1 10 | Output15 | 1.5 seconds | 512 megabytes | ['dsu', 'graphs', 'greedy', '*2500'] |
E. Delivery Clubtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPetya and Vasya got employed as couriers. During the working day they are to deliver packages to n different points on the line. According to the company's internal rules, the delivery of packages must ... | Input2 0 105 6 | Output10 | 2 seconds | 512 megabytes | ['binary search', 'data structures', 'dp', '*2600'] |
D. High Crytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputDisclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)Rick and Morty like to go to the ridge High Cry for crying lo... | Input53 2 1 6 5 | Output8 | 1 second | 512 megabytes | ['binary search', 'bitmasks', 'combinatorics', 'data structures', 'divide and conquer', '*2200'] |
C. National Propertytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library.Some long and uninteresting story was removed...The alphabet of Bo... | Input4 31 21 13 1 3 22 1 1 | OutputYes22 3 | 1 second | 512 megabytes | ['2-sat', 'dfs and similar', 'graphs', 'implementation', '*2100'] |
B. Sorting the Coinstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, ... | Input41 3 4 2 | Output1 2 3 2 1 | 1 second | 512 megabytes | ['dsu', 'implementation', 'sortings', 'two pointers', '*1500'] |
A. Classroom Watchtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputEighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inn... | Input21 | Output115 | 1 second | 512 megabytes | ['brute force', 'math', '*1200'] |
F. Forbidden Indicestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of n lowercase Latin letters. Some indices in this string are marked as forbidden.You want to find a string a such that the value of |a|·f(a) is maximum possible,... | Input5ababa00100 | Output5 | 2 seconds | 256 megabytes | ['dsu', 'string suffix structures', 'strings', '*2400'] |
E. Awards For Contestantstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlexey recently held a programming contest for students from Berland. n students participated in a contest, i-th of them solved ai problems. Now he wants to award some contestants. Alexey can aw... | Input41 2 3 4 | Output3 3 2 1 | 1 second | 256 megabytes | ['brute force', 'data structures', 'dp', '*2300'] |
D. Merge Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMerge sort is a well-known sorting algorithm. The main function that sorts the elements of array a with indices from [l, r) can be implemented as follows: If the segment [l, r) is already sorted in non-de... | Input3 3 | Output2 1 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'divide and conquer', '*1800'] |
C. Strange Game On Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan is playing a strange game.He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of o... | Input4 3 20 1 01 0 10 1 01 1 1 | Output4 1 | 1 second | 256 megabytes | ['greedy', 'two pointers', '*1600'] |
B. Balanced Substringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting only of characters 0 and 1. A substring [l, r] of s is a string slsl + 1sl + 2... sr, and its length equals to r - l + 1. A substring is called balanced if the nu... | Input811010111 | Output4 | 1 second | 256 megabytes | ['dp', 'implementation', '*1500'] |
A. Chorestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every the condition ai ≥ ai - 1 is met, so the sequence is sorted.Also Luba can work really hard on some... | Input4 2 23 6 7 10 | Output13 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Restore the Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya had a tree consisting of n vertices numbered with integers from 1 to n. Accidentally he lost his tree. Petya remembers information about k vertices: distances from each of them to each of the n... | Input5 20 1 2 3 22 1 0 1 2 | Output2 13 24 35 2 | 3 seconds | 256 megabytes | ['graphs', 'greedy', 'trees', '*2900'] |
F. Pathstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Let's build a graph on vertices 1, 2, ..., n in such a way that there is an edge between vertices u and v if and only if . Let d(u, v) be the shortest distance between u and ... | Input6 | Output8 | 4 seconds | 512 megabytes | ['data structures', 'number theory', '*2700'] |
E. Points, Lines and Ready-made Titlestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothin... | Input41 11 22 12 2 | Output16 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'trees', '*2300'] |
D. Something with XOR Queriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Jury has hidden a permutation p of integers from 0 to n - 1. You know only the length n. Remind that in permutation all integers are distinct.Let b be the inv... | Input3003232 | Output? 0 0? 1 1? 1 2? 0 2? 2 1? 2 0!10 1 2 | 2 seconds | 256 megabytes | ['brute force', 'interactive', 'probabilities', '*2000'] |
C. Maximum splittingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum ... | Input112 | Output3 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'math', 'number theory', '*1300'] |
B. Maximum of Maximums of Minimumstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum inte... | Input5 21 2 3 4 5 | Output5 | 1 second | 256 megabytes | ['greedy', '*1200'] |
A. Search for Pretty Integerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two lists of non-zero digits.Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list... | Input2 34 25 7 6 | Output25 | 1 second | 256 megabytes | ['brute force', 'implementation', '*900'] |
E. The Untended Antiquitytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAdieu l'ami.Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around the abandoned Eikou Cram School building, Oshino's makeshift residence.The space is represente... | Input5 6 51 2 2 4 51 3 3 3 33 4 4 1 12 2 2 4 53 1 1 4 4 | OutputNoYes | 2 seconds | 512 megabytes | ['data structures', 'hashing', '*2400'] |
D. The Overdosing Ubiquitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor.The Cinderswarm Bee. Koyomi knows it.The bees, according to their nature... | Input3 0 | Output9 | 1 second | 256 megabytes | ['brute force', 'dfs and similar', 'graphs', '*2800'] |
C. The Intriguing Obsessiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output— This is not playing but duty as allies of justice, Nii-chan!— Not allies but justice itself, Onii-chan!With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fi... | Input1 1 1 | Output8 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'math', '*1800'] |
B. The Eternal Immortalitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEven if the world is full of counterfeits, I still regard it as wonderful.Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoe... | Input2 4 | Output2 | 1 second | 256 megabytes | ['math', '*1100'] |
A. The Artful Expedienttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRock... Paper!After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.... | Input31 2 34 5 6 | OutputKaren | 1 second | 256 megabytes | ['brute force', 'implementation', '*1100'] |
G. El Toll Cavestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe prehistoric caves of El Toll are located in Moià (Barcelona). You have heard that there is a treasure hidden in one of n possible spots in the caves. You assume that each of the spots has probabilit... | Input31 12 13 2 | Output2500000007777777786 | 2 seconds | 256 megabytes | ['math', '*3300'] |
F. Yet Another Minimization Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n integers a1... an. The cost of a subsegment is the number of unordered pairs of distinct indices within the subsegment that contain equal elements. Split t... | Input7 31 1 3 3 3 2 1 | Output1 | 2 seconds | 256 megabytes | ['divide and conquer', 'dp', '*2500'] |
E. Policeman and a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree (a connected non-oriented graph without cycles) with vertices numbered from 1 to n, and the length of the i-th edge is wi. In the vertex s there is a policeman, in the vertic... | Input41 2 21 3 11 4 1243 1 4 1 | Output8 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'trees', '*2700'] |
D. Huge Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concat... | Input5011010111111031 26 54 4 | Output120 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'implementation', 'strings', '*2200'] |
C. Qualification Roundstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSnark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it ... | Input5 31 0 11 1 01 0 01 0 01 0 0 | OutputNO | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dp', '*1500'] |
B. Race Against Timetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he fac... | Input12 30 45 3 11 | OutputNO | 2 seconds | 256 megabytes | ['implementation', '*1400'] |
A. Bark to Unlocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone... | Inputya4ahoytoha | OutputYES | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'strings', '*900'] |
A. Between the Officestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.You prefer flying from Seat... | Input4FSSF | OutputNO | 2 seconds | 256 megabytes | ['implementation', '*800'] |
G. Flowers and Chocolatetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's Piegirl's birthday soon, and Pieguy has decided to buy her a bouquet of flowers and a basket of chocolates.The flower shop has F different types of flowers available. The i-th type of flowe... | Input2 3 33 510 3 7 | Output17 | 2 seconds | 256 megabytes | ['combinatorics', 'math', 'matrices', '*3300'] |
F. Egg Roulettetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe game of Egg Roulette is played between two players. Initially 2R raw eggs and 2C cooked eggs are placed randomly into a carton. The shells are left on so there is no way to distinguish a raw egg from... | Input1 1??BB | Output0 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'divide and conquer', 'math', 'meet-in-the-middle', '*3300'] |
E. Hex Dyslexiatime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCopying large hexadecimal (base 16) strings by hand can be error prone, but that doesn't stop people from doing it. You've discovered a bug in the code that was likely caused by someone making a mistake ... | Inputf1e | OutputNO | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'graphs', '*3300'] |
D. Buy Low Sell Hightime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you wi... | Input910 5 4 7 9 12 6 2 10 | Output20 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*2400'] |
C. Gotta Go Fasttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're trying to set the record on your favorite video game. The game consists of N levels, which must be completed sequentially in order to beat the game. You usually complete each level as fast as pos... | Input1 82 8 81 | Output3.14 | 2 seconds | 256 megabytes | ['binary search', 'dp', '*2400'] |
B. Ordering Pizzatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), a... | Input3 123 5 74 6 75 9 5 | Output84 | 2 seconds | 256 megabytes | ['binary search', 'sortings', 'ternary search', '*1900'] |
A. Save the problem!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAttention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case t... | Input18 | Output30 41 5 10 25 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1400'] |
F. Cities Excursionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads that connect a city to itself... | Input7 7 51 22 31 33 44 55 34 61 4 22 6 11 7 31 3 21 3 5 | Output2-1-12-1 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'trees', '*2700'] |
E. Firetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take ti seconds to save i-th item. In addition, for each item, he estimat... | Input33 7 42 6 53 7 6 | Output1122 3 | 2 seconds | 256 megabytes | ['dp', 'sortings', '*2000'] |
D. Make a Permutation!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan has an array consisting of n elements. Each of the elements is an integer from 1 to n.Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace... | Input43 2 2 3 | Output21 2 4 3 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', '*1500'] |
C. Bustime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After r... | Input6 9 2 4 | Output4 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', '*1500'] |
B. Polycarp and Letterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.Let A be a set of positions in the string. Let's call... | Input11aaaaBaabAbA | Output2 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'strings', '*1000'] |
A. Fair Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card.Before the game Petya will choose an integer and after that Vasya will choose another... | Input411272711 | OutputYES11 27 | 1 second | 256 megabytes | ['implementation', 'sortings', '*1000'] |
G. Graphic Settingstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Ivan bought a new computer. Excited, he unpacked it and installed his favourite game. With his old computer Ivan had to choose the worst possible graphic settings (because otherwise the fram... | Input131 | OutputPathinc 1inc 1 | 2 seconds | 256 megabytes | ['*3200'] |
F. Almost Permutationtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently Ivan noticed an array a while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might he... | Input3 0 | Output3 | 3 seconds | 512 megabytes | ['flows', '*2200'] |
E. Turn Off The TVtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuba needs your help again! Luba has n TV sets. She knows that i-th TV set will be working from moment of time li till moment ri, inclusive.Luba wants to switch off one of TV sets in order to free the... | Input31 34 61 7 | Output1 | 2 seconds | 256 megabytes | ['data structures', 'sortings', '*2000'] |
D. Yet Another Array Queries Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of size n, and q queries to it. There are queries of two types: 1 li ri — perform a cyclic shift of the segment [li, ri] to the right. That is, for every x... | Input6 3 51 2 3 4 5 62 1 32 3 61 1 62 2 1 5 3 | Output3 3 1 5 2 | 2 seconds | 256 megabytes | ['data structures', 'implementation', '*1800'] |
C. 1-2-3time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far... | Input10 2 11 1 11 1 11 1 12 2 22 2 22 2 2 | Output1 9 | 1 second | 256 megabytes | ['graphs', 'implementation', '*1800'] |
B. Kayakingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.Now the party is ready to start its journey, but... | Input21 2 3 4 | Output1 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'sortings', '*1500'] |
A. Quasi-palindrometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right... | Input131 | OutputYES | 1 second | 256 megabytes | ['brute force', 'implementation', '*900'] |
F. Mahmoud and Ehab and the final stagetime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMahmoud and Ehab solved Dr. Evil's questions so he gave them the password of the door of the evil land. When they tried to open the door using it, the door gave them a final quest... | Input5 9mahmoud mahmoudbadawy drmahmoud drevil mahmoud1 1 51 1 21 2 32 3 mahmoud2 4 mahmoud2 2 mahmouu1 1 51 2 31 1 1 | Output14141330127 | 5 seconds | 512 megabytes | ['data structures', 'strings', '*2900'] |
E. Mahmoud and Ehab and the functiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array a of length n and array b of length m. He introduced a function f(j) which is defined for integers j, ... | Input5 6 31 2 3 4 51 2 3 4 5 61 1 101 1 -91 5 -1 | Output0900 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'sortings', '*2100'] |
D. Mahmoud and Ehab and the binary stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud and Ehab are in the fourth stage now.Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in ... | Input3213210 | Output? 000? 001? 010? 011? 100? 101! 2 1 | 2 seconds | 256 megabytes | ['binary search', 'divide and conquer', 'interactive', '*2000'] |
C. Mahmoud and Ehab and the xortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won't show them any set from his large collection, but will ask them to cre... | Input5 5 | OutputYES1 2 4 5 7 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1900'] |
B. Mahmoud and Ehab and the bipartitenesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.A tree is a connected acyclic graph. A biparti... | Input31 21 3 | Output0 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'trees', '*1300'] |
A. Mahmoud and Ehab and the MEXtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.Dr. Evil ... | Input5 30 4 5 6 7 | Output2 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1000'] |
E. Arkady and a Nobody-mentime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkady words in a large company. There are n employees working in a system of a strict hierarchy. Namely, each employee, with an exception of the CEO, has exactly one immediate manager. The CE... | Input40 1 2 1 | Output0 2 4 2 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*2700'] |
G. Circle of Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number k. Then you may repeatedly select a set of 2 or more po... | Input30000100000100000110000000001100 | OutputYES | 1 second | 256 megabytes | ['math', '*3000'] |
F. Ordering T-Shirtstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's another Start[c]up, and that means there are T-shirts to order. In order to make sure T-shirts are shipped as soon as possible, we've decided that this year we're going to order all of the nece... | Input2 200100 250 100 | Output200 | 2 seconds | 256 megabytes | ['greedy', '*2800'] |
E. Desk Disordertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new set of desks just arrived, and it's about time! Things were getting quite cramped in the office. You've been put in charge of creating a new seating chart for the engineers. The desks are numbered... | Input41 55 23 77 3 | Output6 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'dsu', 'graphs', 'trees', '*2100'] |
D. Third Month Insanitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, number... | Input20 40 100 10060 0 40 400 60 0 450 60 55 0 | Output1.75 | 2 seconds | 256 megabytes | ['dp', 'probabilities', 'trees', '*2100'] |
C. Pie Rulestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice.... | Input3141 592 653 | Output653 733 | 2 seconds | 256 megabytes | ['dp', 'games', '*1500'] |
B. Lazy Security Guardtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose whic... | Input4 | Output8 | 2 seconds | 256 megabytes | ['brute force', 'geometry', 'math', '*1000'] |
A. Declined Finaliststime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete ons... | Input252 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28 | Output3 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*800'] |
F. Wizard's Tourtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAll Berland residents are waiting for an unprecedented tour of wizard in his Blue Helicopter over the cities of Berland!It is well-known that there are n cities in Berland, some pairs of which are conne... | Input4 51 23 22 43 44 1 | Output21 4 24 3 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2300'] |
E. Tests Renumerationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.Unfortunately, the archive with ... | Input501 02 12extra 03 199 0 | Output4move 3 1move 01 5move 2extra 4move 99 3 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*2200'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.