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 |
|---|---|---|---|---|---|
E. Analysis of Pathes in Functional Graphtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.Graph is given as the array ... | Input7 31 2 3 4 3 2 66 3 1 4 2 2 3 | Output10 18 17 110 28 27 19 3 | 2 seconds | 512 megabytes | ['data structures', 'graphs', '*2100'] |
D. Road to Post Officetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.Vasiliy's car is not new — it breaks after driven every k kilometers a... | Input5 2 1 4 10 | Output14 | 1 second | 256 megabytes | ['math', '*1900'] |
C. Cellular Networktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the ... | Input3 2-2 2 4-3 0 | Output4 | 3 seconds | 256 megabytes | ['binary search', 'implementation', 'two pointers', '*1500'] |
B. Powers of Twotime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer x exists so that ai + aj = 2x).InputThe first line contains th... | Input47 3 2 1 | Output2 | 3 seconds | 256 megabytes | ['brute force', 'data structures', 'implementation', 'math', '*1500'] |
A. Maximum Increasetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.A subarray is the sequence of consecutive elements of the array. Suba... | Input51 7 2 11 15 | Output3 | 1 second | 256 megabytes | ['dp', 'greedy', 'implementation', '*800'] |
C. They Are Everywheretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to ... | Input3AaA | Output2 | 2 seconds | 256 megabytes | ['binary search', 'strings', 'two pointers', '*1500'] |
B. Cells Not Under Attacktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another.The cell of the field is under... | Input3 31 13 12 2 | Output4 2 0 | 2 seconds | 256 megabytes | ['data structures', 'math', '*1200'] |
A. Cardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exa... | Input61 5 7 4 4 3 | Output1 36 24 5 | 1 second | 256 megabytes | ['greedy', 'implementation', '*800'] |
E. Cool Sloganstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBomboslav set up a branding agency and now helps companies to create new logos and advertising slogans. In term of this problems, slogan of the company should be a non-empty substring of its name. For ex... | Input3abc | Output1 | 4 seconds | 512 megabytes | ['string suffix structures', 'strings', '*3300'] |
D. Huffman Coding on Segmenttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice wants to send an important message to Bob. Message a = (a1, ..., an) is a sequence of positive integers (characters).To compress the message Alice wants to use binary Huffman coding. W... | Input71 2 1 3 1 2 151 71 33 52 44 4 | Output103350 | 4 seconds | 256 megabytes | ['data structures', 'greedy', '*3100'] |
C. Break Uptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAgain, there are hard times in Berland! Many towns have such tensions that even civil war is possible. There are n towns in Reberland, some pairs of which connected by two-way roads. It is not guaranteed tha... | Input6 71 62 1 62 3 53 4 94 6 44 6 54 5 13 1 3 | Output822 7 | 3 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*2600'] |
B. Connecting Universitiestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTreeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town. In Treeland there are 2k universities which are... | Input7 21 5 6 21 33 24 53 74 34 6 | Output6 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*1800'] |
A. As Fast As Possibletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to t... | Input5 10 1 2 5 | Output5.0000000000 | 1 second | 256 megabytes | ['binary search', 'math', '*1900'] |
B. One Bombtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb... | Input3 4.*.......*.. | OutputYES1 2 | 1 second | 256 megabytes | ['implementation', '*1400'] |
A. Launch of Collidertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and... | Input4RLRL2 4 6 10 | Output1 | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
F. Coprime Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo positive integers are coprime if and only if they don't have a common divisor greater than 1.Some bear doesn't want to tell Radewoosh how to solve some algorithmic problem. So, Radewoosh is go... | Input40 0 0 0 | Output4 | 2 seconds | 256 megabytes | ['combinatorics', 'number theory', '*3000'] |
E. Crontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSometime the classic solution are not powerful enough and we have to design our own. For the purpose of this problem you have to implement the part of the system of task scheduling.Each task should be executed a... | Input-1 59 23 -1 -1 -16146737265814674175401467417541146741759814674175991467417600 | Output146741754014674175411467417542146741759914675039401467503940 | 3 seconds | 256 megabytes | ['*2800'] |
D. Limak and Shooting Pointstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBearland is a dangerous place. Limak can’t travel on foot. Instead, he has k magic teleportation stones. Each stone can be used at most once. The i-th stone allows to teleport to a point (ax... | Input2 4-2 -14 54 22 14 -11 -1 | Output3 | 3 seconds | 256 megabytes | ['brute force', 'geometry', 'math', '*2600'] |
C. LRUtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular caching algorithms called LRU (Least Recently Used).Suppose the cache may store... | Input3 10.3 0.2 0.5 | Output0.3 0.2 0.5 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', 'math', 'probabilities', '*2400'] |
B. Fix a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is an undirected connected graph without cycles.Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tree. One way is to create an a... | Input42 3 3 4 | Output12 3 4 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'trees', '*1700'] |
A. Vacationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried ... | Input41 3 2 0 | Output2 | 1 second | 256 megabytes | ['dp', '*1400'] |
B. Barnicletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. Barney asked the ba... | Input8.549e2 | Output854.9 | 1 second | 256 megabytes | ['brute force', 'implementation', 'math', 'strings', '*1400'] |
A. Pineapple Incidenttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTed has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it ... | Input3 10 4 | OutputNO | 1 second | 256 megabytes | ['implementation', 'math', '*900'] |
F. ...Dary!time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney has finally found the one, a beautiful young lady named Lyanna. The problem is, Lyanna and Barney are trapped in Lord Loss' castle. This castle has shape of a convex polygon of n points. Like most of ... | Input4-41 67-16 2025 25-36 85 | Output0-16 20-36 85 | 3 seconds | 256 megabytes | ['binary search', 'geometry', 'two pointers', '*3300'] |
E. ...Wait for it...time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney is searching for his dream girl. He lives in NYC. NYC has n junctions numbered from 1 to n and n - 1 roads connecting them. We will consider the NYC as a rooted tree with root being junction ... | Input5 7 113 52 34 31 44 1 4 5 4 1 42 4 31 2 1 21 4 2 12 2 102 1 101 2 4 11 2 3 42 5 22 4 91 3 5 21 1 2 3 | Output2 2 1 1 3 1 5 0 1 4 2 6 7 | 3 seconds | 256 megabytes | ['data structures', 'dsu', 'trees', '*3000'] |
D. Legen...time limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney was hanging out with Nora for a while and now he thinks he may have feelings for her. Barney wants to send her a cheesy text message and wants to make her as happy as possible. Initially, happiness l... | Input3 63 2 1heartearthart | Output6 | 6 seconds | 256 megabytes | ['data structures', 'dp', 'matrices', 'strings', '*2500'] |
C. PLEASEtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initia... | Input12 | Output1/2 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'implementation', 'math', 'matrices', '*2000'] |
B. Puzzlestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted).... | Input71 2 1 1 4 4 | Output1.0 4.0 5.0 3.5 4.5 5.0 5.0 | 1 second | 256 megabytes | ['dfs and similar', 'math', 'probabilities', 'trees', '*1700'] |
A. Lorenzo Von Matterhorntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBarney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road b... | Input71 3 4 301 4 1 21 3 6 82 4 31 6 1 402 3 72 2 4 | Output94032 | 1 second | 256 megabytes | ['brute force', 'data structures', 'implementation', 'trees', '*1500'] |
F. Couple Covertime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputCouple Cover, a wildly popular luck-based game, is about to begin! Two players must work together to construct a rectangle. A bag with n balls, each with an integer written on it, is placed on the table.... | Input54 2 6 1 341 3 5 8 | Output20181410 | 3 seconds | 512 megabytes | ['brute force', 'dp', 'number theory', '*2200'] |
E. Xor-sequencestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a1, a2, ..., an.A sequence of integers x1, x2, ..., xk is called a "xor-sequence" if for every 1 ≤ i ≤ k - 1 the number of ones in the binary representation of the num... | Input5 215 1 2 4 8 | Output13 | 3 seconds | 256 megabytes | ['matrices', '*1900'] |
D. Swaps in Permutationtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation of the numbers 1, 2, ..., n and m pairs of positions (aj, bj).At each step you can choose a pair from the given positions and swap the numbers in that positions. What ... | Input9 61 2 3 4 5 6 7 8 91 44 72 55 83 66 9 | Output7 8 9 4 5 6 1 2 3 | 5 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'math', '*1700'] |
C. Exponential notationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive decimal number x.Your task is to convert it to the "simple exponential notation".Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" l... | Input16 | Output1.6E1 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1800'] |
B. s-palindrometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", be... | InputoXoxoXo | OutputTAK | 1 second | 256 megabytes | ['implementation', 'strings', '*1600'] |
A. Fashion in Berlandtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAccording to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it s... | Input31 0 1 | OutputYES | 1 second | 256 megabytes | ['implementation', '*1000'] |
F3. Tree of Life (hard)time limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo add insult to injury, the zombies have taken all but two drawings from Heidi! Please help her recover the Tree of Life from only these two drawings.InputThe input format is the same as in the ... | Input19 264 35 46 18 68 27 158 68 78 17 35 1 | OutputYES2 13 15 46 57 68 59 81 4 | 8 seconds | 256 megabytes | ['trees', '*3200'] |
F2. Tree of Life (medium)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHeidi got tired of deciphering the prophecy hidden in the Tree of Life and decided to go back to her headquarters, rest a little and try there. Of course, she cannot uproot the Tree and take it... | Input15 524 12 113 134 14 32 133 13 24 132 13 24 2 | OutputYES2 54 23 25 1 | 5 seconds | 256 megabytes | ['constructive algorithms', 'hashing', 'trees', '*2700'] |
F1. Tree of Life (easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHeidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.On the surface, the Tree o... | Input41 21 31 4 | Output3 | 2 seconds | 256 megabytes | ['*1300'] |
D3. The Wall (hard)time limit per test15 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSo many wall designs to choose from! Even modulo 106 + 3, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do s... | Input1 1 1 | Output2 | 15 seconds | 256 megabytes | ['dp', '*2100'] |
D2. The Wall (medium)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHeidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC2 (Handbook of Crazy Const... | Input5 1 | Output5 | 2 seconds | 256 megabytes | ['combinatorics', '*1800'] |
D1. The Wall (easy)time limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output"The zombies are lurking outside. Waiting. Moaning. And when they come...""When they come?""I hope the Wall is high enough."Zombie attacks have hit the Wall, our line of defense in the North. Its p... | Input3 7...............BB.B.. | Output2 | 0.5 seconds | 256 megabytes | ['*1200'] |
C3. Brain Network (hard)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBreaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In... | Input612215 | Output1 2 2 3 4 | 2 seconds | 256 megabytes | ['trees', '*2200'] |
C2. Brain Network (medium)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFurther research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joini... | Input4 31 21 31 4 | Output2 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'trees', '*1500'] |
C1. Brain Network (easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know why their movements are so sluggish, the problem of laggy thinking has been ... | Input4 41 22 33 14 1 | Outputno | 2 seconds | 256 megabytes | ['*1300'] |
B3. Recover Polygon (hard)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZombies have found out about the Zombie Contamination level checker and managed to damage it! Now detecting the shape of their main compound will be a real challenge for Heidi. As before, a la... | Input8 192 3 2 4 2 5 3 3 3 5 4 3 4 5 4 6 5 2 5 3 5 6 6 2 6 3 6 4 6 5 6 6 6 7 7 6 7 75 82 2 2 3 2 4 3 2 3 4 4 2 4 3 4 40 0 | Output42 32 46 65 242 22 33 33 2 | 5 seconds | 256 megabytes | ['data structures', '*2600'] |
B2. Recover Polygon (medium)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow that Heidi has made sure her Zombie Contamination level checker works, it's time to strike! This time, the zombie lair is a strictly convex polygon on the lattice. Each vertex of the pol... | Input8000000000000011000012210012342000244420001223200000011000000000050000001210024200121000000700000000122100013420000132000002200000110000000000 | Output42 32 46 65 242 22 33 33 232 54 54 2 | 4 seconds | 256 megabytes | ['geometry', '*2600'] |
B1. Recover Polygon (easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lai... | Input6000000000000012100024200012100000000 | OutputYes | 2 seconds | 256 megabytes | ['*1700'] |
A3. Collective Mindsets (hard)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHeidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very r... | Input42 112 212 122 22 | Output1221 | 4 seconds | 256 megabytes | ['*2400'] |
A2. Collective Mindsets (medium)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWay to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders... | Input1 | Output0 | 1 second | 256 megabytes | ['*2300'] |
A1. Collective Mindsets (easy)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her o... | Input1 | Output1 | 1 second | 256 megabytes | ['*1100'] |
E. Mike and Geometry Problemtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in ... | Input3 21 21 32 3 | Output5 | 3 seconds | 256 megabytes | ['combinatorics', 'data structures', 'dp', 'geometry', 'implementation', '*2000'] |
D. Friends and Subsequencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who k... | Input61 2 3 2 1 46 7 1 2 3 2 | Output2 | 2 seconds | 512 megabytes | ['binary search', 'data structures', '*2100'] |
C. Mike and Chocolate Thievestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greed... | Input1 | Output8 | 2 seconds | 256 megabytes | ['binary search', 'combinatorics', 'math', '*1700'] |
B. Mike and Shortcutstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city.City consists of n intersections numbered from 1 to n. Mike ... | Input32 2 3 | Output0 1 2 | 3 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'greedy', 'shortest paths', '*1600'] |
A. Mike and Cellphonetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has on... | Input3586 | OutputNO | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', '*1400'] |
B. Lovely Palindromestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 ar... | Input1 | Output11 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1000'] |
A. Opponentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputArya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan require... | Input2 21000 | Output2 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. TOFtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Pari gave Arya a cool graph problem. Arya wrote a non-optimal solution for it, because he believes in his ability to optimize non-optimal solutions. In addition to being non-optimal, his code was buggy and h... | Input3 31 22 33 1 | Output2998 | 1 second | 256 megabytes | ['dfs and similar', 'graphs', '*2900'] |
D. Dividing Kingdom IItime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLong time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great k... | Input5 6 55 4 865 1 01 3 382 1 332 4 282 3 403 52 61 32 31 6 | Output-133-1-133 | 6 seconds | 256 megabytes | ['brute force', 'data structures', 'dsu', 'graphs', 'sortings', '*2500'] |
C. The Values You Can Maketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal t... | Input6 185 6 1 10 12 2 | Output160 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 | 2 seconds | 256 megabytes | ['dp', '*1900'] |
B. Remainders Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Pari and Arya are playing a game called Remainders.Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value . There are n ancient numbers c1, c2, ..., cn... | Input4 52 3 5 12 | OutputYes | 1 second | 256 megabytes | ['chinese remainder theorem', 'math', 'number theory', '*1800'] |
A. NP-Hard Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.Suppose the graph G is given. Subset A of its vertices is called a ver... | Input4 21 22 3 | Output12 21 3 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*1500'] |
B. Little Robber Girl's Zootime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Robber Girl likes to scare animals in her zoo for fun. She decided to arrange the animals in a row in the order of non-decreasing height. However, the animals were so scared that they ... | Input42 1 4 3 | Output1 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'sortings', '*1100'] |
A. Free Ice Creamtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.At the start of the day they have x ice cream packs. Since the ice c... | Input5 7+ 5- 10- 20+ 40- 20 | Output22 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
E. Travelling Through the Snow Queen's Kingdomtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGerda is travelling to the palace of the Snow Queen.The road network consists of n intersections and m bidirectional roads. Roads are numbered from 1 to m. Snow Queen put... | Input5 4 61 22 33 43 51 3 1 41 3 2 41 4 4 51 4 4 12 3 1 42 2 2 3 | OutputYesYesYesNoNoYes | 1.5 seconds | 256 megabytes | ['bitmasks', 'brute force', 'divide and conquer', 'graphs', '*2800'] |
D. Kay and Eternitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSnow Queen told Kay to form a word "eternity" using pieces of ice. Kay is eager to deal with the task, because he will then become free, and Snow Queen will give him all the world and a pair of skate... | Input5 34 54 65 55 67 7 | Output10 8 1 4 0 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'sortings', '*2600'] |
C. Optimal Pointtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen the river brought Gerda to the house of the Old Lady who Knew Magic, this lady decided to make Gerda her daughter. She wants Gerda to forget about Kay, so she puts all the roses from the garden und... | Input150 0 40 0 -40 4 04 0 01 1 1 | Output0 0 0 | 3 seconds | 256 megabytes | ['binary search', 'math', '*2900'] |
B. Kay and Snowflaketime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a... | Input7 41 1 3 3 5 31235 | Output3236 | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dp', 'trees', '*1900'] |
A. Robbers' watchtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRobbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.First, as they know that kingdo... | Input2 3 | Output4 | 2 seconds | 256 megabytes | ['brute force', 'combinatorics', 'dp', 'math', '*1700'] |
J. The Hero with Bombstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a new computer game you need to help the hero to get out of the maze, which is a rectangular field of size n × m. The hero is located in one of the cells of this field. He knows where the exit ... | Input3 5XEX.XX.XXTX.X.X | OutputSSMNNTSSNEMWWTEEEE | 2 seconds | 256 megabytes | ['*special problem', '*3000'] |
I. Loadertime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA loader works in a warehouse, which is a rectangular field with size n × m. Some cells of this field are free, others are occupied by pillars on which the roof of the warehouse rests. There is a load in one o... | Input3 3..Y.BX..T | OutputYESwSwsE | 4 seconds | 256 megabytes | ['*special problem', 'graphs', '*2500'] |
H. Exchange of Bookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn pupils, who love to read books, study at school. It is known that each student has exactly one best friend, and each pupil is the best friend of exactly one other pupil. Each of the pupils has exac... | Input4 12 4 1 3 | Output3 1 4 2 | 1 second | 256 megabytes | ['*special problem', '*1900'] |
G. The Fractiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeriodic decimal fraction is usually written as: [entire_part.non-periodic_part (period)]. Any simple fraction can be represented as a periodic decimal fraction and vice versa. For example, the decimal fr... | Input0.2(45) | Output27/110 | 1 second | 256 megabytes | ['*special problem', '*1900'] |
F. Reformat the Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you are given a string s consisting of uppercase and lowercase Latin letters, spaces, dots and commas. Your task is to correct the formatting of this string by removing and insertin... | Input hello ,i AM veRy GooD.Boris | OutputHello, i am very good. Boris | 1 second | 256 megabytes | ['*special problem', '*1800'] |
E. Hammer throwingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn athletes take part in the hammer throw. Each of them has his own unique identifier — the integer from 1 to n (all athletes have distinct identifiers). After the draw, the order in which the athletes ... | Input42 0 1 0 | Output2 4 1 3 | 1 second | 256 megabytes | ['*special problem', '*1800'] |
D. Chocolate Bartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA chocolate bar has a rectangular shape and consists of n × m slices. In other words, a bar consists of n rows with m slices of chocolate in each row.Each slice of chocolate is known to weigh 1 gram. You... | Input23 3 44 4 7 | OutputYesNo | 1 second | 256 megabytes | ['*special problem', 'math', '*1400'] |
C. Symmetric Differencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two sets of numbers. Your task is to print all numbers from the sets, that both sets don't contain simultaneously.InputThe first line contains the description of the first set, the s... | Input3 1 2 33 2 3 4 | Output2 1 4 | 1 second | 256 megabytes | ['*special problem', '*1600'] |
B. The Teacher of Physical Educationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn pupils came to Physical Education lesson. We know the name and the height of each pupil. Your task is to help the teacher of Physical Education to line up all pupils in non-decreasi... | Input4Ivan 150Igor 215Dasha 158Katya 150 | OutputIvanKatyaDashaIgor | 1 second | 256 megabytes | ['*special problem', '*1600'] |
A. The Check of the Pointtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the coordinate plane there is a square with sides parallel to the coordinate axes. The length of the square side is equal to a. The lower left corner of the square coincides with the point (0... | Input2 1 1 | Output0 | 1 second | 256 megabytes | ['*special problem', 'geometry', '*1200'] |
E. Alyona and Trianglestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S.Alyona tried to... | Input4 10 01 00 11 1 | Output-1 02 00 2 | 3 seconds | 256 megabytes | ['geometry', 'two pointers', '*2600'] |
D. Alyona and Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona and she decided to pay her attentio... | Input3 2 2abcab | Output2 | 2 seconds | 256 megabytes | ['dp', 'strings', '*1900'] |
C. Alyona and the Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a numb... | Input988 22 83 14 95 91 98 53 113 247 -81 671 649 655 126 -803 8 | Output5 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*1600'] |
B. Alyona and Mextime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSomeone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is ... | Input51 3 3 3 6 | Output5 | 1 second | 256 megabytes | ['sortings', '*1200'] |
A. Alyona and Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containi... | Input6 12 | Output14 | 1 second | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1100'] |
E. Runaway to a Shadowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima is living in a dormitory, as well as some cockroaches.At the moment 0 Dima saw a cockroach running on a table and decided to kill it. Dima needs exactly T seconds for aiming, and after that he... | Input0 0 1 131 1 1-1 -1 1-2 2 1 | Output0.50000000000 | 1 second | 256 megabytes | ['geometry', 'sortings', '*2500'] |
D. Gifts by the Listtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's family, so let's number them with integ... | Input3 21 22 31 2 1 | Output-1 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'trees', '*2000'] |
C. Heap Operationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has recently learned data structure named "Binary heap".The heap he is now operating with allows the following operations: put the given number into the heap; get the value of the minimum elem... | Input2insert 3getMin 4 | Output4insert 3removeMininsert 4getMin 4 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*1600'] |
B. Economy Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score ... | Input1359257 | OutputYES | 1 second | 256 megabytes | ['brute force', '*1300'] |
A. A Good Contesttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCodeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time parti... | Input3Burunduk1 2526 2537BudAlNik 2084 2214subscriber 2833 2749 | OutputYES | 1 second | 256 megabytes | ['implementation', '*800'] |
B. Bear and Finding Criminalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.Limak is a police officer. He lives in a c... | Input6 31 1 1 0 1 0 | Output3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*1000'] |
A. Bear and Five Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.Limak can discard (throw out) some cards. His goal is to minimize t... | Input7 3 7 3 20 | Output26 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
E. Bear and Bad Powers of 42time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLimak, a bear, isn't good at handling queries. So, he asks you to do it.We say that powers of 42 (numbers 1, 42, 1764, ...) are bad. Other numbers are good.You are given a sequence of n good... | Input6 1240 1700 7 1672 4 17223 2 4 421 21 33 2 6 501 21 41 62 3 4 413 1 5 11 11 31 5 | Output1742491842181418224344107 | 5 seconds | 256 megabytes | ['data structures', '*3100'] |
D. Bear and Chasetime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBearland has n cities, numbered 1 through n. There are m bidirectional roads. The i-th road connects two distinct cities ai and bi. No two roads connect the same pair of cities. It's possible to get fr... | Input3 31 21 32 3 | Output0.833333333333 | 7 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'graphs', 'implementation', 'math', 'probabilities', '*2900'] |
C. Bear and Square Gridtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X').Two empty cells are directly connected if they share a side. Two cells (r1, c1) (... | Input5 2..XXXXX.XXX.XXXX...XXXXX. | Output10 | 3 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'implementation', '*2400'] |
B. Bear and Tower of Cubestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLimak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.A block ... | Input48 | Output9 42 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', '*2200'] |
A. Bear and Prime 100time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem. In the output section below you will see the information about flushing the output.Bear Limak thinks of some hidden number — an integer from interval [2, 100]. Your t... | Inputyesnoyes | Output2805composite | 1 second | 256 megabytes | ['constructive algorithms', 'interactive', 'math', '*1400'] |
F. Lena and Queriestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLena is a programmer. She got a task to solve at work.There is an empty set of pairs of integers and n queries to process. Each query is one of three types: Add a pair (a, b) to the set. Remove a p... | Input73 11 2 33 11 -1 1003 12 43 1 | OutputEMPTY SET5995 | 4 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'geometry', '*2500'] |
E. Another Sith Tournamenttime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As o... | Input30.0 0.5 0.80.5 0.0 0.40.2 0.6 0.0 | Output0.680000000000000 | 2.5 seconds | 256 megabytes | ['bitmasks', 'dp', 'math', 'probabilities', '*2200'] |
D. Iterated Linear Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.I... | Input3 4 1 1 | Output7 | 1 second | 256 megabytes | ['math', 'number theory', '*1700'] |
C. Joty and Chocolatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.An unpainted tile should be painted Red if it's index is divisible by a an... | Input5 2 3 12 15 | Output39 | 1 second | 256 megabytes | ['implementation', 'math', 'number theory', '*1600'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.