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. Game Outcometime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSherlock Holmes and Dr. Watson played some game on a checkered board nβΓβn in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now ov... | Input11 | Output0 | 2 seconds | 256 megabytes | ['brute force', '*800'] |
E. Mrs. Hudson's Pancakestime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMrs. Hudson hasn't made her famous pancakes for quite a while and finally she decided to make them again. She has learned m new recipes recently and she can't wait to try them. Those recipes ar... | Input1112 ? 1 | Output2 | 5 seconds | 256 megabytes | ['brute force', 'dp', '*3000'] |
D. Cluestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That i... | Input2 0 1000000000 | Output1 | 2 seconds | 256 megabytes | ['combinatorics', 'graphs', '*2500'] |
C. Ciphertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher... | Input1ab | Output1 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', '*2000'] |
B. Suspectstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and n... | Input1 1+1 | OutputTruth | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'implementation', '*1600'] |
A. Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "a... | Inputaaaaaaaa | Output0 | 2 seconds | 256 megabytes | ['brute force', '*1700'] |
B. Combinationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya plays a card game by the following rules.A player has several cards. Each card contains two non-negative integers inscribed, one at the top of the card and one at the bottom. At the beginning of the ... | Input21 02 0 | Output2 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1100'] |
A. I_love_%username%time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.One day Vasya decided to... | Input5100 50 200 150 200 | Output2 | 2 seconds | 256 megabytes | ['brute force', '*800'] |
E. Martian Colonytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe first ship with the Earth settlers landed on Mars. The colonists managed to build n necessary structures on the surface of the planet (which can be regarded as a plane, and the construction can be ... | Input3 50.00 0.0000.0 8.006 8.00 | Output78.5398163397 | 4 seconds | 256 megabytes | ['geometry', '*3000'] |
D. Flatland Fencingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage ... | Input0 2 0 4 | OutputFIRST2 | 2 seconds | 256 megabytes | ['games', 'math', '*2400'] |
C. Double Profilestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user.The social network contains ... | Input3 31 22 31 3 | Output3 | 3 seconds | 256 megabytes | ['graphs', 'hashing', 'sortings', '*2300'] |
B. Colliderstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBy 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activating several ... | Input10 10+ 6+ 10+ 5- 10- 5- 6+ 10+ 3+ 6+ 3 | OutputSuccessConflict with 6SuccessAlready offSuccessSuccessSuccessSuccessConflict with 10Already on | 2 seconds | 256 megabytes | ['math', 'number theory', '*1600'] |
A. Hometasktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as... | Inputababa1ab | Output2 | 2 seconds | 256 megabytes | ['greedy', '*1600'] |
E. Euclidean Distancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a multiset of points on the plane with integer coordinates. Find the maximum distance between two points from this multiset.InputThe first line of input contains the number of points ... | Input3012345 | Output5.656854249 | 2 seconds | 256 megabytes | ['*special problem', '*2100'] |
D. Date Changetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a date in "DD.MM.YYYY" ("day.month.year") format and a number of days shift you have to add to this date. Output the resulting date.InputThe first line of input contains the date in "DD.MM.Y... | Input10.02.201212 | Output22.02.2012 | 2 seconds | 256 megabytes | ['*special problem', '*2000'] |
C. Caesar Ciphertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCaesar cipher is one of the simplest encryption techniques. To transform the original message into encrypted one using key k, one has to replace each letter with a letter which is k positions later in t... | InputCODEFORCES5 | OutputHTIJKTWHJX | 2 seconds | 256 megabytes | ['*special problem', '*2200'] |
B. 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', '*1800'] |
A. A + Btime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers A and B. Calculate their sum and output it without leading zeros.InputTwo lines of input data contain integers A and B (1ββ€βA,βBββ€β105).OutputOutput Aβ+βB without leading zeros.Exampl... | Input123 | Output15 | 2 seconds | 256 megabytes | ['*special problem', '*1600'] |
E. Gardentime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a very beautiful country garden that can be represented as an nβΓβm rectangular field divided into nΒ·m squares. One beautiful day Vasya remembered that he needs to pave roads between k important squa... | Input3 3 21 2 31 2 31 2 31 23 3 | Output9.X..X..XX | 2 seconds | 256 megabytes | ['bitmasks', 'dp', 'graphs', 'trees', '*2500'] |
D. Framestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vasya got hold of a sheet of checkered paper nβΓβm squares in size. Our Vasya adores geometrical figures, so he painted two rectangles on the paper. The rectangles' sides are parallel to the coordinate... | Input4 5######.#.####.###### | OutputYES1 1 3 31 1 4 5 | 2 seconds | 256 megabytes | ['brute force', '*2600'] |
C. Pocket Booktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly m letters long. Let's number the names from 1 to n in the order in which they ... | Input2 3AABBAA | Output4 | 2 seconds | 256 megabytes | ['combinatorics', '*1400'] |
B. Stepstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vasya went out for a walk in the yard but there weren't any of his friends outside and he had no one to play touch and run. But the boy didn't lose the high spirits and decided to play touch and run wit... | Input4 51 131 11 10 -2 | Output4 | 2 seconds | 256 megabytes | ['binary search', 'implementation', '*1300'] |
A. Markstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.Overall the group has n students. They received marks for m subjects. E... | Input3 3223232112 | Output2 | 1 second | 256 megabytes | ['implementation', '*900'] |
B. Phone Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWinters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for e... | Input42 Fedorov22-22-2298-76-543 Melnikov75-19-0923-45-6799-99-987 Rogulenko22-22-2211-11-1133-33-3344-44-4455-55-5566-66-6695-43-213 Kaluzhin11-11-1199-99-9998-65-32 | OutputIf you want to call a taxi, you should call: Rogulenko.If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin.If you want to go to a cafe with a wonderful girl, you should call: Melnikov. | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1200'] |
A. Soft Drinkingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c li... | Input3 4 5 10 8 100 3 1 | Output2 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
E. Freezing with Styletime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis winter is so... well, you've got the idea :-) The Nvodsk road system can be represented as n junctions connected with nβ-β1 bidirectional roads so that there is a path between any two junctio... | Input6 3 41 2 12 3 13 4 14 5 15 6 1 | Output4 1 | 7 seconds | 256 megabytes | ['binary search', 'data structures', 'divide and conquer', 'trees', '*3000'] |
D. Mission Impassabletime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarket stalls now have the long-awaited game The Colder Scrools V: Nvodsk. The game turned out to be difficult as hell and most students can't complete the last quest ("We don't go to Nvodsk..."). ... | Input7-1 -1 -1 -1 -1 -1 -1abacaba | Output0 | 3 seconds | 256 megabytes | ['dp', 'strings', '*2600'] |
C. Smart Cheatertime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputI guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increased the popularity of the public transport dramatically. The route of bus 62 has exactly n stops (stop ... | Input3 3 100 10 100100 01 22 31 3 | Output90.000000000 | 5 seconds | 256 megabytes | ['data structures', 'math', 'probabilities', '*2200'] |
B. Quantity of Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJust in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the... | Input1 1 1 | Output1 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'graphs', 'math', '*1600'] |
A. Win or Freezetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should writ... | Input6 | Output2 | 2 seconds | 256 megabytes | ['games', 'math', 'number theory', '*1400'] |
E. Martian Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the study of the Martians Petya clearly understood that the Martians are absolutely lazy. They like to sleep and don't like to wake up. Imagine a Martian who has exactly n eyes located in a row... | InputABCBABA2BAABABBA | Output1 | 2 seconds | 256 megabytes | ['string suffix structures', 'strings', '*2300'] |
D. Coloring Bracketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Petya read a problem about a bracket sequence. He gave it much thought but didn't find a solution. Today you will face it.You are given string s. It represents a correct bracket sequence. A cor... | Input(()) | Output12 | 2 seconds | 256 megabytes | ['dp', '*1900'] |
C. Division into Teamstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have so... | Input31 2 1 | Output21 2 13 | 1 second | 256 megabytes | ['greedy', 'math', 'sortings', '*1500'] |
B. Martian Clocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaving stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" β you can say that, of course, but don't be too harsh on the kid. In his country fil... | Input11:20 | Output3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 2 seconds | 256 megabytes | ['implementation', '*1600'] |
A. Business triptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhat joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until...... | Input51 1 1 1 2 2 3 2 2 1 1 1 | Output2 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'sortings', '*900'] |
E. Porcelaintime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.The collection of porcelain is arranged neatly on n shelves. Within each... | Input2 33 3 7 23 4 1 5 | Output15 | 1 second | 256 megabytes | ['dp', '*1900'] |
D. Bag of micetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should... | Input1 3 | Output0.500000000 | 2 seconds | 256 megabytes | ['dp', 'games', 'math', 'probabilities', '*1800'] |
C. Terse princesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputΒ«Next pleaseΒ», β the princess called and cast an estimating glance at the next groom.The princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more... | Input10 2 3 | Output5 1 3 6 16 35 46 4 200 99 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1700'] |
B. Escapetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe princess is going to escape the dragon's cave, and she needs to plan it carefully.The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape afte... | Input121110 | Output2 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1500'] |
A. Insomnia curetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputΒ«One dragon. Two dragon. Three dragonΒ», β the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.However, just counting dragons was boring as we... | Input123412 | Output12 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*800'] |
B. Smile Housetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA smile house is created to raise the mood. It has n rooms. Some of the rooms are connected by doors. For each two rooms (number i and j), which are connected by a door, Petya knows their value cij β the ... | Input4 41 2 -10 31 3 1 -102 4 -10 -13 4 0 -3 | Output4 | 3 seconds | 256 megabytes | ['binary search', 'graphs', 'matrices', '*2500'] |
A. Punctuationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.Y... | Inputgalileo galilei was an italian physicist ,mathematician,astronomer | Outputgalileo galilei was an italian physicist, mathematician, astronomer | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1300'] |
B. Lucky Masktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 1... | Input1 7 | Output7 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1300'] |
A. Lucky Tickettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5,... | Input247 | OutputNO | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Lucky Queriestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5... | Input2 347countswitch 1 2count | Output21 | 3 seconds | 256 megabytes | ['data structures', '*2400'] |
D. Lucky Pairtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 1... | Input41 4 2 4 | Output9 | 2 seconds | 256 megabytes | ['combinatorics', 'data structures', 'implementation', '*2900'] |
C. Lucky Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky a... | Input3 210 10 10 | Output3 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', '*2100'] |
B. Lucky Number 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and ... | Input2 2 1 1 | Output4774 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1800'] |
A. Lucky Conversiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky an... | Input4774 | Output1 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1200'] |
E. Competitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe secondary diagonal of a square matrix is a diagonal going from the top right to the bottom left corner. Let's define an n-degree staircase as a square matrix nβΓβn containing no squares above the seco... | Input3 32 33 23 3 | Output31 2 3 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2200'] |
D. Missile Silostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to ... | Input4 6 11 2 11 3 32 3 12 4 13 4 11 4 22 | Output3 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'shortest paths', '*1900'] |
C. Anagram Searchtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and... | Inputbb??x???aab | Output2 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1500'] |
B. Meetingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table... | Input2 5 4 233 1 25 3 11 3 2 | Output4 | 2 seconds | 256 megabytes | ['implementation', '*1300'] |
A. Arrival of the Generaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldier... | Input433 44 11 22 | Output2 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
B. Help Kingdom of Far Far Away 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert nu... | Input2012 | Output$2,012.00 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1200'] |
A. Help Vasilisa the Wise 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wis... | Input3 74 65 5 | Output1 23 4 | 2 seconds | 256 megabytes | ['brute force', 'math', '*1000'] |
E. Help Greg the Dwarf 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGreg the Dwarf has been really busy recently with excavations by the Neverland Mountain. However for the well-known reasons (as you probably remember he is a very unusual dwarf and he cannot sta... | Input2 21.0 0.0 0.0-1.0 0.0 0.0 | Output2.000000000 | 2 seconds | 256 megabytes | ['geometry', '*3000'] |
D. Help Shrek and Donkey 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaving learned (not without some help from the Codeforces participants) to play the card game from the previous round optimally, Shrek and Donkey (as you may remember, they too live now in the... | Input2 3 1R-GRG- | OutputFirst | 2 seconds | 256 megabytes | ['games', '*2600'] |
C. Help Caretakertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAutumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to so... | Input3 3 | Output1AAA.A..A. | 3 seconds | 256 megabytes | ['brute force', 'dp', '*2300'] |
B. Help Generaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstra... | Input2 4 | Output4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*1800'] |
A. Help Farmertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam s... | Input4 | Output28 41 | 1 second | 256 megabytes | ['brute force', 'math', '*1600'] |
E. Clearing Uptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter Santa Claus and his assistant Elf delivered all the presents and made all the wishes come true, they returned to the North Pole and found out that it is all covered with snow. Both of them were quit... | Input1 21 1 S1 1 M | Output0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'dsu', 'graphs', '*2300'] |
D. Take-off Rampstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya participates in a ski race along the X axis. The start is at point 0, and the finish is at L, that is, at a distance L meters from the start in the positive direction of the axis. Vasya has been ... | Input2 205 10 5 54 16 1 7 | Output1511 | 4 seconds | 256 megabytes | ['graphs', 'shortest paths', '*2300'] |
C. Queuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how many people who ... | Input4a 0b 2c 0d 0 | Outputa 150c 170d 180b 160 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1800'] |
B. Hopscotchtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSo nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game fi... | Input1 0 0 | Output-1 | 2 seconds | 256 megabytes | ['geometry', 'math', '*1400'] |
A. Amusing Joketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSo, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters f... | InputSANTACLAUSDEDMOROZSANTAMOROZDEDCLAUS | OutputYES | 2 seconds | 256 megabytes | ['implementation', 'sortings', 'strings', '*800'] |
F. New Year Snowflaketime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Gerald ..., in other words, on a New Year Eve Constantine prepared an unusual present for the Beautiful Lady. The present is the magic New Year snowflake that can make any dream come true.The New... | Input4 00 00 11 01 1 | Output10.5 0.5 | 1 second | 256 megabytes | ['geometry', 'sortings', '*2600'] |
E. New Year Garlandtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent New Year Tree must be decorated with a good garlan... | Input3 2 10003 1 2 | Output8 | 5 seconds | 256 megabytes | ['combinatorics', 'dp', '*2600'] |
D. New Year Contesttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Gerald sets the table, Alexander sends the greeting cards, and Sergey and his twins create an army of clone snowmen, Gennady writes a New Year contest.The New Year contest begins at 18:00 (6.00 P.... | Input330 330 720 | Output2 10 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1800'] |
C. New Year Snowmentime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's t... | Input71 2 3 4 5 6 7 | Output23 2 16 5 4 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', '*1800'] |
B. New Year Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander... | Input41 2 3 44 1 3 24 3 1 23 4 2 13 1 2 4 | Output2 1 1 4 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', '*1800'] |
A. New Year Tabletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those gu... | Input4 10 4 | OutputYES | 2 seconds | 256 megabytes | ['geometry', 'math', '*1700'] |
B. Wallpapertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaving bought his own apartment, Boris decided to paper the walls in every room. Boris's flat has n rooms, each of which has the form of a rectangular parallelepiped. For every room we known its length, wid... | Input15 5 3310 1 10015 2 3203 19 500 | Output640 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1600'] |
A. Petr and Booktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got... | Input10015 20 20 15 10 30 45 | Output6 | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
E. Hellish Constraintstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKatya recently started to invent programming tasks and prepare her own contests. What she does not like is boring and simple constraints. Katya is fed up with all those "N does not exceed a thousa... | Inputcodeforces2 0 0o 1 2e 1 2 | Output7 | 3 seconds | 256 megabytes | ['brute force', 'dp', 'two pointers', '*2900'] |
D. World of Darkrafttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Roma has become the happy owner of a new game World of Darkraft. This game combines elements of virtually all known genres, and on one of the later stages of the game Roma faced difficultie... | Input2 2RLLR | OutputLOSE | 2 seconds | 256 megabytes | ['dp', 'games', '*2500'] |
C. Mushroom Gnomes - 2time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Natalia was walking in the woods when she met a little mushroom gnome. The gnome told her the following story:Everybody knows that the mushroom gnomes' power lies in the magic mushrooms tha... | Input1 12 2 50 501 1 | Output0.5000000000 | 1 second | 256 megabytes | ['binary search', 'data structures', 'probabilities', 'sortings', '*2200'] |
B. Digits Permutationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.Then Andrey got bored from looking at the ... | Input198 | Output981819 | 1 second | 256 megabytes | ['greedy', '*1900'] |
A. Literature Lessontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.Let's consider that all lines in the poems consist of low... | Input1 1daymaysunfun | Outputaabb | 2 seconds | 256 megabytes | ['implementation', '*1600'] |
E. Last Chancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaving read half of the book called "Storm and Calm" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw In... | InputAbo | Output3 1 | 2 seconds | 256 megabytes | ['data structures', 'implementation', 'strings', '*2000'] |
D. Palindromestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFriday is Polycarpus' favourite day of the week. Not because it is followed by the weekend, but because the lessons on Friday are 2 IT lessons, 2 math lessons and 2 literature lessons. Of course, Polycarp... | Inputabacaba1 | Output0abacaba | 2 seconds | 256 megabytes | ['dp', 'strings', '*1900'] |
C. Historytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus likes studying at school a lot and he is always diligent about his homework. Polycarpus has never had any problems with natural sciences as his great-great-grandfather was the great physicist Seins... | Input51 102 93 84 75 6 | Output4 | 2 seconds | 256 megabytes | ['sortings', '*1500'] |
B. Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output"Hey, it's homework time" β thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to s... | Input33 1 2 | Output0 | 2 seconds | 256 megabytes | ['greedy', '*1000'] |
A. Postcards and photostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes fro... | InputCPCPCPC | Output7 | 2 seconds | 256 megabytes | ['implementation', '*900'] |
B. Ternary Logictime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic.... | Input14 34 | Output50 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1100'] |
A. Presentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving someb... | Input42 3 4 1 | Output4 1 2 3 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Weak Subsequencetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes strings. Recently he has received a voucher to purchase a string as a gift from his mother. The string can be bought in the local shop. One can consider that the shop has... | Input2 2 | Output10 | 3 seconds | 256 megabytes | ['combinatorics', '*3000'] |
D. Cycletime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes rectangular tables that consist of characters "0" and "1". Recently he has received one such table as a gift from his mother. The table contained n rows and m columns. The rows are ... | Input3 3111101111 | Output8 | 3 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'implementation', '*2500'] |
C. Zero-Onetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him.Before the very ... | Input???? | Output00011011 | 2 seconds | 256 megabytes | ['constructive algorithms', 'games', 'greedy', '*1900'] |
B. Rectangle and Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split ... | Input0 010 1110 00 111 12 22 11 2 | OutputYES5 6 7 81 2 3 4 | 2 seconds | 256 megabytes | ['brute force', 'geometry', 'math', '*1600'] |
A. Replacementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't l... | Input51 2 3 4 5 | Output1 1 2 3 4 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'sortings', '*1300'] |
C. Swapstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n players sitting at a round table. All of them have s cards of n colors in total. Besides, initially the first person had cards of only the first color, the second one had cards of only the second co... | Input4 82 2 2 2 | OutputYes44 34 21 31 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', '*2200'] |
B. Pairs of Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's assume that we have a pair of numbers (a,βb). We can get a new pair (aβ+βb,βb) or (a,βaβ+βb) from the given pair in a single step.Let the initial pair of numbers be (1,1). Your task is to find n... | Input5 | Output3 | 1 second | 256 megabytes | ['brute force', 'dfs and similar', 'math', 'number theory', '*1900'] |
A. Average Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of positive integers a1,βa2,β...,βan. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one)... | Input51 2 3 4 5 | Output13 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1200'] |
B. Unarytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUnary is a minimalistic Brainfuck dialect in which programs are written using only one token. Brainfuck programs use 8 commands: "+", "-", "[", "]", "<", ">", "." and "," (their meaning is not important for the... | Input,. | Output220 | 2 seconds | 256 megabytes | ['implementation', '*1200'] |
A. 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 source code of the program itself, "9" prints the lyrics of "99 Bottles of Beer" son... | InputHi! | OutputYES | 2 seconds | 256 megabytes | ['implementation', '*900'] |
E. Bits of merry old Englandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnother feature of Shakespeare language is that the variables are named after characters of plays by Shakespeare, and all operations on them (value assignment, output etc.) look like a dialo... | Input7 21 2 2 4 2 1 2 | Output11 4b=1print(b)a=2print(a)print(a)b=4print(b)print(a)b=1print(b)print(a) | 2 seconds | 256 megabytes | ['flows', 'graphs', '*2700'] |
D. Constants in the language of Shakespearetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputShakespeare is a widely known esoteric programming language in which programs look like plays by Shakespeare, and numbers are given by combinations of ornate epithets. In this... | Input1111 | Output2+2^4-2^0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', '*2100'] |
C. Logo Turtletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward").You... | InputFT1 | Output2 | 2 seconds | 256 megabytes | ['dp', '*1800'] |
B. Piettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPiet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will us... | Input2 101243 | Output1 | 2 seconds | 256 megabytes | ['implementation', '*2100'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.