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 |
|---|---|---|---|---|---|
C. Football Championshiptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAny resemblance to any real championship and sport is accidental.The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal ru... | InputAERLAND DERLAND 2:1DERLAND CERLAND 0:3CERLAND AERLAND 0:1AERLAND BERLAND 2:0DERLAND BERLAND 4:0 | Output6:0 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1800'] |
B. Drinkstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drin... | Input350 50 100 | Output66.666666666667 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
A. Cinematime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe capital of Berland has the only movie theater in the country. Besides, it consists of only one room. The room is divided into n rows, each row consists of m seats.There are k people lined up to the box o... | Input3 4 61 11 11 11 21 31 3 | Output1 11 22 11 31 42 3 | 1.5 seconds | 256 megabytes | ['brute force', 'data structures', '*2400'] |
B. Special Olympicstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled "Special Olympics". He justly thought that, if the regular Olympic games have five rings, then ... | Input60 60 45 5580 80 8 32 | Output1 | 2 seconds | 256 megabytes | ['geometry', '*1900'] |
A. Hexadecimal's theoremtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibon... | Input3 | Output1 1 1 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'number theory', '*900'] |
E. Gripping Storytime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOne day Qwerty the Ranger witnessed two transport ships collide with each other. As a result, all contents of their cargo holds scattered around the space. And now Qwerty wants to pick as many lost ite... | Input0 0 5 10 55 4 7 11 5-7 1 4 7 80 2 13 5 62 -3 9 3 413 5 1 9 9 | Output3 | 4 seconds | 512 megabytes | ['binary search', 'data structures', 'sortings', '*2400'] |
D. Cube Snaketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got an nβΓβnβΓβn cube, split into unit cubes. Your task is to number all unit cubes in this cube with positive integers from 1 to n3 so that: each number was used as a cube's number exactly once; ... | Input3 | Output1 4 17 2 3 18 27 26 19 8 5 16 7 6 15 24 25 20 9 12 13 10 11 14 23 22 21 | 2 seconds | 256 megabytes | ['constructive algorithms', '*2700'] |
C. Delivering Carcinogentime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputQwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to g... | Input10 0 1-10 0 2 8 | Output9.584544103 | 2 seconds | 256 megabytes | ['binary search', 'geometry', '*2400'] |
B. Jumping on Wallstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.The canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that w... | Input7 3---X--X-X--XX- | OutputYES | 2 seconds | 256 megabytes | ['shortest paths', '*1400'] |
A. About Bacteriatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputQwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't d... | Input3 1 3 5 | Output2 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1700'] |
B. Limittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two polynomials: P(x)β=βa0Β·xnβ+βa1Β·xnβ-β1β+β...β+βanβ-β1Β·xβ+βan and Q(x)β=βb0Β·xmβ+βb1Β·xmβ-β1β+β...β+βbmβ-β1Β·xβ+βbm. Calculate limit .InputThe first line contains two space-separated integers n ... | Input2 11 1 12 5 | OutputInfinity | 2 seconds | 256 megabytes | ['math', '*1400'] |
A. Plate Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plate... | Input5 5 2 | OutputFirst | 2 seconds | 256 megabytes | ['constructive algorithms', 'games', 'math', '*1600'] |
E. Opening Portalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPavel plays a famous computer game. A player is responsible for a whole country and he can travel there freely, complete quests and earn experience.This country has n cities connected by m bidirection... | Input3 31 2 11 3 12 3 131 2 3 | Output2 | 2 seconds | 256 megabytes | ['dsu', 'graphs', 'shortest paths', '*2600'] |
D. The Next Good Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn problems on strings one often has to find a string with some particular properties. The problem authors were reluctant to waste time on thinking of a name for some string so they called it goo... | Input3aaaaaaa | Outputaabbcaa | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'hashing', 'strings', '*2800'] |
C. Paint Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n vertexes and n points on a plane, no three points lie on one straight line.Your task is to paint the given tree on a plane, using the given points as vertexes. That is, you shou... | Input31 32 30 01 12 0 | Output1 3 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'divide and conquer', 'geometry', 'sortings', 'trees', '*2200'] |
B. Infinite Mazetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe've got a rectangular nβΓβm-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze and cyclically tiled a plane with it so that the plane became an infinite ma... | Input5 4##.###S##..##.###..# | OutputYes | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*2000'] |
A. Lexicographically Maximum Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.We'll call a non-empty string s[p1p2... pk]β=βsp1sp2... spk(1ββ€β... | Inputababba | Outputbbba | 2 seconds | 256 megabytes | ['greedy', 'strings', '*1100'] |
E. Building Foresttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn oriented weighted forest is an acyclic weighted digraph in which from each vertex at most one edge goes.The root of vertex v of an oriented weighted forest is a vertex from which no edge goes and w... | Input6001 2 12 1 5 2 21 1 21 3 4 | Output30 | 2 seconds | 256 megabytes | ['data structures', 'dsu', 'graphs', '*2000'] |
D. Analyzing Polylinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch footb... | Input11 0 | Output1 | 2 seconds | 256 megabytes | ['geometry', 'math', 'sortings', '*1900'] |
C. Try and Catchtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.T... | Input8try try throw ( AE ) catch ( BE, "BE in line 3") try catch(AE, "AE in line 5") catch(AE,"AE somewhere") | OutputAE somewhere | 2 seconds | 256 megabytes | ['expression parsing', 'implementation', '*1800'] |
B. After Trainingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The b... | Input4 3 | Output2132 | 2 seconds | 256 megabytes | ['data structures', 'implementation', 'math', '*1300'] |
A. Let's Watch Footballtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too... | Input4 1 1 | Output3 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'math', '*1000'] |
B. Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John... | Input34 8 100 | Output1733401 | 2 seconds | 256 megabytes | ['math', '*1200'] |
A. Examstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would... | Input4 8 | Output4 | 2 seconds | 256 megabytes | ['implementation', 'math', '*900'] |
E. Fibonacci Numbertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohn Doe has a list of all Fibonacci numbers modulo 1013. This list is infinite, it starts with numbers 0 and 1. Each number in the list, apart from the first two, is a sum of previous two modulo 101... | Input13 | Output7 | 3 seconds | 256 megabytes | ['brute force', 'math', 'matrices', '*2900'] |
D. Two Segmentstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNick has some permutation consisting of p integers from 1 to n. A segment [l,βr] (lββ€βr) is a set of elements pi satisfying lββ€βiββ€βr.Nick calls a pair of segments [a0,βa1] and [b0,βb1] (1ββ€βa0ββ€βa1β<βb0... | Input31 2 3 | Output3 | 5 seconds | 256 megabytes | ['data structures', '*2900'] |
C. Hamming Distancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHamming distance between strings a and b of equal length (denoted by h(a,βb)) is equal to the number of distinct integers i (1ββ€βiββ€β|a|), such that aiββ βbi, where ai is the i-th symbol of string a, ... | Input4 4 44 44 | Output6aaaabbaabbaabbaaaabbbbbb | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', 'matrices', '*2400'] |
B. Xortime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohn Doe has four arrays: a, b, k, and p. Each array consists of n integers. Elements of all arrays are indexed starting from 1. Array p is a permutation of integers 1 to n.John invented a game for his friends an... | Input3 2 17 7 78 8 81 2 31 3 2 | Output96 | 4 seconds | 256 megabytes | ['brute force', '*2000'] |
A. Cutting Figuretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've gotten an nβΓβm sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares th... | Input5 4#####..##..##..##### | Output2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'trees', '*1700'] |
B. Walking in the Raintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The oppositio... | Input410 3 5 10 | Output5 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1100'] |
A. Funky Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those t... | Input256 | OutputYES | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'implementation', '*1300'] |
E. Thwarting Demonstrationstime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIt is dark times in Berland. Berlyand opposition, funded from a neighboring state, has organized a demonstration in Berland capital Bertown. Through the work of intelligence we know that the ... | Input3 41 4 2 | Output4 | 6 seconds | 512 megabytes | ['binary search', 'data structures', 'trees', '*2200'] |
D. Metro Schemetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland is very concerned with privacy, so almost all plans and blueprints are secret. However, a spy of the neighboring state managed to steal the Bertown subway scheme.The Bertown Subway has n stations... | Input3 31 22 33 1 | Output1 3 | 2 seconds | 256 megabytes | ['graphs', 'greedy', '*2700'] |
C. Fools and Roadstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThey say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are man... | Input51 21 32 42 521 43 5 | Output2 1 1 1 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*1900'] |
B. Demonstrationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough an... | Input5 282 4 5 3 1 | Output2 | 2 seconds | 256 megabytes | ['greedy', '*1700'] |
A. Dynasty Puzzlestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berla... | Input3abccacba | Output6 | 2 seconds | 256 megabytes | ['dp', '*1500'] |
E. Counter Attacktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland has managed to repel the flatlanders' attack and is now starting the counter attack.Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The... | Input4 41 21 34 24 3 | Output22 1 4 2 2 3 | 3 seconds | 256 megabytes | ['data structures', 'dsu', 'graphs', 'hashing', 'sortings', '*2100'] |
D. Non-Secret Cyphertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland starts to seize the initiative on the war with Flatland. To drive the enemy from their native land, the berlanders need to know exactly how many more flatland soldiers are left in the enemy'... | Input4 21 2 1 2 | Output3 | 3 seconds | 256 megabytes | ['two pointers', '*1900'] |
C. STLtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.We all know that programs often store sets of integers. For e... | Input3pair pair int int int | Outputpair<pair<int,int>,int> | 2 seconds | 256 megabytes | ['dfs and similar', '*1500'] |
B. Surroundedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSo, the Berland is at war with its eternal enemy Flatland again, and Vasya, an accountant, was assigned to fulfil his duty to the nation. Right now the situation in Berland is dismal β their both cities are... | Input0 0 16 0 3 | Output1.000000000000000 | 1 second | 256 megabytes | ['geometry', '*1800'] |
A. Vasya and the Bustime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids..."The latter events happen to be of no importance to us. Vasya is ... | Input1 2 | Output2 2 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1100'] |
B. Counting Rhombitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two positive integers w and h. Your task is to count the number of rhombi which have the following properties: Have positive area. With vertices at integer points. All vertices of the rho... | Input2 2 | Output1 | 2 seconds | 256 megabytes | ['brute force', 'math', '*1300'] |
A. Cut Ribbontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each ribbon piece should have length a, b or c. After the cuttin... | Input5 5 3 2 | Output2 | 1 second | 256 megabytes | ['brute force', 'dp', '*1300'] |
H. Stacktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem we'll use a stack which supports two types of operations: Push a given number on the stack. Pop two numbers from the stack, perform a given operation (addition or multiplication) on them and p... | Input12+3*66*+ | Output45 | 2 seconds | 256 megabytes | ['*special problem', 'expression parsing', 'implementation', '*1800'] |
G. Array Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSorting arrays is traditionally associated with high-level languages. How hard can it be in Roco? Sort the given array in non-descending order.InputThe first line of input contains an integer n (1ββ€βnββ€... | Input571973 | Output1 3 7 7 9 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1600'] |
F. Binary Notationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Output its binary notation.InputThe only line of input data contains an integer n (1ββ€βnββ€β106).OutputOutput the binary notation of n (without any leading zeros).Ex... | Input5 | Output101 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1400'] |
E. HQ9+time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHQ9+ is a joke programming language which has only four one-character instructions: "H" prints "Hello, World!", "Q" prints the whole source code of the program itself (at each call), "9" prints the lyrics of "99... | InputHello! | OutputYES | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1400'] |
D. Asteriskstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a number n. Print n lines, i-th line should consist of i characters "*". Lines' indices are 1-based.InputThe only line of input contains an integer n (1ββ€βnββ€β50).OutputOutput the described pa... | Input3 | Output****** | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1100'] |
C. LCMtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLeast common multiple (LCM) of two numbers is the smallest positive integer which is divisible by both of them. You are given integers a and b. Calculate their LCM.InputThe input contains two integers a and b (1β... | Input10 42 | Output210 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', 'math', '*1400'] |
B. A + Reverse Btime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given numbers a and b. Calculate the sum of a and reverse of b. A reverse of a number is a number which contains the same digits in reverse order. For example, reverse of 230 is 32, and reverse ... | Input5 15 | Output56 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1300'] |
A. Hexagonal Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHexagonal numbers are figurate numbers which can be calculated using the formula hnβ=β2n2β-βn. You are given n; calculate n-th hexagonal number.InputThe only line of input contains an integer n (1ββ€... | Input3 | Output15 | 2 seconds | 256 megabytes | ['*special problem', '*1100'] |
E. Heaven Tourtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe story was not finished as PMP thought. God offered him one more chance to reincarnate and come back to life. But before he can come back, God told him that PMP should ask n great men including promine... | Input5 2 20 10 11 21 22 | Output331 3 5 4 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2900'] |
D. BRT Contract time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the last war of PMP, he defeated all his opponents and advanced to the final round. But after the end of semi-final round evil attacked him from behind and killed him! God bless him. Before his death... | Input1 3 25 2512345 | Output89121212 | 2 seconds | 256 megabytes | ['data structures', '*2800'] |
C. Weak Memorytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZart PMP is qualified for ICPC World Finals in Harbin, China. After team excursion to Sun Island Park for snow sculpture art exposition, PMP should get back to buses before they leave. But the park is rea... | Input6 6 31 3 61 22 34 25 64 53 41 6 | Output3 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', '*2000'] |
B. AlgoRacetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, he decided to compete in a car racing to increase the spirit of victory. H... | Input4 2 30 1 5 62 0 3 61 3 0 16 6 7 00 3 5 62 0 1 61 3 0 26 6 7 01 4 21 4 11 4 3 | Output343 | 2 seconds | 256 megabytes | ['dp', 'shortest paths', '*1800'] |
A. Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHappy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.One of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 thr... | Input33 2 11 2 3 | Output2 | 2 seconds | 256 megabytes | ['greedy', '*1500'] |
B. Growing Mushroomstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. T... | Input2 3 3 502 44 2 | Output1 15.002 15.00 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1200'] |
A. Comparing Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on geno... | Inputabba | OutputYES | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1100'] |
E. Soap Time! - 2time limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputImagine the Cartesian coordinate system. There are k different points containing subway stations. One can get from any subway station to any one instantly. That is, the duration of the transfer between... | Input1 02 -2 | Output0 | 6 seconds | 256 megabytes | ['binary search', 'data structures', '*3000'] |
D. Visit of the Greattime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Great Mushroom King descended to the dwarves, but not everyone managed to see him. Only the few chosen ones could see the King.We know that only LCM(k2lβ+β1,βk2lβ+β1β+β1,β...,βk2rβ+β1) dwarves ... | Input23 1 10 25 0 4 3 | Output00 | 3 seconds | 256 megabytes | ['math', 'number theory', '*2600'] |
C. Clever Fat Rattime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Fat Rat and his friend Π‘erealguy have had a bet whether at least a few oats are going to descend to them by some clever construction. The figure below shows the clever construction. A more forma... | Input112 | OutputFat Rat | 2.5 seconds | 256 megabytes | ['dp', '*2500'] |
B. Mushroom Scientiststime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (x,βy,βz). In this c... | Input31 1 1 | Output1.0 1.0 1.0 | 2 seconds | 256 megabytes | ['math', 'ternary search', '*1800'] |
A. Planttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: thr... | Input1 | Output3 | 2 seconds | 256 megabytes | ['math', '*1300'] |
E. Candy Shoptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe prestigious Codeforces kindergarten consists of n kids, numbered 1 through n. Each of them are given allowance in rubles by their parents.Today, they are going to the most famous candy shop in the town... | Input2 5510 | Output13 | 3 seconds | 256 megabytes | ['greedy', '*2900'] |
D. T-shirttime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are going to work in Codeforces as an intern in a team of n engineers, numbered 1 through n. You want to give each engineer a souvenir: a T-shirt from your country (T-shirts are highly desirable in Codefo... | Input2 2500 500500 500 | Output1.500000000000 | 5 seconds | 256 megabytes | ['dp', 'greedy', 'probabilities', '*2700'] |
C. Cyclic Coloringtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a directed graph G with n vertices and m arcs (multiple arcs and self-loops are allowed). You have to paint each vertex of the graph into one of the k (kββ€βn) colors in such way that for... | Input4 41 22 13 44 3 | Output2 | 4 seconds | 256 megabytes | ['dfs and similar', '*2200'] |
B. Zootime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has n observation binoculars located at the OX axis. For each i between 1 and n, inclusive, there exists a single binocular located at the p... | Input5 52 14 13 24 34 4 | Output11 | 2 seconds | 256 megabytes | ['brute force', 'geometry', '*1700'] |
A. Headquarterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from t... | Input3URULULDR | Output9 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*1700'] |
E. Wooden Fencetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has recently bought some land and decided to surround it with a wooden fence.He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products... | Input2 31 22 3 | Output2 | 3 seconds | 256 megabytes | ['dp', '*1800'] |
D. Common Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has recently learned at school what a number's divisor is and decided to determine a string's divisor. Here is what he came up with.String a is the divisor of string b if and only if there exist... | Inputabcdabcdabcdabcdabcdabcd | Output2 | 2 seconds | 256 megabytes | ['brute force', 'hashing', 'implementation', 'math', 'strings', '*1400'] |
C. Optimal Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnd here goes another problem on arrays. You are given positive integer len and array a which consists of n integers a1, a2, ..., an. Let's introduce two characteristics for the given array. Let's consid... | Input5 30 -2 3 -5 12 | Output10 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2000'] |
B. Vasya's Calendartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present β the clock that shows not only the time, but also the date.The clock's face can disp... | Input422 2 | Output2 | 1 second | 256 megabytes | ['implementation', '*1000'] |
A. Battlefieldtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya lagged behind at the University and got to the battlefield. Just joking! He's simply playing some computer game. The field is a flat platform with n trenches dug on it. The trenches are segments on ... | Input2 40 5 6 530 0 0 41 1 4 16 0 6 4 | Output19.0000000000 | 2 seconds | 256 megabytes | ['geometry', 'graphs', 'implementation', 'shortest paths', '*2200'] |
B. Number of Tripletstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points on a plane. All points are different.Find the number of different groups of three points (A,βB,βC) such that point B is the middle of segment AC. The groups of three points a... | Input31 12 23 3 | Output1 | 2 seconds | 256 megabytes | ['binary search', 'brute force', '*1300'] |
A. Series of Crimestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.The Berland capital's map is represented by an nβΓβm rectangular table. Each cell of the tabl... | Input3 2.*..** | Output1 1 | 2 seconds | 256 megabytes | ['brute force', 'geometry', 'implementation', '*800'] |
F. Mathematical Analysis Rocks!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudents of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the stude... | Input42 1 4 33 4 2 1 | Output4 3 1 2 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*1200'] |
E. Cubestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's imagine that you're playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that do not nece... | Input10 3 21 2 1 1 3 2 1 1 2 2 | Output4 | 1 second | 256 megabytes | ['binary search', 'dp', 'two pointers', '*1800'] |
D. Nametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.Two young parents abac and bbad think what name to give to ... | Inputaadaac | Outputaad | 1 second | 256 megabytes | ['greedy', 'strings', '*1900'] |
C. Lettertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPatrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercas... | InputPRuvetSTAaYA | Output5 | 1 second | 256 megabytes | ['dp', '*1400'] |
B. Divisibility Rulestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya studies divisibility rules at school. Here are some of them: Divisibility by 2. A number is divisible by 2 if and only if its last digit is divisible by 2 or in other words, is even. Divisibil... | Input10 10 | Output2-type1 | 1 second | 256 megabytes | ['math', 'number theory', '*2300'] |
A. Defragmentationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you have to implement an algorithm to defragment your hard disk. The hard disk consists of a sequence of clusters, numbered by integers from 1 to n. The disk has m recorded files, the i... | Input7 22 1 23 3 4 5 | Output0 | 1 second | 256 megabytes | ['implementation', '*1800'] |
F3. Representative Samplingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The proble... | Input3 2ababzdabq | Output2 | 2 seconds | 256 megabytes | ['*2500'] |
F2. Representative Samplingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The proble... | Input3 2ababzdabq | Output2 | 2 seconds | 256 megabytes | ['dp', 'sortings', 'strings', '*2200'] |
F1. Representative Samplingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The proble... | Input3 2ababzdabq | Output2 | 2 seconds | 256 megabytes | ['*1800'] |
D3. Magic Squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challen... | Input31 2 3 4 5 6 7 8 9 | Output152 7 69 5 14 3 8 | 2 seconds | 256 megabytes | ['*2100'] |
D2. Magic Squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challen... | Input31 2 3 4 5 6 7 8 9 | Output152 7 69 5 14 3 8 | 2 seconds | 256 megabytes | ['*1900'] |
D1. Magic Squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challen... | Input31 2 3 4 5 6 7 8 9 | Output152 7 69 5 14 3 8 | 2 seconds | 256 megabytes | ['*1500'] |
C3. Smart Beaver and Resolving Collisionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The ... | Input10 2 7+ 11 0+ 22 2+ 33 6+ 44 0+ 55 0- 22+ 66 0 | Output7 | 1 second | 256 megabytes | ['*2000'] |
C2. Smart Beaver and Resolving Collisionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The ... | Input10 2 7+ 11 0+ 22 2+ 33 6+ 44 0+ 55 0- 22+ 66 0 | Output7 | 1 second | 256 megabytes | ['*1900'] |
C1. Smart Beaver and Resolving Collisionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The ... | Input10 2 7+ 11 0+ 22 2+ 33 6+ 44 0+ 55 0- 22+ 66 0 | Output7 | 1 second | 256 megabytes | ['*1600'] |
B3. Greedy Merchantstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n citi... | Input7 81 22 33 44 55 65 73 54 741 52 42 64 7 | Output2120 | 2 seconds | 256 megabytes | ['*1800'] |
B2. Greedy Merchantstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n citi... | Input7 81 22 33 44 55 65 73 54 741 52 42 64 7 | Output2120 | 2 seconds | 256 megabytes | ['*1600'] |
B1. Greedy Merchantstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.The Roman Empire consisted of n citi... | Input7 81 22 33 44 55 65 73 54 741 52 42 64 7 | Output2120 | 2 seconds | 256 megabytes | ['*1600'] |
A3. Educational Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.The playing field is a sequence of n non-negative in... | Input41 0 1 2 | Output113 | 2 seconds | 256 megabytes | ['greedy', '*1100'] |
A2. Educational Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.The playing field is a sequence of n non-negative in... | Input41 0 1 2 | Output113 | 2 seconds | 256 megabytes | ['greedy', '*1000'] |
A1. Educational Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.The playing field is a sequence of n non-negative in... | Input41 0 1 2 | Output113 | 2 seconds | 256 megabytes | ['*1000'] |
G2. Fibonacci Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFibonacci strings are defined as follows: f1 = Β«aΒ» f2 = Β«bΒ» fn = fnβ-β1Β fnβ-β2, nβ>β2 Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".You are given a Fibonacci string... | Input6 5ababbaaba | Output35331 | 2 seconds | 256 megabytes | ['matrices', 'strings', '*2600'] |
G1. Fibonacci Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFibonacci strings are defined as follows: f1 = Β«aΒ» f2 = Β«bΒ» fn = fnβ-β1Β fnβ-β2, nβ>β2 Thus, the first five Fibonacci strings are: "a", "b", "ba", "bab", "babba".You are given a Fibonacci string... | Input6 5ababbaaba | Output35331 | 2 seconds | 256 megabytes | ['strings', '*2400'] |
F2. Script Generationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY was offered a job of a screenwriter for the ongoing TV series. In particular, he needs to automate the hard decision: which main characters will get married by the end o... | Input2 4 31 1 11 2 22 1 32 2 7 | Output2 | 2 seconds | 256 megabytes | ['*2300'] |
F1. Script Generationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Smart Beaver from ABBYY was offered a job of a screenwriter for the ongoing TV series. In particular, he needs to automate the hard decision: which main characters will get married by the end o... | Input2 4 31 1 11 2 22 1 32 2 7 | Output2 | 2 seconds | 256 megabytes | ['*1800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.