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. Cross Sumtime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGenos has been given n distinct lines on the Cartesian plane. Let be a list of intersection points of these lines. A single point might appear multiple times in this list if it is the intersection of multi... | Input41000 1000 31000 0-1000 00 50000 -5000 | Output14.282170363 | 7 seconds | 512 megabytes | ['binary search', 'geometry', '*3300'] |
D. Power Treetime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGenos and Saitama went shopping for Christmas trees. However, a different type of tree caught their attention, the exalted Power Tree. A Power Tree starts out as a single root vertex indexed 1. A Power T... | Input2 51 1 31 2 51 3 71 4 112 1 | Output344 | 3.5 seconds | 256 megabytes | ['data structures', 'trees', '*2600'] |
C. Marblestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Tw... | Input7NNESWWSWSWSW | OutputYES | 2 seconds | 256 megabytes | ['hashing', 'strings', '*2500'] |
B. Zumatime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGenos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as pos... | Input31 2 1 | Output1 | 2 seconds | 512 megabytes | ['dp', '*1900'] |
A. Chain Reactiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n beacons located at distinct positions on a number line. The i-th beacon has position ai and power level bi. When the i-th beacon is activated, it destroys all beacons to its left (direction... | Input41 93 16 17 4 | Output1 | 2 seconds | 256 megabytes | ['binary search', 'dp', '*1600'] |
B. Testing Robotstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the ro... | Input3 4 2 2UURDRDRL | Output1 1 0 1 1 1 1 0 6 | 2 seconds | 256 megabytes | ['implementation', '*1600'] |
A. Magic Spherestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCarl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has n... | Input4 4 02 1 2 | OutputYes | 2 seconds | 256 megabytes | ['implementation', '*1200'] |
E. Intergalaxy Tripstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe scientists have recently discovered wormholesΒ β objects in space that allow to travel very long distances between galaxies and star systems. The scientists know that there are n galaxies within ... | Input3100 50 500 100 800 0 100 | Output1.750000000000000 | 2 seconds | 256 megabytes | ['probabilities', 'shortest paths', '*2700'] |
D. Board Gametime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a board card game. In this game the player has two characteristics, x and yΒ β the white magic skill and the black magic skill, respectively. There are n spell cards lying on the table, ea... | Input40 0 3 42 2 5 34 1 1 75 3 8 8 | Output31 2 4 | 2.5 seconds | 256 megabytes | ['data structures', 'dfs and similar', '*2500'] |
C. Freelancer's Dreamstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Mosc... | Input3 20 206 21 32 6 | Output5.000000000000000 | 2 seconds | 256 megabytes | ['geometry', '*2400'] |
B. Lazy Studenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudent Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graphΒ β something that will definitely never be useful in real life. He ... | Input4 52 13 14 01 15 0 | Output2 41 43 43 13 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'graphs', '*1700'] |
A. Sorting Railway Carstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the rail... | Input54 1 2 5 3 | Output2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*1600'] |
B. More Cowbelltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed s... | Input2 12 5 | Output7 | 2 seconds | 256 megabytes | ['binary search', 'greedy', '*1400'] |
A. Uncowed Forcestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Desp... | Input20 40 60 80 1000 1 2 3 41 0 | Output4900 | 1 second | 256 megabytes | ['implementation', '*1000'] |
E. Pastoral Odditiestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the land of Bovinia there are n pastures, but no paths connecting the pastures. Of course, this is a terrible situation, so Kevin Sun is planning to rectify it by constructing m undirected paths ... | Input4 41 3 42 4 81 2 23 4 3 | Output-1883 | 4 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'dsu', 'math', 'trees', '*3000'] |
D. Ruminations on Ruminantstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKevin Sun is ruminating on the origin of cows while standing at the origin of the Cartesian plane. He notices n lines on the plane, each representable by an equation of the form axβ+βbyβ=βc.... | Input41 0 00 1 01 1 -11 -1 2 | Output2 | 4 seconds | 256 megabytes | ['geometry', 'math', '*2900'] |
C. Lieges of Legendretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that ... | Input2 13 4 | OutputKevin | 2 seconds | 256 megabytes | ['games', 'math', '*2200'] |
B. Moodular Arithmetictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (M... | Input3 2 | Output3 | 1 second | 256 megabytes | ['combinatorics', 'dfs and similar', 'dsu', 'math', 'number theory', '*1800'] |
A. Alternative Thinkingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin... | Input810000011 | Output5 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'math', '*1600'] |
B. Approximating a Constant Rangetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium inte... | Input51 2 3 3 2 | Output4 | 2 seconds | 256 megabytes | ['dp', 'implementation', 'two pointers', '*1400'] |
A. Two Basestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.You're given a number X represented in ba... | Input6 21 0 1 1 1 12 104 7 | Output= | 1 second | 256 megabytes | ['brute force', 'implementation', '*1100'] |
E. A Museum Robberytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere's a famous museum in the city where KleofΓ‘Ε‘ lives. In the museum, n exhibits (numbered 1 through n) had been displayed for a long time; the i-th of those exhibits has value vi and mass wi. Then... | Input3 1030 460 65 1931 42 51 20 332 22 431 40 63 | Output556674384168191145947033915181541912 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*2800'] |
D. Acyclic Organic Compoundstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1.Let's look at the subtree Tv of some vertex v. It is possible to rea... | Input101 2 7 20 20 30 40 50 50 50cacabbcddd1 26 87 26 25 45 93 102 52 3 | Output513 | 3 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'dsu', 'hashing', 'strings', 'trees', '*2400'] |
C. KleofΓ‘Ε‘ and the n-thlontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKleofΓ‘Ε‘ is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). There are m participants in the n-thlon and each ... | Input4 102121 | Output1.0000000000000000 | 1 second | 256 megabytes | ['dp', 'math', 'probabilities', '*2300'] |
B. Lipshitz Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA function is called Lipschitz continuous if there is a real constant K such that the inequality |f(x)β-βf(y)|ββ€βKΒ·|xβ-βy| holds for all . We'll deal with a more... discrete version of this term.For... | Input10 41 5 2 9 1 3 4 2 1 72 43 87 101 9 | Output178223210 | 1 second | 256 megabytes | ['data structures', 'math', '*2100'] |
A. The Two Routestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road networkΒ β for each pair of different towns x and y, there is a bidirectional... | Input4 21 33 4 | Output2 | 2 seconds | 256 megabytes | ['graphs', 'shortest paths', '*1600'] |
F. Edge coloring of bipartite graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected bipartite graph without multiple edges. You should paint the edges of graph to minimal number of colours, so that no two adjacent edges have the same colour... | Input4 3 51 22 23 24 14 3 | Output31 2 3 1 2 | 1 second | 256 megabytes | ['graphs', '*2800'] |
E. Lomsat gelraltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour.Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtr... | Input41 2 3 41 22 32 4 | Output10 9 3 4 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dsu', 'trees', '*2300'] |
D. Area of Two Circles' Intersectiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two circles. Find the area of their intersection.InputThe first line contains three integers x1,βy1,βr1 (β-β109ββ€βx1,βy1ββ€β109,β1ββ€βr1ββ€β109) β the position of the cent... | Input0 0 46 0 4 | Output7.25298806364175601379 | 2 seconds | 256 megabytes | ['geometry', '*2000'] |
C. Make Palindrometime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" an... | Inputaabc | Outputabba | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'strings', '*1800'] |
B. Queries about less or equal elementstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj... | Input5 41 3 5 7 96 4 2 8 | Output3 2 1 4 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'sortings', 'two pointers', '*1300'] |
A. Extract Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", ... | Inputaba,123;1a;0 | Output"123,0""aba,1a" | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1600'] |
E. Sandy and Nutstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRooted tree is a connected graph without any simple cycles with one vertex selected as a root. In this problem the vertex number 1 will always serve as a root.Lowest common ancestor of two vertices u a... | Input4 0 0 | Output16 | 3 seconds | 256 megabytes | ['bitmasks', 'dp', 'trees', '*2600'] |
D. Spongebob and Squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table c... | Input26 | Output61 262 93 55 39 226 1 | 2 seconds | 256 megabytes | ['brute force', 'math', '*1900'] |
C. Day at the Beachtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building s... | Input31 2 3 | Output3 | 2 seconds | 256 megabytes | ['sortings', '*1600'] |
B. Spongebob and Joketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1,βa2,β...,βam of length m... | Input3 33 2 11 2 3 | OutputPossible3 2 1 | 2 seconds | 256 megabytes | ['implementation', '*1500'] |
A. Patrick and Shoppingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between h... | Input10 20 30 | Output60 | 1 second | 256 megabytes | ['implementation', '*800'] |
F. Cut Lengthtime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.The boundary of n-gon belon... | Input4 30 01 01 10 10 0 1 10 0 0 10 0 1 -1 | Output1.414213562373095145471.000000000000000000000.00000000000000000000 | 0.5 seconds | 256 megabytes | ['geometry', '*2900'] |
E. Chocolate Bartime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a rectangular chocolate bar consisting of nβΓβm single squares. You want to eat exactly k squares, so you may need to break the chocolate bar. In one move you can break any single rectangular p... | Input42 2 12 2 32 2 22 2 4 | Output5540 | 2 seconds | 256 megabytes | ['brute force', 'dp', '*2000'] |
D. Igor In the Museumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIgor is in the museum and he wants to see as many pictures as possible.Museum can be represented as a rectangular field of nβΓβm cells. Each cell is either empty or impassable. Empty cells are marke... | Input5 6 3*******..*.********....*******2 22 54 3 | Output6410 | 1 second | 256 megabytes | ['dfs and similar', 'graphs', 'shortest paths', '*1700'] |
C. Nearest vectorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.Non-oriented angle is non-ne... | Input4-1 00 -11 01 1 | Output3 4 | 2 seconds | 256 megabytes | ['geometry', 'sortings', '*2300'] |
B. Queries on a Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri] ki ... | Inputabacaba23 6 11 4 2 | Outputbaabcaa | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1300'] |
A. Tricky Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.For example, for nβ=β4 the sum is equal to β-β1β-β2β+β3β-β4β=ββ-β4, beca... | Input241000000000 | Output-4499999998352516354 | 1 second | 256 megabytes | ['math', '*900'] |
C. Subsequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor the given sequence with n different elements find the number of increasing subsequences with kβ+β1 elements. It is guaranteed that the answer is not greater than 8Β·1018.InputFirst line contain two int... | Input5 212354 | Output7 | 1 second | 256 megabytes | ['data structures', 'dp', '*1900'] |
B. Restauranttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time li and the finis... | Input27 114 7 | Output1 | 4 seconds | 256 megabytes | ['dp', 'greedy', 'sortings', '*1600'] |
A. Divisibilitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFind the number of k-divisible numbers on the segment [a,βb]. In other words you need to find the number of such integer values x that aββ€βxββ€βb and x is divisible by k.InputThe only line contains three s... | Input1 1 10 | Output10 | 1 second | 256 megabytes | ['math', '*1600'] |
E. Wilbur and Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWilbur the pig now wants to play with strings. He has found an n by m table consisting only of the digits from 0 to 9 where the rows are numbered 1 to n and the columns are numbered 1 to m. Wilbur ... | Input1 1 201 11 11 11 11 11 11 11 11 11 100000000000002413423432432 | OutputYESNO | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'strings', '*2500'] |
D. Wilbur and Treestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.There are n trees located at various positions on a line. Tree i is locate... | Input2 2 0.5000001 2 | Output3.250000000 | 2 seconds | 256 megabytes | ['dp', 'math', 'probabilities', 'sortings', '*2300'] |
C. Wilbur and Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such ... | Input52 00 01 01 10 10 -1 -2 1 0 | OutputYES0 01 02 00 11 1 | 2 seconds | 256 megabytes | ['combinatorics', 'greedy', 'sortings', '*1700'] |
B. Wilbur and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWilbur the pig is tinkering with arrays again. He has the array a1,βa2,β...,βan initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai,βaiβ+β1,β..... | Input51 2 3 4 5 | Output5 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1100'] |
A. Wilbur and Swimming Pooltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rect... | Input20 01 1 | Output1 | 1 second | 256 megabytes | ['geometry', 'implementation', '*1100'] |
B. Pasha and Phonetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.Also Pasha has a number k and two sequences of length nβ... | Input6 238 56 497 3 4 | Output8 | 1 second | 256 megabytes | ['binary search', 'math', '*1600'] |
A. Vitaly and Nighttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at t... | Input2 20 0 0 11 0 1 1 | Output3 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
E. Cutting the Linetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a non-empty line s and an integer k. The following operation is performed with this line exactly once: A line is split into at most k non-empty substrings, i.e. string s is represented... | Inputaba2 | Outputaab | 2 seconds | 256 megabytes | ['string suffix structures', 'strings', '*3100'] |
D. REQtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday on a math lesson the teacher told Vovochka that the Euler function of a positive integer Ο(n) is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to... | Input101 2 3 4 5 6 7 8 9 1071 13 85 64 88 107 97 10 | Output14608815361921441152 | 3 seconds | 256 megabytes | ['data structures', 'number theory', '*2500'] |
C. Edo and Magnetstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEdo has got a collection of n refrigerator magnets!He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the followi... | Input3 11 1 2 22 2 3 33 3 4 4 | Output1 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', 'two pointers', '*2300'] |
B. Max and Biketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor months Maxim has been coming to work on his favorite bicycle. And quite recently he decided that he is ready to take part in a cyclists' competitions.He knows that this year n competitions will take ... | Input2 1 21 105 9 | Output3.8496447105021.106060157705 | 2 seconds | 256 megabytes | ['binary search', 'geometry', '*2500'] |
A. Warrior and Archertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed... | Input60 1 3 7 15 31 | Output7 | 2 seconds | 256 megabytes | ['games', '*2300'] |
E. Strange Calculation and Catstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGosha's universe is a table consisting of n rows and m columns. Both the rows and columns are numbered with consecutive integers starting with 1. We will use (r,βc) to denote a cell locat... | Input1 3 32 1 2 33 1 2 51 1 1 7 | Output5 | 4 seconds | 256 megabytes | ['dp', 'matrices', '*2400'] |
D. Happy Tree Partytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed g... | Input6 61 2 11 3 71 4 42 5 52 6 21 4 6 172 3 21 4 6 171 5 5 202 4 11 5 1 3 | Output24203 | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'math', 'trees', '*2400'] |
C. Beautiful Functiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvery day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to ch... | Input30 10 410 0 420 10 4 | Outputt abs((t-10)) | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*2200'] |
B. Anton and Linestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations ... | Input41 21 21 00 10 2 | OutputNO | 1 second | 256 megabytes | ['geometry', 'sortings', '*1600'] |
A. 2Chartime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as h... | Input4abbcaccaaabbb | Output9 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1200'] |
E. BCPCtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBCPC stands for Byteforces Collegiate Programming Contest, and is the most famous competition in Byteforces.BCPC is a team competition. Each team is composed by a coach and three contestants. Blenda is the coach... | Input5 2 21 14 12 33 23 4 | Output4 | 4 seconds | 256 megabytes | ['binary search', 'geometry', 'two pointers', '*2700'] |
D. Super Mtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAri the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforcesβ superhero. Byteforces is a country that consists of n cities, connected by nβ-β1 bidirectional roads. Every r... | Input7 21 21 31 43 53 63 72 7 | Output23 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*2200'] |
C. The Big Racetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today. Willman and Bolt have exactly the same speed, so when ... | Input10 3 2 | Output3/10 | 1 second | 256 megabytes | ['math', '*1800'] |
B. The Monster and the Squirreltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAri the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.Ari draws a regular convex polygon on the floor and numbers it... | Input5 | Output9 | 1 second | 256 megabytes | ['math', '*1100'] |
A. PawnChesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGalois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named Β«PawnChessΒ».This new game is played on a board consisting of 8 rows and 8 columns. At t... | Input.................B....B.....W.............W..................... | OutputA | 1 second | 256 megabytes | ['implementation', '*1200'] |
B. Rebrandingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebrandingΒ β an active marketing strategy, that includes a set of measures to change ... | Input6 1policep m | Outputmolice | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1200'] |
A. Wizards' Dueltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHarry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length l. Two opponents simultaneously charge a deadl... | Input1005050 | Output50 | 2 seconds | 256 megabytes | ['implementation', 'math', '*900'] |
E. Birthdaytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputToday is birthday of a Little DashaΒ β she is now 8 years old! On this occasion, each of her n friends and relatives gave her a ribbon with a greeting written on it, and, as it turned out, all the greetings a... | Input5abababaaababababbbab | Output22 5 | 3 seconds | 512 megabytes | ['graph matchings', 'strings', '*3200'] |
D. Top Secret Tasktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. According to the charter, each top-secret military base must include a top-secret ... | Input3 2 22 4 1 | Output3 | 3 seconds | 256 megabytes | ['dp', '*2300'] |
C. Three Statestime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territo... | Input4 511..2#..22#.323.#333 | Output2 | 5 seconds | 512 megabytes | ['dfs and similar', 'graphs', 'shortest paths', '*2200'] |
B. Chip 'n Dale Rescue Rangerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chip... | Input0 0 5 53 2-1 -1-1 0 | Output3.729935587093555327 | 1 second | 256 megabytes | ['binary search', 'geometry', 'math', '*2100'] |
A. Median Smoothingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many ... | Input40 0 1 1 | Output00 0 1 1 | 2 seconds | 256 megabytes | ['implementation', '*1700'] |
B. Duff in Lovetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer aβ>β1 such that a2 is a divisor of x. Malek has a number store! In his store, ... | Input10 | Output10 | 2 seconds | 256 megabytes | ['math', '*1300'] |
A. Duff and Meattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly ai kilograms of meat. There is a big shop uptown and Malek wants to buy mea... | Input31 32 23 1 | Output10 | 1 second | 256 megabytes | ['greedy', '*900'] |
F. Duff is Madtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuff is mad at her friends. That's why she sometimes makes Malek to take candy from one of her friends for no reason! She has n friends. Her i-th friend's name is si (their names are not necessarily uniq... | Input5 5aababababababb1 5 43 5 41 5 21 5 31 4 1 | Output126371 | 4 seconds | 256 megabytes | ['data structures', 'strings', '*3000'] |
E. Duff as a Queentime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuff is the queen of her country, Andarz Gu. She's a competitive programming fan. That's why, when he saw her minister, Malek, free, she gave her a sequence consisting of n non-negative integers, a1,β... | Input5 51 2 3 4 22 1 51 2 2 82 1 51 1 3 102 2 2 | Output8161 | 7 seconds | 256 megabytes | ['data structures', '*2900'] |
D. Duff in Mafiatime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has n cities (numbered from 1 to n) connected by m bidirectional roads (numbered by 1 to m).Each road has a destructing time, and a... | Input5 72 1 3 73 1 1 65 4 1 84 5 1 13 2 2 34 5 2 52 3 2 4 | OutputYes3 24 5 | 6 seconds | 256 megabytes | ['2-sat', 'binary search', '*3100'] |
C. Duff in the Armytime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRecently Duff has been a soldier in the army. Malek is her commander.Their country, Andarz Gu has n cities (numbered from 1 to n) and nβ-β1 bidirectional roads. Each road connects two different citie... | Input5 4 51 31 21 44 52 1 4 34 5 61 5 25 5 102 3 35 3 1 | Output1 32 2 303 1 2 41 2 | 4 seconds | 512 megabytes | ['data structures', 'trees', '*2200'] |
B. Duff in Beachtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile Duff was resting in the beach, she accidentally found a strange array b0,βb1,β...,βblβ-β1 consisting of l positive integers. This array was strange because it was extremely long, but there was ano... | Input3 5 35 9 1 | Output10 | 2 seconds | 256 megabytes | ['dp', '*2100'] |
A. Duff and Weight Liftingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lif... | Input51 1 2 3 3 | Output2 | 1 second | 256 megabytes | ['greedy', '*1500'] |
B. Laurenty and Shoptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA little boy Laurenty has been playing his favourite game Nota for quite a while and is now very hungry. The boy wants to make sausage and cheese sandwiches, but first, he needs to buy a sausage and ... | Input41 2 33 2 13 2 2 3 | Output12 | 1 second | 256 megabytes | ['implementation', '*1300'] |
A. Alena's Scheduletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlena has successfully passed the entrance exams to the university and is now looking forward to start studying.One two-hour lesson at the Russian university is traditionally called a pair, it lasts f... | Input50 1 0 1 1 | Output4 | 1 second | 256 megabytes | ['implementation', '*900'] |
F. Digits of Number Pitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasily has recently learned about the amazing properties of number Ο. In one of the articles it has been hypothesized that, whatever the sequence of numbers we have, in some position, this sequenc... | Input021019 | Output2 | 2 seconds | 256 megabytes | ['dp', 'implementation', 'strings', '*3200'] |
E. Present for Vitalik the Philatelist time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVitalik the philatelist has a birthday today!As he is a regular customer in a stamp store called 'Robin Bobin', the store management decided to make him a gift.Vitalik wants to bu... | Input32 3 2 | Output5 | 5 seconds | 256 megabytes | ['combinatorics', 'math', 'number theory', '*2900'] |
D. Lizard Era: Beginningtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to tak... | Input31 0 00 1 00 0 1 | OutputLMMWMW | 2 seconds | 256 megabytes | ['meet-in-the-middle', '*2300'] |
C. Alice, Bob, Oranges and Applestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process... | Input1 4 | Output3B | 1 second | 256 megabytes | ['number theory', '*2400'] |
B. Phillip and Trainstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe mobile application store has a new game called "Subway Roller".The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a recta... | Input216 4...AAAAA........s.BBB......CCCCC........DDDDD...16 4...AAAAA........s.BBB....CCCCC.........DDDDD.... | OutputYESNO | 1 second | 256 megabytes | ['dfs and similar', 'graphs', 'shortest paths', '*1700'] |
A. Gennady the Dentisttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.All children love to cry loudly at the reception at the dent... | Input54 2 24 1 25 2 43 3 55 1 2 | Output21 3 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1800'] |
E. Anton and Iratime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them obtain the required permutation by paying as little money... | Input44 2 1 33 2 4 1 | Output324 33 1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*2300'] |
D. Dima and Lisatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes... | Input27 | Output35 11 11 | 1 second | 256 megabytes | ['brute force', 'math', 'number theory', '*1800'] |
C. Marina and Vasyatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.More formally, you are given... | Input3 2abcxyc | Outputayd | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'strings', '*1700'] |
B. Kolya and Tanya time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.More formally, there are 3n gnomes... | Input1 | Output20 | 1 second | 256 megabytes | ['combinatorics', '*1500'] |
A. Olesya and Rodiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them.Your task is: given the n and t print an integer stric... | Input3 2 | Output712 | 1 second | 256 megabytes | ['math', '*1000'] |
B. Robot's Tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRobot Doc is located in the hall, with n computers stand in a line, numbered from left to right from 1 to n. Each computer contains exactly one piece of information, each of which Doc wants to get eventua... | Input30 2 0 | Output1 | 1 second | 256 megabytes | ['greedy', 'implementation', '*1200'] |
A. Asphalting Roadstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCity X consists of n vertical and n horizontal infinite roads, forming nβΓβn intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the nu... | Input21 11 22 12 2 | Output1 4 | 1 second | 256 megabytes | ['implementation', '*1000'] |
E. Boolean Functiontime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem we consider Boolean functions of four variables A,βB,βC,βD. Variables A,βB,βC and D are logical and can take values 0 or 1. We will define a function using the following grammar:<expr... | Input?21 0 1 0 10 1 1 0 1 | Output2 | 4 seconds | 256 megabytes | ['bitmasks', 'dp', 'expression parsing', '*3000'] |
D. Number of Binominal Coefficientstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor a given prime integer p and integers Ξ±,βA calculate the number of pairs of integers (n,βk), such that 0ββ€βkββ€βnββ€βA and is divisible by pΞ±. As the answer can be rather large, pri... | Input2 27 | Output3 | 4 seconds | 256 megabytes | ['dp', 'math', 'number theory', '*3300'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.