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 |
|---|---|---|---|---|---|
A. New Bus Routetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities situated along the main road of Berland. Cities are represented by their coordinates β integer numbers a1,βa2,β...,βan. All coordinates are pairwise distinct.It is possible to get from... | Input46 -3 0 4 | Output2 1 | 1 second | 256 megabytes | ['implementation', 'sortings', '*1100'] |
A. Bear and Big Brothertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is small... | Input4 7 | Output2 | 1 second | 256 megabytes | ['implementation', '*800'] |
B. Masha and geometric depressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMasha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geo... | Input3 2 30 46 14 25 48 | Output3 | 1 second | 256 megabytes | ['brute force', 'implementation', 'math', '*1700'] |
A. Anastasia and pebblestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the ... | Input3 22 3 4 | Output3 | 1 second | 256 megabytes | ['implementation', 'math', '*1100'] |
E. New tasktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the 228-th international Uzhlyandian Wars strategic game tournament teams from each country are called. The teams should consist of 5 participants.The team of Uzhlyandia will consist of soldiers, because ... | Input61 1 1 1 1 121 32 3 | Output16 | 3 seconds | 256 megabytes | ['data structures', '*2900'] |
D. Finding linestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter some programming contest Roma decided to try himself in tourism. His home country Uzhlyandia is a Cartesian plane. He wants to walk along each of the Main Straight Lines in Uzhlyandia. It is known... | Input1132 | Output0 1 20 -2 -20 5 60 -2 21 1 220 -3 | 3 seconds | 256 megabytes | ['constructive algorithms', 'divide and conquer', 'interactive', '*3000'] |
C. The Great Mixingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration . Today, on the party in honour of Sergiy of ... | Input400 4100 300 450 500 | Output2 | 1 second | 256 megabytes | ['dfs and similar', 'graphs', 'shortest paths', '*2300'] |
B. Weird journeytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherlandΒ β Uzhlyandia.It is widely known that Uzhlyandia has n cities connected with m bidirectional ro... | Input5 41 21 31 41 5 | Output6 | 2 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', '*2100'] |
A. Functions againtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSomething happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arri... | Input51 4 2 3 1 | Output3 | 1 second | 256 megabytes | ['dp', 'two pointers', '*1600'] |
B. Not Afraidtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSince the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them. There are n para... | Input4 21 -34 -2 3 2 -3 | OutputYES | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', '*1300'] |
A. The Monstertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b,βbβ+βa,βbβ+β2a,βbβ+β3a,β... and Morty screams at time... | Input20 29 19 | Output82 | 1 second | 256 megabytes | ['brute force', 'math', 'number theory', '*1200'] |
E. ALTtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputALT is a planet in a galaxy called "Encore". Humans rule this planet but for some reason there's no dog in their planet, so the people there are sad and depressed. Rick and Morty are universal philanthropists and... | Input4 52 43 41 42 42 12 41 22 3 | Output31 5 2 3 1 | 4 seconds | 256 megabytes | ['data structures', 'flows', 'graphs', 'trees', '*3200'] |
D. Rap Godtime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRick is in love with Unity. But Mr. Meeseeks also love Unity, so Rick and Mr. Meeseeks are "love rivals". Unity loves rap, so it decided that they have to compete in a rap game (battle) in order to choose the... | Input4 34 1 t3 2 p1 2 s3 21 32 1 | Output011 | 7 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'hashing', 'strings', 'trees', '*3400'] |
C. Till I Collapsetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated n Mr. Meeseeks, standing in a line numbered from 1 to n. Each of them has his own colo... | Input51 3 4 3 3 | Output4 2 1 1 1 | 2 seconds | 256 megabytes | ['data structures', 'divide and conquer', '*2400'] |
B. Legacytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them. There are n planets in their universe num... | Input3 5 12 3 2 3 172 3 2 2 162 2 2 3 33 3 1 1 121 3 3 17 | Output0 28 12 | 2 seconds | 256 megabytes | ['data structures', 'graphs', 'shortest paths', '*2300'] |
A. Berzerktime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.In this game there are n objec... | Input52 3 23 1 2 3 | OutputLose Win Win LoopLoop Win Win Win | 4 seconds | 256 megabytes | ['dfs and similar', 'dp', 'games', '*2000'] |
E. Anton and Permutationtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAnton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1,βa2,β...,βan}, in which every number from 1 to n appea... | Input5 44 52 42 52 2 | Output1433 | 4 seconds | 512 megabytes | ['brute force', 'data structures', '*2200'] |
D. Anton and School - 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of r... | Input)(()() | Output6 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', 'number theory', '*2300'] |
C. Anton and Fairy Taletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:"Once upon a time, there lived an emperor. He was very rich a... | Input5 2 | Output4 | 1 second | 256 megabytes | ['binary search', 'math', '*1600'] |
B. Anton and Classestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes.Anton has n variants when he will attend chess classes, i-th var... | Input31 52 62 322 46 8 | Output3 | 4 seconds | 256 megabytes | ['greedy', 'sortings', '*1100'] |
A. Anton and Polyhedronstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square fa... | Input4IcosahedronCubeTetrahedronDodecahedron | Output42 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*800'] |
G. BF Calculatortime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputIn this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.You are given an arithmetic expression consisting of integers from 0 to 255 and additi... | Input2+3 | Output++>+++><[<+>-]<++++++++++++++++++++++++++++++++++++++++++++++++. | 2 seconds | 64 megabytes | ['*special problem', '*2000'] |
F. Crunching Numbers Just for Youtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the las... | Input3 3 1 2 | Output1 2 3 | 2 seconds | 64 megabytes | ['*special problem', 'implementation', '*1900'] |
E. Twisted Circuittime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output InputThe input consists of four lines, each line containing a single digit 0 or 1.OutputOutput a single digit, 0 or 1.ExampleInput0110Output0 | Input0110 | Output0 | 2 seconds | 64 megabytes | ['*special problem', 'brute force', 'implementation', '*2000'] |
D. Touchy-Feely Palindromestime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputInputThe only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.OutputOutput "Yes" or "No".ExamplesInput373OutputYesInput121OutputNoInput43... | Input373 | OutputYes | 2 seconds | 64 megabytes | ['*special problem', 'implementation', '*1900'] |
C. INTERCALCtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputDO YOU EXPECT ME TO FIND THIS OUT?WHAT BASE AND/XOR LANGUAGE INCLUDES string?DON'T BYTE OF MORE THAN YOU CAN CHEWYOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FARSAYING "ABRACADABRA" WITHOUT A MAGIC AND... | Input42 5 3 1 | Output4 | 2 seconds | 64 megabytes | ['*special problem', 'implementation', '*1800'] |
B. Kids' Riddletime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputProgrammers' kids solve this riddle in 5-10 minutes. How fast can you do it?InputThe input contains a single integer n (0ββ€βnββ€β2000000000).OutputOutput a single integer.ExamplesInput11Output2Input14Outpu... | Input11 | Output2 | 2 seconds | 64 megabytes | ['*special problem', '*2000'] |
A. Numbers Joketime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputInputThe input contains a single integer a (1ββ€βaββ€β30).OutputOutput a single integer.ExampleInput3Output27 | Input3 | Output27 | 2 seconds | 64 megabytes | ['*special problem', '*1700'] |
H. Intranet of Busestime limit per test10 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new bus route is opened in the city . The route is a closed polygon line in the place, with all segments parallel to one of the axes. m buses will operate on the route. All buses move in a loop a... | Input4 20 00 11 11 0 | Output1.000000000 | 10 seconds | 256 megabytes | ['binary search', 'geometry', 'implementation', 'two pointers', '*3100'] |
G. Andryusha and Nervous Barrierstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndryusha has found a perplexing arcade machine. The machine is a vertically adjusted board divided into square cells. The board has w columns numbered from 1 to w from left to right, a... | Input10 5 13 2 3 10 | Output7 | 4 seconds | 256 megabytes | ['data structures', 'dp', '*2700'] |
F. Axel and Marston in Bitlandtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA couple of friends, Axel and Marston are travelling across the country of Bitland. There are n towns in Bitland, with some pairs of towns connected by one-directional roads. Each road in ... | Input2 21 2 02 2 1 | Output3 | 5 seconds | 256 megabytes | ['bitmasks', 'dp', 'graphs', 'matrices', '*2400'] |
E. Underground Labtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediately Andr... | Input3 2 12 13 1 | Output3 2 1 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2100'] |
D. Innokenty and a Football Leaguetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputInnokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the sho... | Input2DINAMO BYTECITYFOOTBALL MOSCOW | OutputYESDINFOO | 2 seconds | 256 megabytes | ['2-sat', 'graphs', 'greedy', 'implementation', 'shortest paths', 'strings', '*1900'] |
C. Andryusha and Colored Balloonstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them.The park consists of n squares connected with (nβ-β1)... | Input32 31 3 | Output31 3 2 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'greedy', 'trees', '*1600'] |
B. The Meeting Place Cannot Be Changedtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.At some p... | Input37 1 31 2 1 | Output2.000000000000 | 5 seconds | 256 megabytes | ['binary search', '*1600'] |
A. Andryusha and Sockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndryusha is an orderly boy and likes to keep things in their place.Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pa... | Input11 1 | Output1 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
C. Dishonest Sellerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIgor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is ai, and after a week of discounts its ... | Input3 15 4 63 1 5 | Output10 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1200'] |
B. Weird Roundingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is crazy about round numbers. He especially likes the numbers divisible by 10k.In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by ... | Input30020 3 | Output1 | 1 second | 256 megabytes | ['brute force', 'greedy', '*1100'] |
A. Pupils Redistributiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Berland each high school student is characterized by academic performance β integer value between 1 and 5.In high school 0xFF there are two groups of pupils: the group A and the group B. Each ... | Input45 4 4 45 5 4 5 | Output1 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1000'] |
E. Selling Numberstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBoris really likes numbers and even owns a small shop selling interesting numbers. He has n decimal numbers Bi. Cost of the number in his shop is equal to the sum of costs of its digits. You are given... | Input4238919580 0 1 1 2 2 3 3 4 4 | Output4 | 2 seconds | 512 megabytes | ['dp', 'sortings', '*3000'] |
D. Parquet Re-layingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPeter decided to lay a parquet in the room of size nβΓβm, the parquet consists of tiles of size 1βΓβ2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter ... | Input2 3ULRDLRLRULRD | Output21 21 1 | 2 seconds | 512 megabytes | ['constructive algorithms', '*2700'] |
C. Peterson Polyglottime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPeterson loves to learn new languages, but his favorite hobby is making new ones. Language is a set of words, and word is a sequence of lowercase Latin letters.Peterson makes new language every morn... | Input51 2 c2 3 a3 4 t2 5 t | Output32 | 4 seconds | 512 megabytes | ['brute force', 'dfs and similar', 'dsu', 'hashing', 'strings', 'trees', '*2500'] |
B. Bitwise Formulatime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.Initially, Bob chooses integer m, bit depth of the game, which m... | Input3 3a := 101b := 011c := ? XOR b | Output011100 | 3 seconds | 512 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'expression parsing', 'implementation', '*1800'] |
A. String Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLittle Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always he... | Inputababcbaabb5 3 4 1 7 6 2 | Output3 | 2 seconds | 512 megabytes | ['binary search', 'greedy', 'strings', '*1700'] |
E. Hanoi Factorytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOf course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Egypt... | Input31 5 12 6 23 7 3 | Output6 | 1 second | 256 megabytes | ['brute force', 'data structures', 'dp', 'greedy', 'sortings', '*2000'] |
D. Cloud of Hashtagstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a li... | Input3#book#bigtown#big | Output#b#big#big | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'implementation', 'strings', '*1800'] |
C. Alyona and Spreadsheettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables.Now she has a table filled with integers. The table consists of n rows and m ... | Input5 41 2 3 53 1 3 24 5 2 35 5 3 24 4 3 461 12 54 53 51 31 5 | OutputYesNoYesYesYesNo | 1 second | 256 megabytes | ['binary search', 'data structures', 'dp', 'greedy', 'implementation', 'two pointers', '*1600'] |
B. Game of Credit Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards.Rules of th... | Input3123321 | Output02 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'sortings', '*1300'] |
A. Shell Gametime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells ... | Input42 | Output1 | 0.5 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*1000'] |
G. Sherlock and the Encrypted Datatime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSherlock found a piece of encrypted data which he thinks will be useful to catch Moriarty. The encrypted data consists of two integer l and r. He noticed that these integers were in he... | Input11014 1014 | Output1 | 2 seconds | 512 megabytes | ['bitmasks', 'combinatorics', 'dp', '*2900'] |
F. Sherlock's bet to Moriartytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSherlock met Moriarty for a final battle of wits. He gave him a regular n sided convex polygon. In addition to it, he gave him certain diagonals to form regions on the polygon. It was guara... | Input4 11 3 | Output1 2 | 2 seconds | 512 megabytes | ['constructive algorithms', 'data structures', 'divide and conquer', 'geometry', 'graphs', 'implementation', 'trees', '*2800'] |
E. The Holmes Childrentime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Holmes children are fighting over who amongst them is the cleverest.Mycroft asked Sherlock and Eurus to find value of f(n), where f(1)β=β1 and for nββ₯β2, f(n) is the number of distinct ordered... | Input7 1 | Output6 | 2 seconds | 256 megabytes | ['math', 'number theory', '*2100'] |
D. The Door Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMoriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are... | Input3 31 0 12 1 32 1 22 2 3 | OutputNO | 2 seconds | 256 megabytes | ['2-sat', 'dfs and similar', 'dsu', 'graphs', '*2000'] |
C. Molly's Chemicalstime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMolly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value ai.Molly wants Sherlock to fall in love with ... | Input4 22 2 2 2 | Output8 | 2.5 seconds | 512 megabytes | ['binary search', 'brute force', 'data structures', 'implementation', 'math', '*1800'] |
B. Sherlock and his girlfriendtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry.He bought n pieces of jewelry. The i-th piece has price equal to iβ+β1, that ... | Input3 | Output21 1 2 | 1 second | 256 megabytes | ['constructive algorithms', 'number theory', '*1200'] |
A. A Serial Killertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOur beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting hi... | Inputross rachel4ross joeyrachel phoebephoebe monicamonica chandler | Outputross racheljoey racheljoey phoebejoey monicajoey chandler | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'strings', '*900'] |
A. University Scheduletime limit per test10 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem your task is to come up with a week schedule of classes in university for professors and student groups. Consider that there are 6 educational days in week and maximum number of c... | Input3 3 11 0 00 1 00 0 1 | Output541 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | 10 seconds | 256 megabytes | ['*special problem', '*2900'] |
L. Barstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.In some minutes of the workday Polycarp has import... | Input3 3010 | Output1 | 2 seconds | 256 megabytes | ['*special problem', 'binary search', '*2000'] |
K. Stepan and Vowelstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".Sergey does not like such behavior, so he wants to write a program to... | Input13pobeeeedaaaaa | Outputpobeda | 1 second | 256 megabytes | ['*special problem', 'implementation', 'strings', '*1600'] |
J. Stepan's Seriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWell, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definite... | Input5 2NYNNY | OutputYES | 2 seconds | 256 megabytes | ['*special problem', 'dp', '*2000'] |
I. Composing Of Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan has a set of n strings. Also, he has a favorite string s. Stepan wants to do the following. He will take some strings of his set and write them down one after another. It is possible that h... | Input3aaaaaaa | Output2 | 2 seconds | 256 megabytes | ['*special problem', 'dp', '*2300'] |
H. Repairing Of Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan had a favorite string s which consisted of the lowercase letters of the Latin alphabet. After graduation, he decided to remember it, but it was a long time ago, so he can't now remember it.... | Input66 3 1 0 0 0 | Outputkkrrrq | 2 seconds | 256 megabytes | ['*special problem', 'constructive algorithms', '*2200'] |
G. Perfectionist Arkadiytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkadiy has lots square photos with size aβΓβa. He wants to put some of them on a rectangular wall with size hβΓβw. The photos which Arkadiy will put on the wall must form a rectangular grid and ... | Input2 18 13 | Output0.5 | 1 second | 256 megabytes | ['*special problem', 'number theory', '*2700'] |
F. Pens And Days Of Weektime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (nβ+β1)-th day again he uses the pen number 1, on the (nβ+β2)-th β he uses the pen number 2 and so... | Input33 3 3 | Output2 | 3 seconds | 256 megabytes | ['*special problem', 'binary search', 'number theory', '*2700'] |
E. Big Number and Remaindertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan has a very big positive integer.Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading... | Input5213 | Output2 | 3 seconds | 256 megabytes | ['*special problem', 'math', 'number theory', '*2300'] |
D. Lie or Truthtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the ri... | Input5 2 43 4 2 3 13 2 3 4 1 | OutputTRUTH | 2 seconds | 256 megabytes | ['*special problem', 'constructive algorithms', 'implementation', 'sortings', '*1500'] |
C. Maximum Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below. So, for example, to ... | Input2 | Output1 | 1 second | 256 megabytes | ['*special problem', 'constructive algorithms', 'greedy', 'implementation', '*1200'] |
B. Significant Cupstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStepan is a very experienced olympiad participant. He has n cups for Physics olympiads and m cups for Informatics olympiads. Each cup is characterized by two parameters β its significance ci and widt... | Input3 1 84 25 54 23 2 | Output8 | 3 seconds | 256 megabytes | ['*special problem', 'binary search', 'data structures', 'two pointers', '*2100'] |
A. Amusement Parktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.Tickets f... | Input3 4 1011 | Output8 | 2 seconds | 256 megabytes | ['*special problem', 'ternary search', '*2100'] |
F. Test Data Generationtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTest data generation is not an easy task! Often, generating big random test cases is not enough to ensure thorough testing of solutions for correctness.For example, consider a problem from an old... | Input3 6 100000 | Output4 | 5 seconds | 256 megabytes | ['combinatorics', 'divide and conquer', 'dp', 'fft', 'math', 'number theory', '*3400'] |
E. Blog Post Ratingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's well-known that blog posts are an important part of Codeforces platform. Every blog post has a global characteristic changing over timeΒ β its community rating. A newly created blog post's commun... | Input42 0 2 2 | Output1122 | 4 seconds | 256 megabytes | ['data structures', 'sortings', '*3000'] |
D. Perishable Roadstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as roads! No two roads int... | Input31 23 | Output223 | 3 seconds | 256 megabytes | ['dp', 'graphs', 'shortest paths', '*2700'] |
C. Prairie Partitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt can be shown that any positive integer x can be uniquely represented as xβ=β1β+β2β+β4β+β...β+β2kβ-β1β+βr, where k and r are integers, kββ₯β0, 0β<βrββ€β2k. Let's call that representation prairie par... | Input81 1 2 2 3 4 5 8 | Output2 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'math', '*2200'] |
B. Dynamic Problem Scoringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya and Petya take part in a Codeforces round. The round lasts for two hours and contains five problems.For this round the dynamic problem scoring is used. If you were lucky not to participa... | Input25 15 40 70 11550 45 40 30 15 | Output2 | 2 seconds | 256 megabytes | ['brute force', 'greedy', '*2000'] |
A. Success Ratetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Co... | Input43 10 1 27 14 3 820 70 2 75 6 1 1 | Output4100-1 | 2 seconds | 256 megabytes | ['binary search', 'math', '*1700'] |
E. Verifying Kingdomtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.The judge has a hidden rooted full binary tree with n leaves. A full binary tree is one where every node has either 0 or 2 children. The nodes with 0 children are call... | Input5XZYYX | Output1 4 21 2 42 4 12 3 52 4 3-1-1 1 1 2 2 3 3 6 6 | 2 seconds | 256 megabytes | ['binary search', 'divide and conquer', 'interactive', 'trees', '*3200'] |
D. Varying Kibibitstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a1,βa2,β...,βan. Denote this list of integers as T.Let f(L) be a function that takes in a non-empty list of integers L.The function will output another integer as follows: ... | Input3123 321 555 | Output292711924 | 3 seconds | 256 megabytes | ['bitmasks', 'dp', '*2700'] |
C. Vulnerable Kerbalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer m, and a list of n distinct integers between 0 and mβ-β1.You would like to construct a sequence satisfying the properties: Each element is an integer between 0 and mβ-β1, ... | Input0 5 | Output51 2 4 3 0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'graphs', 'math', 'number theory', '*2300'] |
B. Volatile Kitetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a convex polygon P with n distinct vertices p1,βp2,β...,βpn. Vertex pi has coordinates (xi,βyi) in the 2D plane. These vertices are listed in clockwise order.You can choose a real number D... | Input40 00 11 11 0 | Output0.3535533906 | 2 seconds | 256 megabytes | ['geometry', '*1800'] |
A. Voltage Keepsaketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n devices that you want to use simultaneously.The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The... | Input2 12 22 1000 | Output2.0000000000 | 2 seconds | 256 megabytes | ['binary search', 'math', '*1800'] |
F. Bear and Isomorphic Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBearland is a big square on the plane. It contains all points with coordinates not exceeding 106 by the absolute value.There are n houses in Bearland. The i-th of them is located at the poi... | Input445 30 110 13 513-999123 700000-950000 123456-950000 98765432 310 -1-4 651 35 26 14 4-3 3 | Output250.000000000000100000000000.0000000000000.0000000000006.562500000000 | 2 seconds | 256 megabytes | ['geometry', 'two pointers', '*3300'] |
E. Bear and Rectangle Stripstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLimak has a grid that consists of 2 rows and n columns. The j-th cell in the i-th row contains an integer ti,βj which can be positive, negative or zero.A non-empty rectangle of cells is call... | Input670 70 70 70 70 -1590 -60 -30 30 -30 15 | Output3 | 3 seconds | 256 megabytes | ['dp', 'greedy', '*3000'] |
D. Bear and Companytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some ... | Input4VKVK | Output3 | 1 second | 256 megabytes | ['dp', '*2500'] |
C. Bear and Tree Jumpstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.Limak is a little polar bear. He lives in a tree that... | Input6 21 21 32 42 54 6 | Output20 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'trees', '*2100'] |
B. Bear and Different Namestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen i... | Input8 3NO NO YES YES YES NO | OutputAdam Bob Bob Cpqepqwer Limak Adam Bob Adam | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1500'] |
A. Bear and Friendship Conditiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).There are n members, numb... | Input4 31 33 41 4 | OutputYES | 1 second | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', '*1500'] |
D. Draw Brackets!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence of square brackets is regular if by inserting symbols "+" and "1" into it, you can get a regular mathematical expression from it. For example, sequences "[[]][]", "[]" and "[[][[]]]" β are re... | Input8[[][]][] | Output+- -++- -+|+- -++- -+|| ||| || ||| ||+- -++- -+|| |+- -++- -+ | 1 second | 256 megabytes | ['*special problem', 'implementation', '*1400'] |
C. Online Courses In BSUtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow you can take online courses in the Berland State University! Polycarp needs to pass k main online courses of his specialty to get a diploma. In total n courses are availiable for the passage... | Input6 25 30002 2 11 41 5 | Output51 2 3 4 5 | 2 seconds | 256 megabytes | ['*special problem', 'dfs and similar', 'graphs', 'implementation', '*1500'] |
B. Maximize Sum of Digitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.Your task is to help Anton and to find the integer that interests him. If t... | Input100 | Output99 | 1 second | 256 megabytes | ['*special problem', 'implementation', 'math', '*1300'] |
A. New Passwordtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInnokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should ... | Input4 3 | Outputjava | 1 second | 256 megabytes | ['*special problem', 'implementation', '*800'] |
D. k-Interesting Pairs Of Integerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. Fo... | Input4 10 3 2 1 | Output4 | 2 seconds | 256 megabytes | ['*special problem', 'bitmasks', 'brute force', 'meet-in-the-middle', '*1700'] |
C. Cycle In Mazetime limit per test15 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Robot is in a rectangular maze of size nβΓβm. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right... | Input2 3 2.**X.. | OutputRL | 15 seconds | 256 megabytes | ['*special problem', 'dfs and similar', 'graphs', 'greedy', 'shortest paths', '*1700'] |
B. News About Credittime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp studies at the university in the group which consists of n students (including himself). All they are registrated in the social net "TheContacnt!".Not all students are equally sociable. Abou... | Input41 2 1 0 | Output31 22 42 3 | 1 second | 256 megabytes | ['*special problem', 'greedy', 'two pointers', '*1200'] |
A. Year of University Entrancetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entr... | Input32014 2016 2015 | Output2015 | 1 second | 256 megabytes | ['*special problem', 'implementation', 'sortings', '*800'] |
G. The Winds of Wintertime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGiven a rooted tree with n nodes. The Night King removes exactly one node from the tree and all the edges associated with it. Doing this splits the tree and forms a forest. The node which is remov... | Input100 11 21 31 42 52 63 74 84 95 10 | Output3455599999 | 2 seconds | 512 megabytes | ['binary search', 'data structures', '*3300'] |
F. Barrels and boxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or ... | Input1 1 1 | Output0 | 2 seconds | 256 megabytes | ['brute force', 'combinatorics', 'math', 'number theory', 'probabilities', '*2300'] |
E. Game of Stonestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: The game starts with n piles of sto... | Input15 | OutputNO | 3 seconds | 256 megabytes | ['bitmasks', 'dp', 'games', '*2100'] |
D. Jon and Orbstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree n... | Input1 11 | Output1 | 2 seconds | 256 megabytes | ['dp', 'math', 'probabilities', '*2200'] |
C. Jon Snow and his Favourite Numbertime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walke... | Input5 1 29 7 11 15 5 | Output13 7 | 4 seconds | 256 megabytes | ['brute force', 'dp', 'implementation', 'sortings', '*1800'] |
B. Code For 1time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so h... | Input7 2 5 | Output4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'divide and conquer', '*1600'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.