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 |
|---|---|---|---|---|---|
B. Biridian Foresttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest.The forestThe Biridian Forest is a two-dim... | Input5 7000E0T3T0TT0T0010T0T02T0T0T00T0S000 | Output3 | 2 seconds | 256 megabytes | ['dfs and similar', 'shortest paths', '*1500'] |
A. Purificationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an nāĆān grid. The rows are numbered 1 ... | Input3.E.E.E.E. | Output1 12 23 3 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1500'] |
B. Sheldon and Ice Piecestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDo you remember how Kai constructed the word "eternity" using pieces of ice as components?Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to c... | Input4223454 | Output2 | 1 second | 256 megabytes | ['greedy', '*1500'] |
A. IQ Testtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.Arit... | Input836 624 412 200 | Output-12 | 1 second | 256 megabytes | ['implementation', '*1800'] |
E. Axis Walkingtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIahub wants to meet his girlfriend Iahubina. They both live in Ox axis (the horizontal axis). Iahub lives at point 0 and Iahubina at point d.Iahub has n positive integers a1, a2, ..., an. The sum of thos... | Input32 3 525 7 | Output1 | 3 seconds | 512 megabytes | ['bitmasks', 'combinatorics', 'constructive algorithms', 'dp', 'meet-in-the-middle', '*2300'] |
D. Block Towertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter too much playing on paper, Iahub has switched to computer games. The game he plays is called "Block Towers". It is played in a rectangular grid with n rows and m columns (it contains nāĆām cells). T... | Input2 3..#.#. | Output4B 1 1R 1 2R 2 1B 2 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*1900'] |
C. Magic Fivetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a long plate s containing n digits. Iahub wants to delete some digits (possibly none, but he is not allowed to delete all the digits) to form his "magic number" on the plate, a number that is divis... | Input12561 | Output4 | 1 second | 256 megabytes | ['combinatorics', 'math', '*1700'] |
B. Hungry Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of n integers. A... | Input3 | Output2 9 15 | 1 second | 256 megabytes | ['math', '*1200'] |
A. Flipping Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub got bored, so he invented a game to be played on paper. He writes n integers a1,āa2,ā...,āan. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indice... | Input51 0 0 1 0 | Output4 | 1 second | 256 megabytes | ['brute force', 'dp', 'implementation', '*1200'] |
E. The Red Buttontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPiegirl found the red button. You have one last chance to change the inevitable end.The circuit under the button consists of n nodes, numbered from 0 to n - 1. In order to deactivate the button, the n n... | Input2 | Output0 1 0 | 1 second | 256 megabytes | ['combinatorics', 'dfs and similar', 'dsu', 'graphs', 'greedy', '*2800'] |
D. Reclamationtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn a far away land, there exists a planet shaped like a cylinder. There are three regions in this planet: top, bottom, and side as shown in the following picture. Both the top and the bottom areas consis... | Input3 4 92 23 22 33 43 11 32 11 11 4 | Output6 | 5 seconds | 512 megabytes | ['dsu', '*2900'] |
C. Monsters and Diamondstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPiegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie... | Input6 41 3 -1 1 -11 2 -1 -12 3 -1 3 -12 3 -1 -1 -13 2 -1 -14 2 4 -1 | Output2 -23 42 2-1 -1 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'shortest paths', '*2600'] |
B. Stadium and Gamestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDaniel is organizing a football tournament. He has come up with the following tournament format: In the first several (possibly zero) stages, while the number of teams is even, they split in pairs ... | Input3 | Output34 | 1 second | 256 megabytes | ['binary search', 'math', '*1800'] |
A. Square and Rectanglestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (th... | Input50 0 2 30 3 3 52 0 5 23 2 5 52 2 3 3 | OutputYES | 1 second | 256 megabytes | ['implementation', '*1500'] |
C. Two permutationstime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two permutations p and q, consisting of n elements, and m queries of the form: l1,ār1,āl2,ār2 (l1āā¤ār1;Ā l2āā¤ār2). The response for the query is the number of such integers from 1 to n, ... | Input33 1 23 2 111 2 3 3 | Output1 | 6 seconds | 512 megabytes | ['data structures', '*2400'] |
B. Tournament-graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you have to build tournament graph, consisting of n vertices, such, that for any oriented pair of vertices (v,āu) (vāā āu) there exists a path from vertex v to vertex u consisting of no... | Input3 | Output0 1 00 0 11 0 0 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', '*2200'] |
A. Black-and-White Cubetime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a cube of size kāĆākāĆāk, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.Your task is to paint each of k3 unit cubes one of two... | Input1 | Output-1 | 0.5 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', '*1600'] |
B. Ciel and Flowerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets: To make a "red bouquet", it needs... | Input3 6 9 | Output6 | 1 second | 256 megabytes | ['combinatorics', 'math', '*1600'] |
A. Ciel and Dancingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl ... | Input2 1 | Output21 12 1 | 1 second | 256 megabytes | ['greedy', '*1000'] |
E. Ciel and Gondolastime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFox Ciel is in the Amusement Park. And now she is in a queue in front of the Ferris wheel. There are n people (or foxes more precisely) in the queue: we use first people to refer one at the head of ... | Input5 20 0 1 1 10 0 1 1 11 1 0 0 01 1 0 0 01 1 0 0 0 | Output0 | 4 seconds | 512 megabytes | ['data structures', 'divide and conquer', 'dp', '*2600'] |
D. Ciel and Flipboardtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has a board with n rows and n columns, there is one integer in each cell.It's known that n is an odd number, so let's introduce . Fox Ciel can do the following operation many times: she ch... | Input3-1 -1 1-1 1 -11 -1 -1 | Output9 | 4 seconds | 256 megabytes | ['dp', 'greedy', 'math', '*2900'] |
C. Ciel the Commandertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by nā-ā1 undirected roads, and for any two cities there always exists a path between them.Fox Cie... | Input41 21 31 4 | OutputA B B B | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'divide and conquer', 'greedy', 'trees', '*2100'] |
B. Ciel and Dueltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel is playing a card game with her friend Jiro.Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too... | Input2 3ATK 2000DEF 1700250025002500 | Output3000 | 2 seconds | 256 megabytes | ['dp', 'flows', 'greedy', '*1900'] |
A. Ciel and Robottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four m... | Input2 2RU | OutputYes | 1 second | 256 megabytes | ['binary search', 'implementation', 'math', '*1700'] |
B. Ping-Pong (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem at each moment you have a set of intervals. You can move from interval (a,āb) from our set to interval (c,ād) from our set if and only if cā<āaā<ād or cā<ābā<ād. Also there is... | Input51 1 51 5 112 1 21 2 92 1 2 | OutputNOYES | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*1500'] |
A. Magic Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 41... | Input114114 | OutputYES | 2 seconds | 256 megabytes | ['brute force', 'greedy', '*900'] |
E. Ping-Pongtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem at each moment you have a set of intervals. You can move from interval (a,āb) from our set to interval (c,ād) from our set if and only if cā<āaā<ād or cā<ābā<ād. Also there is a path from in... | Input51 1 51 5 112 1 21 2 92 1 2 | OutputNOYES | 2 seconds | 256 megabytes | ['data structures', '*3000'] |
D. Have You Ever Heard About the Word?time limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA substring of a string is a contiguous subsequence of that string. So, string bca is substring of string abcabc, but string cc is not.A repeating block is a string formed by conca... | Inputabccabc | Outputabc | 6 seconds | 256 megabytes | ['greedy', 'hashing', 'string suffix structures', 'strings', '*2800'] |
C. Kalila and Dimna in the Logging Industrytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money. The manager of logging factory wants them to g... | Input51 2 3 4 55 4 3 2 0 | Output25 | 2 seconds | 256 megabytes | ['dp', 'geometry', '*2100'] |
B. Psychos in a Linetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right ... | Input1010 9 7 8 6 5 3 4 2 1 | Output2 | 1 second | 256 megabytes | ['data structures', 'implementation', '*1900'] |
A. Malek Dance Clubtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan C... | Input11 | Output6 | 1 second | 256 megabytes | ['combinatorics', 'math', '*1600'] |
B. Strings of Powertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVolodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.Volodya calls a string powerful if it start... | Inputheavymetalisheavymetal | Output3 | 2 seconds | 256 megabytes | ['implementation', 'strings', 'two pointers', '*1300'] |
A. Even Oddstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBeing a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. ... | Input10 3 | Output5 | 1 second | 256 megabytes | ['math', '*900'] |
E. Princess and Her Shadowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPrincess Vlada enjoys springing in the meadows and walking in the forest. One day ā wonderful, sunny day ā during her walk Princess found out with astonishment that her shadow was missing! "Bli... | Input0 0 1 0 10 1 | OutputLLUR | 1 second | 256 megabytes | ['constructive algorithms', 'shortest paths', '*3100'] |
D. Game with Powerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya and Petya wrote down all integers from 1 to n to play the "powers" game (n can be quite large; however, Vasya and Petya are not confused by this fact).Players choose numbers in turn (Vasya choos... | Input1 | OutputVasya | 1 second | 256 megabytes | ['dp', 'games', '*2300'] |
C. Balancetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA system of n vessels with water is given. Several pairs of vessels are connected by tubes with transfusion mechanisms. One may transfer an integer amount of liters of water between two vessels connected by su... | Input2 10 11 95 51 2 | Output12 1 4 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'trees', '*2500'] |
B. Antstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: every minute at each junction (x, y) containing at least four ants a group... | Input1 30 10 00 -1 | Output010 | 1 second | 256 megabytes | ['brute force', 'implementation', '*2000'] |
A. Perfect Pairtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.Two integer... | Input1 2 5 | Output2 | 1 second | 256 megabytes | ['brute force', '*1600'] |
G3. Good Substringstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses ... | Inputaaab2aa 0 0aab 1 1 | Output3 | 4 seconds | 256 megabytes | ['string suffix structures', '*2400'] |
G2. Good Substringstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses ... | Inputaaab2aa 0 0aab 1 1 | Output3 | 4 seconds | 256 megabytes | ['string suffix structures', '*2200'] |
G1. Good Substringstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses ... | Inputaaab2aa 0 0aab 1 1 | Output3 | 4 seconds | 256 megabytes | ['hashing', 'strings', '*1700'] |
E3. Summer Homeworktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBy the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:You are given a sequence of integers a1,āa2,ā...,āan. Your task is to perform ... | Input5 51 3 1 2 42 1 42 1 52 2 41 3 102 1 5 | Output1232850 | 3 seconds | 256 megabytes | ['data structures', 'math', '*2300'] |
E2. Summer Homeworktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBy the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:You are given a sequence of integers a1,āa2,ā...,āan. Your task is to perform ... | Input5 51 3 1 2 42 1 42 1 52 2 41 3 102 1 5 | Output1232850 | 3 seconds | 256 megabytes | ['data structures', 'math', '*2300'] |
E1. Summer Homeworktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBy the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:You are given a sequence of integers a1,āa2,ā...,āan. Your task is to perform ... | Input5 51 3 1 2 42 1 42 1 52 2 41 3 102 1 5 | Output1232850 | 3 seconds | 256 megabytes | ['brute force', 'data structures', '*1500'] |
D3. PE Lessontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One o... | Input51 2 2 1 2 | Output120 | 3 seconds | 256 megabytes | ['dp', 'math', '*2400'] |
D2. PE Lessontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One o... | Input51 2 2 1 2 | Output120 | 3 seconds | 256 megabytes | ['dp', '*2300'] |
D1. PE Lessontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One o... | Input51 2 2 1 2 | Output120 | 3 seconds | 256 megabytes | ['brute force', 'dp', '*2300'] |
C2. Tidying Uptime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver is careful about his appearance and pays special attention to shoes so he has a huge number of pairs of shoes from the most famous brands of the forest. He's trying to handle his shoes carefu... | Input2 31 1 22 3 3 | Output2 | 4 seconds | 256 megabytes | ['flows', 'graph matchings', '*2300'] |
C1. Tidying Uptime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmart Beaver is careful about his appearance and pays special attention to shoes so he has a huge number of pairs of shoes from the most famous brands of the forest. He's trying to handle his shoes carefu... | Input2 31 1 22 3 3 | Output2 | 4 seconds | 256 megabytes | ['flows', '*2200'] |
B2. EKGtime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, runn... | Input6 12 0 4 0 6 0 | Output246 | 0.5 seconds | 256 megabytes | ['dfs and similar', 'dp', '*1600'] |
B1. EKGtime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, runn... | Input6 12 0 4 0 6 0 | Output246 | 0.5 seconds | 256 megabytes | ['brute force', 'dfs and similar', '*1500'] |
A2. Special Tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpecial Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and o... | InputAJ | Output81 | 1 second | 256 megabytes | ['math', '*1400'] |
A1. Special Tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpecial Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and o... | InputAJ | Output81 | 1 second | 256 megabytes | ['greedy', '*1100'] |
B. Sereja and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja has got an array, consisting of n integers, a1,āa2,ā...,āan. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms: Make vi-th a... | Input10 111 2 3 4 5 6 7 8 9 103 23 92 103 13 101 1 102 102 103 13 103 9 | Output291120304039 | 1 second | 256 megabytes | ['implementation', '*1200'] |
A. Sereja and Bottlestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.Sereja knows ... | Input41 12 23 34 4 | Output4 | 2 seconds | 256 megabytes | ['brute force', '*1400'] |
E. Sereja and Squarestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja painted n points on the plane, point number i (1āā¤āiāā¤ān) has coordinates (i,ā0). Then Sereja marked each point with a small or large English letter. Sereja don't like letter "x", so he didn... | Input4a??? | Output50 | 4 seconds | 256 megabytes | ['dp', '*2900'] |
D. Sereja and Straight Linestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja placed n points on a plane. Now Sereja wants to place on the plane two straight lines, intersecting at a right angle, so that one of the straight lines intersect the Ox axis at an ang... | Input40 02 00 22 2 | Output0.000000000000000 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'geometry', 'sortings', 'two pointers', '*2500'] |
C. Sereja and Subsequencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja has a sequence that consists of n positive integers, a1,āa2,ā...,āan. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence... | Input142 | Output42 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*2000'] |
B. Sereja and Periodstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's introduce the designation , where x is a string, n is a positive integer and operation "ā+ā" is the string concatenation operation. For example, [abc,ā2]ā=āabcabc.We'll say that string s can b... | Input10 3ababbab | Output3 | 1 second | 256 megabytes | ['binary search', 'dfs and similar', 'strings', '*2000'] |
A. Sereja and Contesttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let'... | Input5 05 3 4 1 2 | Output234 | 2 seconds | 256 megabytes | ['implementation', '*1600'] |
E. Ilya and Two Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya has recently taken up archaeology. He's recently found two numbers, written in the m-based notation. Each of the found numbers consisted of exactly n digits. Ilya immediately started looking... | Input4 75 4 3 25 6 5 4 | Output6 4 2 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'dsu', 'greedy', '*2300'] |
D. Ilya and Roadstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.Ily... | Input10 4 67 9 116 9 137 7 73 5 6 | Output17 | 3 seconds | 256 megabytes | ['dp', '*2100'] |
C. Ilya and Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.He's got a square 2nāĆā2n-siz... | Input113 | Output13 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'sortings', '*1400'] |
B. Ilya and Queriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.You've got string sā=ās1s2... sn (n is the length of the string), consisti... | Input......43 42 31 62 6 | Output1154 | 2 seconds | 256 megabytes | ['dp', 'implementation', '*1100'] |
A. Ilya and Bank Accounttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a... | Input2230 | Output2230 | 2 seconds | 256 megabytes | ['implementation', 'number theory', '*900'] |
B. Archertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is for SmallR while fo... | Input1 2 1 2 | Output0.666666666667 | 2 seconds | 256 megabytes | ['math', 'probabilities', '*1300'] |
A. Whose sentence is it?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience,... | Input5I will go to play with you lala.wow, welcome.miao.lala.miao.miao . | OutputFreda'sOMG>.< I don't know!OMG>.< I don't know!Rainbow'sOMG>.< I don't know! | 2 seconds | 256 megabytes | ['implementation', 'strings', '*1100'] |
E. Biologisttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSmallR is a biologist. Her latest research finding is how to change the sex of dogs. In other words, she can change female dogs into male dogs and vice versa.She is going to demonstrate this technique. No... | Input5 5 90 1 1 1 01 8 6 2 30 7 3 3 2 1 11 8 1 5 11 0 3 2 1 4 10 8 3 4 2 1 01 7 2 4 1 1 | Output2 | 1.5 seconds | 256 megabytes | ['flows', '*2300'] |
D. Interval Cubingtime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile learning Computational Geometry, Tiny is simultaneously learning a useful data structure called segment tree or interval tree. He has scarcely grasped it when comes out a strange problem:Given a... | Input81 2 3 4 5 6 7 851 2 52 2 51 2 52 3 61 4 7 | Output142242215492 | 6 seconds | 256 megabytes | ['data structures', 'math', '*2600'] |
C. Fetch the Treasuretime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRainbow built h cells in a row that are numbered from 1 to h from left to right. There are n cells with treasure. We call each of these n cells "Treasure Cell". The i-th "Treasure Cell" is the ai-t... | Input10 3 5 25 507 608 1002 2 531 333 | Output5510050 | 3 seconds | 256 megabytes | ['brute force', 'data structures', 'graphs', 'shortest paths', '*2500'] |
B. Cats Transporttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance... | Input4 6 21 3 51 02 14 91 102 103 12 | Output3 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*2400'] |
A. The Closest Pairtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCurrently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepte... | Input4 3 | Output0 00 11 01 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*1300'] |
E. Sheeptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInformation technologies are developing and are increasingly penetrating into all spheres of human activity. Incredible as it is, the most modern technology are used in farming!A large farm has a meadow with gra... | Input31 35 72 4 | Output1 3 2 | 1 second | 256 megabytes | ['binary search', 'greedy', '*2900'] |
D. Tennis Racketstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputProfessional sport is more than hard work. It also is the equipment, designed by top engineers. As an example, let's take tennis. Not only should you be in great shape, you also need an excellent racke... | Input3 0 | Output9 | 3 seconds | 256 megabytes | ['brute force', 'geometry', '*2700'] |
C. Memory for Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou get to work and turn on the computer. You start coding and give little thought to the RAM role in the whole process. In this problem your task is to solve one of the problems you encounter in yo... | Input5 38 4 3 2 23 2 2 | Output2 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'greedy', '*1900'] |
B. Context Advertisingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAdvertising has become part of our routine. And now, in the era of progressive technologies, we need your ideas to make advertising better!In this problem we'll look at a simplified version of con... | Input9 4 12this is a sample text for croc final round | Outputthis is asample textfor crocfinal round | 2 seconds | 256 megabytes | ['dp', 'two pointers', '*2100'] |
A. Morning runtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeople like to be fit. That's why many of them are ready to wake up at dawn, go to the stadium and run. In this problem your task is to help a company design a new stadium. The city of N has a shabby old ... | Input2 5 10 2 | Output0.2500000000 | 2 seconds | 256 megabytes | ['binary search', 'math', 'two pointers', '*2000'] |
D. Polygontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus loves convex polygons, especially if all their angles are the same and all their sides are different. Draw for him any such polygon with the given number of vertexes.InputThe input contains a single... | Input8 | Output1.000 0.0007.000 0.0009.000 2.0009.000 3.0005.000 7.0003.000 7.0000.000 4.0000.000 1.000 | 1 second | 256 megabytes | ['constructive algorithms', 'geometry', '*2300'] |
C. White, Black and White Againtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill... | Input3 2 1 | Output2 | 3 seconds | 256 megabytes | ['combinatorics', 'number theory', '*2100'] |
B. Optimizertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA process RAM is a sequence of bytes that are indexed from 1 to n. Polycarpus's program contains such instructions as "memset", that is, the operations of filling memory cells on a segment with some value. ... | Input10 43 33 14 19 2 | Output22 3 | 3 seconds | 256 megabytes | ['data structures', 'greedy', 'sortings', '*2100'] |
A. Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus has got n candies and m friends (nāā„ām). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that i... | Input12 3 | Output4 4 4 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Playing with Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo people play the following string game. Initially the players have got some string s. The players move in turns, the player who cannot make a move loses. Before the game began, the string is wr... | Inputabacaba | OutputFirst2 | 2 seconds | 256 megabytes | ['games', '*2300'] |
D. Olya and Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlya has got a directed non-weighted graph, consisting of n vertexes and m edges. We will consider that the graph vertexes are indexed from 1 to n in some manner. Then for any graph edge that goes from... | Input7 8 21 22 33 43 64 54 75 66 7 | Output2 | 2 seconds | 256 megabytes | ['combinatorics', 'math', '*2200'] |
C. Ivan and Powers of Twotime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan has got an array of n non-negative integers a1,āa2,ā...,āan. Ivan knows that the array is sorted in the non-decreasing order. Ivan wrote out integers 2a1,ā2a2,ā...,ā2an on a piece of pap... | Input40 1 1 1 | Output0 | 0.5 seconds | 256 megabytes | ['greedy', 'implementation', '*1600'] |
B. Continued Fractionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA continued fraction of height n is a fraction of form . You are given two rational numbers, one is represented as and the other one is represented as a finite fraction of height n. Check if they... | Input9 422 4 | OutputYES | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'math', '*1700'] |
A. Strange Additiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUnfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot... | Input4100 10 1 0 | Output40 1 10 100 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', '*1600'] |
B. Calendartime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCalendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified th... | Input1900:01:012038:12:31 | Output50768 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1300'] |
A. Pythagorean Theorem IItime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn mathematics, the Pythagorean theorem ā is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states: In any right-angled triangle, the ... | Input5 | Output1 | 3 seconds | 256 megabytes | ['brute force', 'math', '*1200'] |
E. Random Rankingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputImagine a real contest or exam of n participants. Every participant will get a particular score. We can predict the standings board more or less, if we do some statistics on their previous performance.... | Input21 64 9 | Output0.9200000000 0.080 0.080 0.9200000000 | 2 seconds | 256 megabytes | ['dp', 'math', 'probabilities', '*3000'] |
D. Rotatable Numbertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBike is a smart boy who loves math very much. He invented a number called "Rotatable Number" inspired by 142857. As you can see, 142857 is a magic number because any of its rotatings can be got by mu... | Input6 11 | Output10 | 2 seconds | 256 megabytes | ['math', 'number theory', '*2600'] |
C. Minimum Modulartime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have been given n distinct integers a1,āa2,ā...,āan. You can remove at most k of them. Find the minimum modular m (mā>ā0), so that for every pair of the remaining integers (ai,āaj), the following ... | Input7 00 2 3 6 7 12 18 | Output13 | 2 seconds | 256 megabytes | ['brute force', 'graphs', 'math', 'number theory', '*2400'] |
B. Rectangle Puzzle IItime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangle grid. That grid's size is nāĆām. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates ā a pair of integers (x,āy) (0āā¤āxāā¤ān,ā... | Input9 9 5 5 2 1 | Output1 3 9 7 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1700'] |
A. Lucky Permutation Tripletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (nā-ā1) appears exactly once in it. For example, [0,ā2,ā1] is a permutati... | Input5 | Output1 4 3 2 01 0 2 4 32 4 0 1 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*1300'] |
B. Eugeny and Play Listtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of ti minutes. Eugeny listens to each song, perhaps more than once. He listens to son... | Input1 22 81 16 | Output11 | 2 seconds | 256 megabytes | ['binary search', 'implementation', 'two pointers', '*1200'] |
A. Eugeny and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEugeny has array aā=āa1,āa2,ā...,āan, consisting of n integers. Each integer ai equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers li, ri (1āā¤āliāā¤āriāā¤ān). ... | Input2 31 -11 11 22 2 | Output010 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Yaroslav and Arrangementstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav calls an array of r integers a1,āa2,ā...,āar good, if it meets the following conditions: |a1ā-āa2|ā=ā1,ā|a2ā-āa3|ā=ā1,ā...,ā|arā-ā1ā-āar|ā=ā1,ā|arā-āa1|ā=ā1, at that . An array of i... | Input1 1 1 | Output0 | 3 seconds | 256 megabytes | ['dp', '*2800'] |
D. Yaroslav and Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav has an array pā=āp1,āp2,ā...,āpn (1āā¤āpiāā¤ān), consisting of n distinct integers. Also, he has m queries: Query number i is represented as a pair of integers li, ri (1āā¤āliāā¤āriāā¤ān). ... | Input1 111 1 | Output1 | 2 seconds | 256 megabytes | ['data structures', '*2200'] |
C. Yaroslav and Algorithmtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav likes algorithms. We'll describe one of his favorite algorithms. The algorithm receives a string as the input. We denote this input string as a. The algorithm consists of some number... | Input21079 | Output10<>1179<>80 | 2 seconds | 256 megabytes | ['constructive algorithms', '*2500'] |
B. Yaroslav and Timetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has n clo... | Input3 100010000 00 10 3 | Output2000 | 2 seconds | 256 megabytes | ['binary search', 'graphs', 'shortest paths', '*2100'] |
A. Yaroslav and Sequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYaroslav has an array, consisting of (2Ā·nā-ā1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can sele... | Input250 50 50 | Output150 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.