problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 β | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
C. Civilizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew plays a game called "Civilization". Dima helps him.The game has n cities and m bidirectional roads. The cities are numbered from 1 to n. Between any pair of cities there either is a single (unique)... | Input6 0 62 1 22 3 42 5 62 3 22 5 31 1 | Output4 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'dsu', 'ternary search', 'trees', '*2100'] |
B. A Lot of Gamestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.Given a group of n non-empty strings. During the game two players build the word together, initially the ... | Input2 3ab | OutputFirst | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'games', 'implementation', 'strings', 'trees', '*1900'] |
A. Boredomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.Given a sequence a consisting of n integers. The play... | Input21 2 | Output2 | 1 second | 256 megabytes | ['dp', '*1500'] |
B. Little Pony and Sort by Shifttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Twilight Sparkle is interested in how to sort a sequence of integers a1,βa2,β...,βan in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit ... | Input22 1 | Output1 | 1 second | 256 megabytes | ['implementation', '*1200'] |
A. Little Pony and Crystal Minetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; nβ>β1) is an nβΓβn matrix with a diamond inscribed into it.You are given an odd integer n. You nee... | Input3 | Output*D*DDD*D* | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Little Pony and Lord Tirektime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLord Tirek is a centaur and the main antagonist in the season four finale episodes in the series "My Little Pony: Friendship Is Magic". In "Twilight's Kingdom" (Part 1), Tirek escapes from ... | Input50 10 10 12 10 20 10 12 10 10 125 1 519 1 5 | Output2558 | 3 seconds | 256 megabytes | ['data structures', '*3100'] |
D. Little Pony and Elements of Harmonytime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Elements of Harmony are six supernatural artifacts representing subjective aspects of harmony. They are arguably the most powerful force in Equestria. The inside of Elements of... | Input2 2 100004 1 2 30 1 0 | Output146614 | 6 seconds | 256 megabytes | ['dp', 'matrices', '*3000'] |
C. Little Pony and Summer Sun Celebrationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to wa... | Input3 21 22 31 1 1 | Output31 2 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2200'] |
B. Little Pony and Harmony Chesttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPrincess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony. A sequence of positive integers bi is harmony if and only if for every two e... | Input51 1 1 1 1 | Output1 1 1 1 1 | 4 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', '*2000'] |
A. Little Pony and Expected Maximumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in t... | Input6 1 | Output3.500000000000 | 1 second | 256 megabytes | ['probabilities', '*1600'] |
F. Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation of numbers from 1 to n. Determine whether there's a pair of integers a,βb (1ββ€βa,βbββ€βn;Β aββ βb) such that the element (note, that it is usual division, not integer one) is betw... | Input41 3 4 2 | OutputNO | 1 second | 256 megabytes | ['data structures', 'divide and conquer', 'hashing', '*2700'] |
E. Three stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three strings (s1,βs2,βs3). For each integer l (1ββ€βlββ€βmin(|s1|,β|s2|,β|s3|) you need to find how many triples (i1,βi2,βi3) exist such that three strings sk[ik... ikβ+βlβ-β1] (kβ=β1,β2,β3... | Inputabcbccbc | Output3 1 | 2 seconds | 256 megabytes | ['data structures', 'dsu', 'string suffix structures', 'strings', '*2400'] |
D. Washer, Dryer, Foldertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n1 washing machines, n2 drying machines and n3 folding machines. Each machine can proc... | Input1 1 1 1 5 5 5 | Output15 | 1 second | 256 megabytes | ['greedy', 'implementation', '*1900'] |
C. Magic Tricktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex enjoys performing magic tricks. He has a trick that requires a deck of n cards. He has m identical decks of n different cards each, which have been mixed together. When Alex wishes to perform the tric... | Input2 2 | Output0.6666666666666666 | 1 second | 256 megabytes | ['combinatorics', 'math', 'probabilities', '*2100'] |
B. 4-point polylinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular grid of lattice points from (0,β0) to (n,βm) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touchin... | Input1 1 | Output1 10 01 00 1 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'geometry', 'trees', '*1800'] |
A. Eeveetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can... | Input7j...... | Outputjolteon | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*1000'] |
E. Devu and Flowerstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hence they are indistinguishable).... | Input2 31 3 | Output2 | 4 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'number theory', '*2300'] |
D. Count Good Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after the merging step it will become "aba... | Inputbb | Output1 2 | 2 seconds | 256 megabytes | ['math', '*2000'] |
C. Predict Outcome of the Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but recently you missed the whole ... | Input53 0 0 03 3 0 06 4 1 06 3 3 03 3 3 2 | Outputyesyesyesnono | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'math', '*1700'] |
B. Sort the Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.Unfortunately, the size of a is too small. You want a bigger array!... | Input33 2 1 | Outputyes1 3 | 1 second | 256 megabytes | ['implementation', 'sortings', '*1300'] |
A. Game With Stickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks.An intersection point is any point... | Input2 2 | OutputMalvika | 1 second | 256 megabytes | ['implementation', '*900'] |
B. Jzzhu and Sequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu has invented a kind of sequences, they meet the following property:You are given x and y, please calculate fn modulo 1000000007 (109β+β7).InputThe first line contains two integers x and y (|x... | Input2 33 | Output1 | 1 second | 256 megabytes | ['implementation', 'math', '*1300'] |
A. Jzzhu and Childrentime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.Jzzhu asks children to... | Input5 21 3 1 4 2 | Output4 | 1 second | 256 megabytes | ['implementation', '*1000'] |
E. Jzzhu and Squarestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu has two integers, n and m. He calls an integer point (x,βy) of a plane special if 0ββ€βxββ€βn and 0ββ€βyββ€βm. Jzzhu defines a unit square as a square with corners at points (x,βy), (xβ+β1,βy), (x... | Input41 32 22 53 4 | Output382658 | 3 seconds | 256 megabytes | ['dp', 'math', 'number theory', '*2900'] |
D. Jzzhu and Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu have n non-negative integers a1,βa2,β...,βan. We will call a sequence of indexes i1,βi2,β...,βik (1ββ€βi1β<βi2β<β...β<βikββ€βn) a group of size k. Jzzhu wonders, how many groups exists such that... | Input32 3 3 | Output0 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', '*2400'] |
C. Jzzhu and Applestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to an apple store. Jzzhu will pack his apples into groups and then sell them. Each... | Input6 | Output26 32 4 | 1 second | 256 megabytes | ['constructive algorithms', 'number theory', '*2500'] |
B. Jzzhu and Citiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (a... | Input5 5 31 2 12 3 21 3 33 4 41 5 53 54 55 5 | Output2 | 2 seconds | 256 megabytes | ['graphs', 'greedy', 'shortest paths', '*2000'] |
A. Jzzhu and Chocolatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJzzhu has a big rectangular chocolate bar that consists of nβΓβm unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: each cut should be straight ... | Input3 4 1 | Output6 | 1 second | 256 megabytes | ['greedy', 'math', '*1700'] |
E. Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBizon the Champion isn't just friendly, he also is a rigorous coder.Let's define function f(a), where a is a sequence of integers. Function f(a) returns the following sequence: first all divisors of a1 go in... | Input6 1 | Output1 2 3 6 | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'implementation', 'number theory', '*2200'] |
D. Multiplication Tabletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBizon the Champion isn't just charming, he also is very smart.While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n... | Input2 2 2 | Output2 | 1 second | 256 megabytes | ['binary search', 'brute force', '*1800'] |
C. Painting Fencetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputBizon the Champion isn't just attentive, he also is very hardworking.Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a... | Input52 2 1 2 1 | Output3 | 1 second | 512 megabytes | ['divide and conquer', 'dp', 'greedy', '*1900'] |
B. Suffix Structurestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letter... | Inputautomatontomat | Outputautomaton | 1 second | 256 megabytes | ['implementation', 'strings', '*1400'] |
A. Rewardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBizon the Champion is called the Champion for a reason. Bizon the Champion has recently got a present β a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be... | Input1 1 11 1 14 | OutputYES | 1 second | 256 megabytes | ['implementation', '*800'] |
B. DZY Loves Stringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string sβ=βs1s2... s|s| (|s| is the length of the strin... | Inputabc31 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | Output41 | 1 second | 256 megabytes | ['greedy', 'implementation', '*1000'] |
A. DZY Loves Hashtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY has a hash table with p buckets, numbered from 0 to pβ-β1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket num... | Input10 5021534153 | Output4 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. DZY Loves Bridgestime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDZY owns 2m islands near his home, numbered from 1 to 2m. He loves building bridges to connect the islands. Every bridge he builds takes one day's time to walk across.DZY has a strange rule of build... | Input2 1 41 1 1 2 | Output1 | 5 seconds | 512 megabytes | ['math', 'matrices', '*3100'] |
D. DZY Loves Gamestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday DZY begins to play an old game. In this game, he is in a big maze with n rooms connected by m corridors (each corridor allows to move in both directions). You can assume that all the rooms are c... | Input5 5 30 0 1 0 11 22 33 44 51 2 | Output0.25000000 | 2 seconds | 256 megabytes | ['math', 'matrices', 'probabilities', '*2800'] |
C. DZY Loves Fibonacci Numberstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1β=β1;Β F2β=β1;Β Fnβ=βFnβ-β1β+βFnβ-β2Β (nβ>β2).DZY loves Fibonacci numbers very much. Today ... | Input4 41 2 3 41 1 42 1 41 2 42 1 3 | Output1712 | 4 seconds | 256 megabytes | ['data structures', 'math', 'number theory', '*2400'] |
B. DZY Loves Modificationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs we know, DZY loves playing games. One day DZY decided to play with a nβΓβm matrix. To be more precise, he decided to modify the matrix with exactly k operations.Each modification is one of t... | Input2 2 2 21 32 4 | Output11 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'greedy', '*2000'] |
A. DZY Loves Sequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY has a sequence a, consisting of n integers.We'll call a sequence ai,βaiβ+β1,β...,βaj (1ββ€βiββ€βjββ€βn) a subsegment of the sequence a. The value (jβ-βiβ+β1) denotes the length of the subsegment.Y... | Input67 2 3 1 5 6 | Output5 | 1 second | 256 megabytes | ['dp', 'implementation', 'two pointers', '*1600'] |
B. DZY Loves Chemistrytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves chemistry, and he enjoys mixing chemicals.DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, ... | Input1 0 | Output1 | 1 second | 256 megabytes | ['dfs and similar', 'dsu', 'greedy', '*1400'] |
A. DZY Loves Chessboardtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves chessboard, and he enjoys playing with it.He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a ches... | Input1 1. | OutputB | 1 second | 256 megabytes | ['dfs and similar', 'implementation', '*1200'] |
E. DZY Loves Plantingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves planting, and he enjoys solving tree problems.DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the functi... | Input41 2 12 3 23 4 31111 | Output2 | 3 seconds | 256 megabytes | ['binary search', 'dsu', 'trees', '*2700'] |
D. DZY Loves Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves strings, and he enjoys collecting them.In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh.Once DZY found a lucky string s. A lot o... | Inputxudyhduxyz3xyz xyzdyh xyzdzy xyz | Output38-1 | 3 seconds | 256 megabytes | ['binary search', 'hashing', 'strings', 'two pointers', '*2500'] |
C. DZY Loves Colorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves colors, and he enjoys painting.On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of the i-th unit of the... | Input3 31 1 2 41 2 3 52 1 3 | Output8 | 2 seconds | 256 megabytes | ['data structures', '*2400'] |
B. DZY Loves FFTtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves Fast Fourier Transformation, and he enjoys using it.Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are... | Input3 1 1 | Output132 | 1 second | 256 megabytes | ['probabilities', '*2300'] |
A. DZY Loves Physicstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as foll... | Input1 01 | Output0.000000000000000 | 1 second | 256 megabytes | ['greedy', 'math', '*1600'] |
B. Kolya and Tandem Repeattime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.Then Borya came and said that the new strin... | Inputaaba2 | Output6 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'strings', '*1500'] |
A. Anton and Letterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved ... | Input{a, b, c} | Output3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
E. Gena and Second Distancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGena doesn't like geometry, so he asks you to solve this problem for him.A rectangle with sides parallel to coordinate axes contains n dots. Let's consider some point of the plane. Let's coun... | Input5 5 40 05 00 55 5 | Output4.99999999941792340 | 2 seconds | 256 megabytes | ['geometry', '*3100'] |
D. Adam and Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Adam gets a rooted tree (connected non-directed graph without cycles), he immediately starts coloring it. More formally, he assigns a color to each edge of the tree so that it meets the following t... | Input111 1 1 3 4 4 7 3 7 6 6 | Output1 1 1 1 1 2 2 2 2 2 3 | 2 seconds | 256 megabytes | ['data structures', 'trees', '*2600'] |
C. Artem and Array time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArtem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he ... | Input53 1 5 2 6 | Output11 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2500'] |
B. Andrey and Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value fo... | Input40.1 0.2 0.3 0.8 | Output0.800000000000 | 2 seconds | 256 megabytes | ['greedy', 'math', 'probabilities', '*1800'] |
A. Borya and Hanabitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.Overall, the game has 25 types of cards (5 distinct colors and 5 distinct ... | Input2G3 G3 | Output0 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'implementation', '*1700'] |
E. Valera and Numbertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below://input: integers x, k, pa = x;for(step = 1; step <= k; step = step + 1){ rnd = [random integ... | Input1 1 50 | Output1.0000000000000 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', 'math', 'probabilities', '*2400'] |
D. Valera and Swapstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation p of length n is a sequence of distinct integers p1,βp2,β...,βpn (1ββ€βpiββ€βn). A permutation is an identity permutation, if for any i the following equation holds piβ=βi. A swap (i,βj) i... | Input51 2 3 4 52 | Output21 2 1 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dsu', 'graphs', 'implementation', 'math', 'string suffix structures', '*2100'] |
C. Valera and Tubes time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns β starting from one, from left to right. We w... | Input3 3 3 | Output3 1 1 1 2 1 33 2 1 2 2 2 33 3 1 3 2 3 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'implementation', '*1500'] |
B. Valera and Fruitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera loves his garden, where n fruit trees grow.This year he will enjoy a great harvest! On the i-th tree bi fruit grow, they will ripen on a day number ai. Unfortunately, the fruit on the tree get... | Input2 31 52 3 | Output8 | 1 second | 256 megabytes | ['greedy', 'implementation', '*1400'] |
A. Valera and Antique Itemstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera is a collector. Once he wanted to expand his collection with exactly one antique item.Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction pric... | Input3 500001 400002 20000 600003 10000 70000 190000 | Output31 2 3 | 1 second | 256 megabytes | ['implementation', '*1000'] |
D. Berland Federalizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a state which includes... | Input5 21 22 33 44 5 | Output12 | 1 second | 256 megabytes | ['dp', 'trees', '*2200'] |
C. One-Based Arithmetictime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputProf. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+β1. Help h... | Input121 | Output6 | 0.5 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'divide and conquer', '*1800'] |
B. Balancertime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a ma... | Input61 6 2 5 3 7 | Output12 | 0.5 seconds | 256 megabytes | ['greedy', 'implementation', '*1600'] |
A. Forgotten Episodetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom "Graph Theory". In total, the season has n episodes, numbered with integers from 1 to n.Polycarpus w... | Input103 8 10 1 7 9 6 5 2 | Output4 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Devu and Birthday Celebrationtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he ... | Input56 27 26 36 47 4 | Output2691020 | 5 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', '*2100'] |
D. Devu and his Brothertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to hi... | Input2 22 33 5 | Output3 | 1 second | 256 megabytes | ['binary search', 'sortings', 'ternary search', 'two pointers', '*1700'] |
C. Devu and Partitioning of the Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came up with an interesting question which he could not solve, can you please sol... | Input5 5 32 6 10 5 9 | OutputYES1 91 51 101 61 2 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'number theory', '*1700'] |
B. Devu, the Dumb Guytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the ith subject has ci chapters. When you teach him, you are supposed to teach all the chapters of a su... | Input2 34 1 | Output11 | 1 second | 256 megabytes | ['implementation', 'sortings', '*1200'] |
A. Devu, the Singer and Churu, the Jokertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Ch... | Input3 302 2 1 | Output5 | 1 second | 256 megabytes | ['greedy', 'implementation', '*900'] |
E. The Child and Binary Treetime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOur child likes computer science very much, especially he likes binary trees.Consider the sequence of n distinct positive integers: c1,βc2,β...,βcn. The child calls a vertex-weighted rooted ... | Input2 31 2 | Output139 | 7 seconds | 256 megabytes | ['combinatorics', 'divide and conquer', 'fft', 'number theory', '*3100'] |
D. The Child and Sequencetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAt the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks.Fortun... | Input5 51 2 3 4 52 3 5 43 3 51 2 52 1 3 31 1 3 | Output85 | 4 seconds | 256 megabytes | ['data structures', 'math', '*2300'] |
E. The Child and Polygontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements: each vertex of ... | Input40 00 11 11 0 | Output2 | 2 seconds | 256 megabytes | ['dp', 'geometry', '*2500'] |
D. The Child and Zootime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOf course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two... | Input4 310 20 30 401 32 34 3 | Output16.666667 | 2 seconds | 256 megabytes | ['dsu', 'sortings', '*1900'] |
C. The Child and Toytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy.The toy consists of n parts and m ropes. Each rope links two p... | Input4 310 20 30 401 41 22 3 | Output40 | 1 second | 256 megabytes | ['graphs', 'greedy', 'sortings', '*1400'] |
B. The Child and Settime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAt the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks.Fortunately, Pick... | Input5 5 | Output24 5 | 1 second | 256 megabytes | ['bitmasks', 'greedy', 'implementation', 'sortings', '*1500'] |
A. The Child and Homeworktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and th... | InputA.VFleaKing_is_the_author_of_this_problemB.Picks_is_the_author_of_this_problemC.Picking_is_the_author_of_this_problemD.Ftiasch_is_cute | OutputD | 1 second | 256 megabytes | ['implementation', '*1300'] |
F. Bannerstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAll modern mobile applications are divided into free and paid. Even a single application developers often release two versions: a paid version without ads and a free version with ads. Suppose that a paid ver... | Input2 12 00 2 | Output0 33 24 22 2 | 5 seconds | 512 megabytes | ['brute force', 'data structures', 'dp', '*3000'] |
E. Cardboard Boxtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEveryone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should com... | Input2 31 21 2 | Output312 | 5 seconds | 256 megabytes | ['data structures', 'greedy', '*2600'] |
D. Pudding Monsterstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever played Pudding Monsters? In this task, a simplified one-dimensional model of this game is used. Imagine an infinite checkered stripe, the cells of which are numbered sequentially with ... | Input3 21 3 52 4 | Output2 | 5 seconds | 256 megabytes | ['dp', '*2800'] |
C. Dungeons and Candiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the loading of the game "Dungeons and Candies" you are required to get descriptions of k levels from the server. Each description is a map of an nβΓβm checkered rectangular field. Some cel... | Input2 3 3 2A.A...A.a..CX.Y... | Output141 02 13 1 | 2 seconds | 256 megabytes | ['dsu', 'graphs', 'greedy', 'trees', '*1800'] |
B. Om Nom and Spiderstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOm Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to s... | Input3 3 4...R.LR.U | Output0 2 2 | 3 seconds | 256 megabytes | ['implementation', 'math', '*1400'] |
A. Feed with Candytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem. One day, Om Nom visited his friend Evan. Evan has... | Input5 30 2 41 3 10 8 30 20 101 5 5 | Output4 | 2 seconds | 256 megabytes | ['greedy', '*1500'] |
E. Special Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you will need to deal with an nβΓβm grid graph. The graph's vertices are the nodes of the nβΓβm grid. The graph's edges are all the sides and diagonals of the grid's unit squares.The fig... | Input3 5101010002001000 | Output131314242431313 | 2 seconds | 256 megabytes | ['*2500'] |
D. Special Gridtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an nβΓβm grid, some of its nodes are black, the others are white. Moreover, it's not an ordinary grid β each unit square of the grid has painted diagonals.The figure below is an example of ... | Input3 5100001001000001 | Output20 | 4 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', '*2000'] |
C. Cardiogramtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem, your task is to use ASCII graphics to paint a cardiogram. A cardiogram is a polyline with the following corners:That is, a cardiogram is fully defined by a sequence of positive integers a1,... | Input53 1 2 5 1 | Output β/β\ β/β\β/β \ β/β \ β/β \ \β/β | 1 second | 256 megabytes | ['implementation', '*1600'] |
B. Pasha Maximizestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent... | Input1990 1 | Output9190 | 1 second | 256 megabytes | ['greedy', '*1400'] |
A. Queue on Bus Stoptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, s... | Input4 32 3 2 1 | Output3 | 1 second | 256 megabytes | ['implementation', '*1000'] |
E. Furukawa Nagisa's Treetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOne day, Okazaki Tomoya has bought a tree for Furukawa Nagisa's birthday. The tree is so strange that every node of the tree has a value. The value of the i-th node is vi. Now Furukawa Nagisa a... | Input1 2 1 01 | Output1 | 2 seconds | 512 megabytes | ['binary search', 'divide and conquer', 'sortings', 'trees', '*3000'] |
D. Nanami's Power Planttime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNanami likes playing games, and is also really good at it. This day she was playing a new game which involved operating a power plant. Nanami's job is to control the generators in the plant and p... | Input3 30 1 00 1 10 1 20 31 2-100 1001 2 02 3 03 1 0 | Output9 | 5 seconds | 512 megabytes | ['flows', '*2900'] |
E. Tachibana Kanade's Tofutime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTachibana Kanade likes Mapo Tofu very much. One day, the canteen cooked all kinds of tofu to sell, but not all tofu is Mapo Tofu, only those spicy enough can be called Mapo Tofu.Each piece of ... | Input2 10 11 13 1 0 01 1 11 0 1 | Output97 | 5 seconds | 512 megabytes | ['dp', '*2500'] |
D. Nanami's Digital Boardtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNanami is an expert at playing games. This day, Nanami's good friend Hajime invited her to watch a game of baseball. Unwilling as she was, she followed him to the stadium. But Nanami had no inte... | Input3 4 50 1 1 01 0 0 10 1 1 02 2 22 1 21 2 21 2 32 2 2 | Output026 | 1 second | 256 megabytes | ['dsu', 'implementation', '*2000'] |
C. Ryouko's Memory Notetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRyouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what ... | Input4 61 2 3 4 3 2 | Output3 | 1 second | 256 megabytes | ['implementation', 'math', 'sortings', '*1800'] |
B. Kuriyama Mirai's Stonestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these... | Input66 4 2 7 2 732 3 61 3 41 1 6 | Output24928 | 2 seconds | 256 megabytes | ['dp', 'implementation', 'sortings', '*1200'] |
A. Kitahara Haruki's Gifttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.Each apple weights 100 grams or 200 grams. Of course Kitahara Ha... | Input3100 200 100 | OutputYES | 1 second | 256 megabytes | ['brute force', 'implementation', '*1100'] |
E. Square Tilingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an nβΓβm rectangle table, its cells are not initially painted. Your task is to paint all cells of the table. The resulting picture should be a tiling of the table with squares. More formally: e... | Input1 3 | OutputABA | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*2300'] |
D. Prefixes and Suffixestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a string sβ=βs1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1ββ€βiββ€βjββ€β|s|) of string s is strin... | InputABACABA | Output31 43 27 1 | 1 second | 256 megabytes | ['dp', 'string suffix structures', 'strings', 'two pointers', '*2000'] |
C. Prime Swapstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a[1],βa[2],β...,βa[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times... | Input33 2 1 | Output11 3 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1800'] |
B. Football Kittime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color xi and the kit for away gam... | Input21 22 1 | Output2 02 0 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', '*1200'] |
A. Choosing Teamstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming champ... | Input5 20 4 5 1 0 | Output1 | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*800'] |
E. Chemistry Experimenttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day two students, Grisha and Diana, found themselves in the university chemistry lab. In the lab the students found n test tubes with mercury numbered from 1 to n and decided to conduct an ex... | Input3 31 2 02 21 2 12 3 | Output1.500001.66667 | 4 seconds | 256 megabytes | ['binary search', 'data structures', 'ternary search', '*2200'] |
D. Random Tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers nβ+β1, nβ+β2, ..., 2Β·n there ... | Input1 1 | Output1 | 1 second | 256 megabytes | ['binary search', 'bitmasks', 'combinatorics', 'dp', 'math', '*2100'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.