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 |
|---|---|---|---|---|---|
F. Panda Meetupstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe red pandas are in town to meet their relatives, the blue pandas! The town is modeled by a number line.The pandas have already planned their meetup, but the schedule keeps changing. You are given q u... | 5
0 6 3
4 2 -5
7 4 -6
10 5 100
10 8 7
| 0 3 3 3 10 | 4 seconds | 256 megabytes | ['data structures', 'dp', 'flows', '*3500'] |
E. Rivalriestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNtarsis has an array a of length n.The power of a subarray a_l \dots a_r (1 \leq l \leq r \leq n) is defined as: The largest value x such that a_l \dots a_r contains x and neither a_1 \dots a_{l-1} nor a_... | 751 4 1 3 351 4 1 8 852 1 1 1 283 2 3 5 2 2 5 381 1 1 1 4 3 3 3101 9 5 9 8 1 5 8 9 1161 1 1 1 5 5 5 5 9 9 9 9 7 7 7 7 | 2 4 2 3 3 3 4 3 8 8 2 1 2 1 2 4 2 4 5 5 2 5 4 1 2 2 1 4 3 2 3 7 9 5 9 8 9 5 8 9 7 1 8 8 1 5 8 8 5 9 9 9 9 7 8 8 7 | 2 seconds | 512 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*3400'] |
D. Miriany and Matchsticktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMiriany's matchstick is a 2 \times n grid that needs to be filled with characters A or B. He has already filled in the first row of the grid and would like you to fill in the second row. You mu... | 410 1ABBAAABBAA4 5AAAA9 17BAAABBAAB4 9ABAB | NO YES BABB YES ABABAABAB NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', '*2800'] |
C. Ina of the Mountaintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo prepare her "Takodachi" dumbo octopuses for world domination, Ninomae Ina'nis, a.k.a. Ina of the Mountain, orders Hoshimachi Suisei to throw boulders at them. Ina asks you, Kiryu Coco, to help ... | 24 31 2 1 37 31 2 3 1 3 2 1 | 2 4 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'math', '*2400'] |
B. Imbalanced Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNtarsis has come up with an array a of n non-negative integers.Call an array b of n integers imbalanced if it satisfies the following: -n\le b_i\le n, b_i \ne 0, there are no two indices (i, j) (... | 51141 4 3 430 1 044 3 2 131 3 1 | YES 1 NO YES -3 1 -2 YES 4 2 -1 -3 YES -1 3 -1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'math', 'sortings', 'two pointers', '*1800'] |
A. Ntarsis' Settime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNtarsis has been given a set S, initially containing integers 1, 2, 3, \ldots, 10^{1000} in sorted order. Every day, he will remove the a_1-th, a_2-th, \ldots, a_n-th smallest numbers in S simultaneously... | 75 11 2 4 5 65 31 3 5 6 74 10002 3 4 59 14341 4 7 9 12 15 17 18 2010 41 3 5 7 9 11 13 15 17 1910 61 4 7 10 13 16 19 22 25 2810 1500001 3 4 5 10 11 12 13 14 15 | 3 9 1 12874 16 18 1499986 | 2 seconds | 256 megabytes | ['binary search', 'math', 'number theory', '*1800'] |
G. Vlad and the Mountainstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad decided to go on a trip to the mountains. He plans to move between n mountains, some of which are connected by roads. The i-th mountain has a height of h_i.If there is a road between mount... | 27 71 5 3 4 2 4 11 44 33 63 22 55 65 751 1 36 2 04 7 01 7 41 7 26 54 7 6 2 5 11 35 31 52 46 251 5 11 3 11 2 10006 2 66 2 5 | YES NO YES YES NO YES NO NO YES NO | 5 seconds | 256 megabytes | ['binary search', 'data structures', 'dsu', 'graphs', 'implementation', 'sortings', 'trees', 'two pointers', '*2000'] |
F. Lisa and the Martianstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLisa was kidnapped by martians! It okay, because she has watched a lot of TV shows about aliens, so she knows what awaits her. Let's call integer martian if it is a non-negative integer and stri... | 105 43 9 1 4 133 11 0 16 12144 1580 1024 100 9 134 37 3 0 43 20 0 12 412 29 46 14 9 4 4 4 5 10 22 11 02 411 49 42 11 10 1 6 9 11 0 5 | 1 3 14 1 3 0 5 6 4082 2 3 7 1 2 3 1 2 15 4 5 11 1 2 0 1 2 0 2 7 4 | 3 seconds | 512 megabytes | ['bitmasks', 'greedy', 'math', 'strings', 'trees', '*1800'] |
E. Nastya and Potionstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlchemist Nastya loves mixing potions. There are a total of n types of potions, and one potion of type i can be bought for c_i coins.Any kind of potions can be obtained in no more than one way, by ... | 45 130 8 3 5 1033 2 4 50 0 2 3 50 3 25 143 31 31 20 2 1 25 15 4 1 3 422 4 53 3 5 42 1 41 50 4 21 1 5 42 43 2 4 30 2 2 41 2 | 23 8 0 5 10 0 143 0 5 0 1 3 4 0 0 0 0 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'sortings', '*1500'] |
D. Prefix Permutation Sumstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friends have an array of n elements, calculated its array of prefix sums and passed it to you, accidentally losing one element during the transfer. Your task is to find out if the given a... | 1256 8 12 1551 6 8 1541 2 10041 3 62231 243 7 1055 44 46 5041 9 10513 21 36 4251 2 3 100000000000000000099 11 12 20 25 28 30 33 | YES YES NO YES YES NO YES NO NO NO NO NO | 3 seconds | 256 megabytes | ['implementation', 'math', '*1300'] |
C. Tiles Comebacktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad remembered that he had a series of n tiles and a number k. The tiles were numbered from left to right, and the i-th tile had colour c_i.If you stand on the first tile and start jumping any number ... | 104 21 1 1 114 31 2 1 1 7 5 3 3 1 3 4 4 2 43 33 1 310 41 2 1 2 1 2 1 2 1 26 21 3 4 1 6 62 21 14 22 1 1 12 11 23 22 2 24 11 1 2 2 | YES YES NO NO YES YES NO YES YES YES | 2 seconds | 256 megabytes | ['greedy', '*1000'] |
B. Parity Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array of integers a of length n. You can apply the following operation to the given array: Swap two elements a_i and a_j such that i \neq j, a_i and a_j are either both even or both odd. De... | 657 10 1 3 2411 9 3 5511 3 15 3 2610 7 8 1 2 311056 6 4 1 6 | YES YES NO NO YES NO | 2 seconds | 256 megabytes | ['greedy', 'sortings', 'two pointers', '*800'] |
A. Escalator Conversationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Vlad became curious about who he can have a conversation with on the escalator in the subway. There are a total of n passengers. The escalator has a total of m steps, all steps indexe... | 75 3 3 115 4 14 18 22 9 5 611 910 50 3 1143 44 74 98 62 60 99 4 11 734 8 8 4968 58 82 737 1 4 6618 66 39 83 48 99 799 1 1 1326 23 84 6 60 87 40 41 256 13 3 2830 70 85 13 1 55 | 2 1 4 1 0 0 3 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'math', '*800'] |
H. The Third Lettertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn order to win his toughest battle, Mircea came up with a great strategy for his army. He has n soldiers and decided to arrange them in a certain way in camps. Each soldier has to belong to exactly ... | 45 31 2 22 3 44 2 -66 51 2 22 3 44 2 -65 4 43 5 1002 21 2 51 2 44 11 2 3 | YES NO NO YES | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'greedy', 'implementation', '*1700'] |
G. The Morning Startime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA compass points directly toward the morning star. It can only point in one of eight directions: the four cardinal directions (N, S, E, W) or some combination (NW, NE, SW, SE). Otherwise, it will bre... | 530 0-1 -11 144 55 76 910 133-1000000000 10000000000 01000000000 -100000000050 02 2-1 5-1 102 1130 0-1 21 -2 | 6 2 6 8 0 | 2 seconds | 256 megabytes | ['combinatorics', 'data structures', 'geometry', 'implementation', 'math', 'sortings', '*1500'] |
F. We Were Both Childrentime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMihai and Slavic were looking at a group of n frogs, numbered from 1 to n, all initially located at point 0. Frog i has a hop length of a_i. Each second, frog i hops a_i units forward. Before an... | 751 2 3 4 532 2 263 1 3 4 9 1091 3 2 4 2 3 7 8 511087 11 6 8 12 4 4 8109 11 9 12 1 7 2 5 8 10 | 3 3 3 5 0 4 4 | 3 seconds | 256 megabytes | ['brute force', 'implementation', 'math', 'number theory', '*1300'] |
E. Cardboard for Picturestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMircea has n pictures. The i-th picture is a square with a side length of s_i centimeters. He mounted each picture on a square piece of cardboard so that each picture has a border of w centimet... | 10
3 50
3 2 1
1 100
6
5 500
2 2 2 2 2
2 365
3 4
2 469077255466389
10000 2023
10 635472106413848880
9181 4243 7777 1859 2017 4397 14 9390 2245 7225
7 176345687772781240
9202 9407 9229 6257 7743 5738 7966
14 865563946464579627
3654 5483 1657 7571 1639 9815 122 9468 3079 2666 5498 4540 7861 5384
19 977162053008871403
9169... | 1 2 4 5 7654321 126040443 79356352 124321725 113385729 110961227 | 2 seconds | 256 megabytes | ['binary search', 'geometry', 'implementation', 'math', '*1100'] |
D. Balanced Roundtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are the author of a Codeforces round and have prepared n problems you are going to set, problem i having difficulty a_i. You will do the following process: remove some (possibly zero) problems fr... | 75 11 2 4 5 61 2108 317 3 1 20 12 5 17 124 22 4 6 85 32 3 19 10 83 41 10 58 18 3 1 4 5 10 7 3 | 2 0 5 0 3 1 4 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'sortings', '*900'] |
C. Word on the Papertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn an 8 \times 8 grid of dots, a word consisting of lowercase Latin letters is written vertically in one column, from top to bottom. What is it?InputThe input consists of multiple test cases. The fir... | 5...................................i.....................................l.......o.......s.......t....................................................................t.......h.......e................................................g.......a.......m.......ea.......a.......a.......a.......a.......a.......a.......a......... | i lost the game aaaaaaaa | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
B. Ten Words of Wisdomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the game show "Ten Words of Wisdom", there are n participants numbered from 1 to n, each of whom submits one response. The i-th response is a_i words long and has quality b_i. No two responses h... | 357 212 59 39 410 131 23 45 611 43 | 4 3 1 | 1 second | 256 megabytes | ['implementation', 'sortings', '*800'] |
A. To My Criticstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuneet has three digits a, b, and c. Since math isn't his strongest point, he asks you to determine if you can choose any two digits to make a sum greater or equal to 10.Output "YES" if there is such a p... | 58 1 24 4 59 9 90 0 08 5 3 | YES NO YES NO YES | 1 second | 256 megabytes | ['implementation', 'sortings', '*800'] |
F. XOR Partitiontime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor a set of integers S, let's define its cost as the minimum value of x \oplus y among all pairs of different integers from the set (here, \oplus denotes bitwise XOR). If there are less than two elemen... | Input542 13 1337 37 152 | Output10001 | 7 seconds | 512 megabytes | ['binary search', 'bitmasks', 'data structures', 'divide and conquer', 'greedy', 'trees', '*2700'] |
E. Max to the Right of Mintime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of length n — an array, consisting of integers from 1 to n, all distinct.Let p_{l,r} denote a subarray — an array formed by writing down elements from index l to ... | 3
1 2 3
| 3 | 3 seconds | 256 megabytes | ['binary search', 'data structures', 'divide and conquer', 'dp', 'dsu', 'two pointers', '*2300'] |
D. Array Paintingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n integers, where each integer is either 0, 1, or 2. Initially, each element of the array is blue.Your goal is to paint each element of the array red. In order to do so, you c... | 3
0 2 0
| 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'two pointers', '*1700'] |
C. Binary String Copyingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of n characters 0 and/or 1.You make m copies of this string, let the i-th copy be the string t_i. Then you perform exactly one operation on each of the copies... | 36 51011001 21 32 45 51 66 41001112 21 41 31 21 101 1 | 3 3 1 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'hashing', 'strings', '*1600'] |
B. Monsterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing yet another computer game. And yet again, his character is killing some monsters. There are n monsters, numbered from 1 to n, and the i-th of them has a_i health points initially.Monocarp... | 33 21 2 32 31 14 32 8 3 5 | 2 1 3 1 2 3 1 2 4 | 2 seconds | 256 megabytes | ['greedy', 'math', 'sortings', '*1000'] |
A. Morning Sandwichtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp always starts his morning with a good ol' sandwich. Sandwiches Monocarp makes always consist of bread, cheese and/or ham.A sandwich always follows the formula: a piece of bread a slice of... | 32 1 110 1 23 7 8 | 3 7 5 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
F. Vika and Wikitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Vika was studying her favorite internet resource - Wikipedia.On the expanses of Wikipedia, she read about an interesting mathematical operation bitwise XOR, denoted by \oplus. Vika began to st... | 4
1 2 1 2
| 2 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'combinatorics', 'divide and conquer', 'dp', 'math', '*2400'] |
E. Vika and Stone Skippingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Vika's hometown, Vladivostok, there is a beautiful sea.Often you can see kids skimming stones. This is the process of throwing a stone into the sea at a small angle, causing it to fly far a... | 1 2 179
2 3
| 1 2 | 3 seconds | 256 megabytes | ['brute force', 'implementation', 'math', 'number theory', '*2600'] |
D. Vika and Bonusestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new bonus system has been introduced at Vika's favorite cosmetics store, "Golden Pear"!The system works as follows: suppose a customer has b bonuses. Before paying for the purchase, the customer ca... | 61 311 30 1795 1000000000723252212 856168102728598293 145725253 | 4 33 0 9999999990 1252047198518668448 106175170582793129 | 3 seconds | 256 megabytes | ['binary search', 'brute force', 'math', 'ternary search', '*2200'] |
C. Vika and Price Tagstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVika came to her favorite cosmetics store "Golden Pear". She noticed that the prices of n items have changed since her last visit.She decided to analyze how much the prices have changed and calcula... | 940 0 0 01 2 3 431 2 31 2 321 22 16100 23 53 11 56 321245 31 12 6 6 671 2 3 4 5 6 77 6 5 4 3 2 134 0 24 0 232 5 21 3 426 14 220 00 3 | YES YES NO NO YES YES NO YES YES | 1 second | 256 megabytes | ['math', 'number theory', '*1800'] |
B. Vika and the Bridgetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the summer, Vika likes to visit her country house. There is everything for relaxation: comfortable swings, bicycles, and a river.There is a wooden bridge over the river, consisting of n planks. ... | 55 21 1 2 1 17 31 2 3 3 3 2 16 61 2 3 4 5 68 41 2 3 4 2 3 1 43 11 1 1 | 0 1 2 2 0 | 1 second | 256 megabytes | ['binary search', 'data structures', 'greedy', 'implementation', 'math', 'sortings', '*1200'] |
A. Vika and Her Friendstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVika and her friends went shopping in a mall, which can be represented as a rectangular grid of rooms with sides of length n and m. Each room has coordinates (a, b), where 1 \le a \le n, 1 \le b \... | 62 2 11 11 22 2 21 12 22 21 2 11 11 25 5 43 31 11 55 15 52 2 21 12 11 23 4 11 23 3 | YES NO YES NO YES YES | 1 second | 256 megabytes | ['games', 'math', '*900'] |
F. The Boss's Identitytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWhile tracking Diavolo's origins, Giorno receives a secret code from Polnareff. The code can be represented as an infinite sequence of positive integers: a_1, a_2, \dots . Giorno immediately sees ... | 32 32 11234 50 2 1 3012345 51 2 3 4 572604 | 1 3 -1 2 2 4 -1 -1 -1 3 8 1 5 | 3 seconds | 512 megabytes | ['binary search', 'bitmasks', 'data structures', 'dfs and similar', 'greedy', 'math', 'sortings', '*2500'] |
E. Triangle Platinum?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Made in Heaven is a rather curious Stand. Of course, it is (arguably) the strongest Stand in existence, but it is also an ardent puzzle enjoyer. For example, it gave ... | 3
63
| ? 1 2 3 ! -1 | 2 seconds | 256 megabytes | ['brute force', 'combinatorics', 'implementation', 'interactive', 'math', 'probabilities', '*2900'] |
D. Professor Higashikatatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJosuke is tired of his peaceful life in Morioh. Following in his nephew Jotaro's footsteps, he decides to study hard and become a professor of computer science. While looking up competitive prog... | 2 2 4
01
1 2
1 2
1
1
2
2
| 0 1 0 1 | 2 seconds | 256 megabytes | ['data structures', 'dsu', 'greedy', 'implementation', 'strings', '*1900'] |
C. Vampiric Powers, anyone?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDIO knows that the Stardust Crusaders have determined his location and will be coming to fight him. To foil their plans he decides to send out some Stand users to fight them. Initially, he sum... | 340 2 5 131 2 358 2 4 12 1 | 7 3 14 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'greedy', '*1400'] |
B. Hamon Odysseytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJonathan is fighting against DIO's Vampire minions. There are n of them with strengths a_1, a_2, \dots, a_n. \def\and {{\,\texttt{&}\,}}Denote (l, r) as the group consisting of the vampires with indices ... | 331 2 352 3 1 5 245 7 12 6 | 1 2 1 | 1 second | 256 megabytes | ['bitmasks', 'greedy', 'two pointers', '*1000'] |
A. The Man who became a God time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKars is tired and resentful of the narrow mindset of his village since they are content with staying where they are and are not trying to become the perfect life form. Being a top-notch inven... | 34 21 3 5 26 31 9 12 4 7 212 81 9 8 2 3 3 1 8 7 7 9 2 | 4 11 2 | 1 second | 256 megabytes | ['greedy', 'sortings', '*800'] |
G. Rudolf and CodeVid-23time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new virus called "CodeVid-23" has spread among programmers. Rudolf, being a programmer, was not able to avoid it.There are n symptoms numbered from 1 to n that can appear when infected. Initial... | 45 410011310000001103001010000030101000100511010001004 1000010101101002 21121001301102 311301103100041001 | 8 0 -1 6 | 1 second | 256 megabytes | ['bitmasks', 'dp', 'graphs', 'greedy', 'shortest paths', '*1900'] |
F. Rudolph and Mimictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive task.Rudolph is a scientist who studies alien life forms. There is a room in front of Rudolph with n different objects scattered around. Among the objects there is exactly one ... | 3
5
1 1 2 2 3
2 1 1 2
2 2 2
2
8
1 2 3 4 3 4 2 1
4 3 4 3 2 2 1 3
2 3 3 2
5 3 2
2 5
15
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 7 9 5 4 3 2 1 | - 1 5 - 1 3 - 2 1 2 ! 1 - 0 - 4 1 3 7 8 - 1 4 - 1 2 ! 2 - 0 ! 10 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', 'interactive', '*1800'] |
E2. Rudolf and Snowflakes (hard version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version n \le 10^{18}.One winter morning, Rudolf was looking thoughtfully out the window, watching th... | 912361315255101011000000000000000000 | NO NO NO NO YES YES YES YES NO | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'implementation', 'math', '*1800'] |
E1. Rudolf and Snowflakes (simple version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a simple version of the problem. The only difference is that in this version n \le 10^6.One winter morning, Rudolf was looking thoughtfully out the window, watching the... | 912361315255101011000000 | NO NO NO NO YES YES YES YES NO | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'math', '*1300'] |
D. Rudolph and Christmas Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRudolph drew a beautiful Christmas tree and decided to print the picture. However, the ink in the cartridge often runs out at the most inconvenient moment. Therefore, Rudolph wants to calcu... | 53 4 21 4 51 5 134 6 61 2 3 42 1 2000001 2000002 4 39 11 | 11 2.5 34.5 199999.9999975 11.333333 | 2 seconds | 256 megabytes | ['constructive algorithms', 'geometry', 'math', '*1200'] |
C. Rudolf and the Another Competitiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRudolf has registered for a programming competition that will follow the rules of ICPC. The rules imply that for each solved problem, a participant gets 1 point, and also incurs a pe... | 53 3 12020 15 11090 90 10040 40 402 1 12030301 3 12010 20 303 2 278 910 710 83 3 157 2 67 5 41 9 8 | 2 1 1 2 1 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'dp', 'greedy', 'sortings', '*1200'] |
B. Rudolph and Tic-Tac-Toetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRudolph invented the game of tic-tac-toe for three players. It has classic rules, except for the third player who plays with pluses. Rudolf has a 3 \times 3 field — the result of the completed... | 5+X+OXOOX.O+.+OXX+O.XOOX.+++O.+X.O+...++X.O+.. | X O + DRAW DRAW | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*800'] |
A. Rudolph and Cut the Rope time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n nails driven into the wall, the i-th nail is driven a_i meters above the ground, one end of the b_i meters long rope is tied to it. All nails hang at different heights one above ... | 434 33 11 249 25 27 73 4511 75 1012 93 21 535 64 57 7 | 2 2 3 0 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
F. Swimmers in the Pooltime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is a pool of length l where n swimmers plan to swim. People start swimming at the same time (at the time moment 0), but you can assume that they take different lanes, so they don't interfer... | 9 18
2
1 2
| 3 | 3 seconds | 512 megabytes | ['dp', 'fft', 'math', 'number theory', '*2800'] |
E. Boxes and Ballstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n boxes placed in a line. The boxes are numbered from 1 to n. Some boxes contain one ball inside of them, the rest are empty. At least one box contains a ball and at least one box is empty.I... | 4 1
1 0 1 0
| 3 | 5 seconds | 256 megabytes | ['dp', 'implementation', 'math', '*2500'] |
D. Rating Systemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are developing a rating system for an online game. Every time a player participates in a match, the player's rating changes depending on the results.Initially, the player's rating is 0. There are n ... | 443 -2 1 23-1 -2 -124 275 1 -3 2 -1 -2 2 | 3 0 25 6 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'dp', 'dsu', 'greedy', 'math', 'two pointers', '*1800'] |
C. Strong Passwordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp finally got the courage to register on ForceCoders. He came up with a handle but is still thinking about the password.He wants his password to be as strong as possible, so he came up with the... | 5880055535351234562505612341234123431114441234443214321459249590001021011 | YES NO YES NO YES | 2 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', 'strings', '*1400'] |
B. Come Togethertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob and Carol hanged out with Alice the whole day, but now it's time to go home. Alice, Bob and Carol live on an infinite 2D grid in cells A, B, and C respectively. Right now, all of them are in cell A.... | 33 11 36 45 22 27 21 14 35 5 | 3 1 6 | 2 seconds | 256 megabytes | ['geometry', 'implementation', 'math', '*900'] |
A. Forbidden Integertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n, which you want to obtain. You have an unlimited supply of every integer from 1 to k, except integer x (there are no integer x at all).You are allowed to take an arbitrary... | 510 3 25 2 14 2 17 7 36 1 1 | YES 6 3 1 1 1 1 3 NO YES 2 2 2 YES 1 7 NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'math', 'number theory', '*800'] |
H. Multiple of Three Cyclestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn array a_1,\dots,a_n of length n is initially all blank. There are n updates where one entry of a is updated to some number, such that a becomes a permutation of 1,2,\dots,n after all the u... | 6
3 2
1 4
4 5
2 6
5 1
6 3
| 32 8 3 2 1 1 | 3 seconds | 256 megabytes | ['combinatorics', 'data structures', 'dp', 'dsu', 'math', '*3400'] |
G. Tree Weightstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n nodes labelled 1,2,\dots,n. The i-th edge connects nodes u_i and v_i and has an unknown positive integer weight w_i. To help you figure out these weights, you are also given t... | 5
1 2
1 3
2 4
2 5
31 41 59 26
| 31 10 18 8 | 5 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'data structures', 'dfs and similar', 'implementation', 'math', 'matrices', 'number theory', 'trees', '*3000'] |
F2. Min Cost Permutation (Hard Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the easy version is the constraints on t and n.You are given an array of n positive integers a_1,\dots,a_n, and a (possibly negative) ... | 36 -73 1 4 1 5 93 21 3 51 27182818 | 9 3 1 4 5 1 1 3 5 2818 | 3 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', 'math', 'sortings', '*2800'] |
F1. Min Cost Permutation (Easy Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the hard version is the constraints on t and n.You are given an array of n positive integers a_1,\dots,a_n, and a (possibly negative) ... | 36 -73 1 4 1 5 93 21 3 51 27182818 | 9 3 1 4 5 1 1 3 5 2818 | 3 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', '*2600'] |
E. Great Gridstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn n \times m grid of characters is called great if it satisfies these three conditions: Each character is either 'A', 'B', or 'C'. Every 2 \times 2 contiguous subgrid contains all three different lette... | 43 4 41 1 2 22 1 3 21 4 2 32 3 3 22 7 21 1 2 21 2 2 18 5 41 2 2 11 5 2 47 1 8 27 4 8 58 5 41 2 2 11 5 2 47 1 8 27 5 8 4 | YES NO YES NO | 1 second | 256 megabytes | ['2-sat', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', '*2400'] |
D. Row Majortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe row-major order of an r \times c grid of characters A is the string obtained by concatenating all the rows, i.e. A_{11}A_{12} \dots A_{1c}A_{21}A_{22} \dots A_{2c} \dots A_{r1}A_{r2} \dots A_{rc}. A gr... | 44216 | that is a tomato | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', 'number theory', 'strings', '*1400'] |
C. Particlestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have discovered n mysterious particles on a line with integer charges of c_1,\dots,c_n. You have a device that allows you to perform the following operation: Choose a particle and remove it from the li... | 36-3 1 4 -1 5 -95998244353 998244353 998244353 998244353 9982443531-2718 | 9 2994733059 -2718 | 1 second | 256 megabytes | ['dp', 'greedy', 'implementation', 'math', '*1300'] |
B. Permutations & Primestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n.In this problem, the \operatorname{MEX} of a collection of integers c_1,c_2,\dots,c_k is defined as the smallest positive integer x which does not occur in the ... | 3215 | 2 1 1 5 2 1 4 3 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1000'] |
A. Subtraction Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive integers, a and b (a < b).For some positive integer n, two players will play a game starting with a pile of n stones. They take turns removing exactly a or exactly b stones ... | 31 41 59 26 | 2 6 3 | 1 second | 256 megabytes | ['constructive algorithms', 'games', '*800'] |
F2. Omsk Metro (hard version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the simple and hard versions is that in this version u can take any possible value.As is known, Omsk is the capital of B... | 18+ 1 -1? 1 1 2? 1 2 1+ 1 1? 1 3 -1? 1 1 1? 1 3 2? 1 1 0 | NO YES NO YES YES YES | 2 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'divide and conquer', 'dp', 'math', 'trees', '*2300'] |
F1. Omsk Metro (simple version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the simple version of the problem. The only difference between the simple and hard versions is that in this version u = 1.As is known, Omsk is the capital of Berland. Like any cap... | 18+ 1 -1? 1 1 2? 1 2 1+ 1 1? 1 3 -1? 1 1 1? 1 3 2? 1 1 0 | NO YES NO YES YES YES | 2 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'dp', 'graphs', 'greedy', 'math', 'trees', '*1800'] |
E. Tracking Segmentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n zeros. You are also given a set of m not necessarily different segments. Each segment is defined by two numbers l_i and r_i (1 \le l_i \le r_i \le n) and rep... | 65 51 24 51 51 32 45531244 21 14 42235 21 51 5421345 21 51 35412355 51 51 51 51 51 431433 22 21 33231 | 3 -1 3 3 3 1 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'two pointers', '*1600'] |
D. Apple Treetime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTimofey has an apple tree growing in his garden; it is a rooted tree of n vertices with the root in vertex 1 (the vertices are numbered from 1 to n). A tree is a connected graph without loops and multiple ... | 251 23 45 33 243 45 14 41 331 21 331 12 33 1 | 2 2 1 4 4 1 2 | 4 seconds | 512 megabytes | ['combinatorics', 'dfs and similar', 'dp', 'math', 'trees', '*1200'] |
C. Sum in Binary Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVanya really likes math. One day when he was solving another math problem, he came up with an interesting tree. This tree is built as follows.Initially, the tree has only one vertex with the number ... | 63103711000000000000000015 | 4 18 71 1 19999999999999980 26 | 1 second | 256 megabytes | ['bitmasks', 'combinatorics', 'math', 'trees', '*800'] |
B. Long Longtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Alex was brought array a_1, a_2, \dots, a_n of length n. He can apply as many operations as he wants (including zero operations) to change the array elements.In 1 operation Alex can choose any l and r... | 56-1 7 -4 -2 5 -88-1 0 0 -2 1 0 -3 052 -1 0 -3 -750 -17 0 1 04-1 0 -2 -1 | 27 3 7 2 13 1 18 1 4 1 | 2 seconds | 256 megabytes | ['greedy', 'math', 'two pointers', '*800'] |
A. Sasha and Array Coloringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha found an array a consisting of n integers and asked you to paint elements.You have to paint each element of the array. You can use as many colors as you want, but each element should be ... | 651 5 6 3 41541 6 3 961 13 9 3 7 242 2 2 254 5 2 2 3 | 7 0 11 23 0 5 | 1 second | 256 megabytes | ['greedy', 'sortings', 'two pointers', '*800'] |
I. Tenzing and Necklacetime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputbright, sunny and innocent......Tenzing has a beautiful necklace. The necklace consists of n pearls numbered from 1 to n with a string connecting pearls i and (i \text{ mod } n)+1 for all 1 \leq... | 45 21 1 1 1 15 21 2 3 4 56 34 2 5 1 3 310 32 5 6 5 2 1 7 9 7 2 | 3 7 5 15 | 2 seconds | 1024 megabytes | ['divide and conquer', 'dp', 'greedy', '*3500'] |
H. Tenzing and Random Real Numberstime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThere are n uniform random real variables between 0 and 1, inclusive, which are denoted as x_1, x_2, \ldots, x_n.Tenzing has m conditions. Each condition has the form of x_i+x_j\le 1 o... | 3 2
0 1 2
1 3 3
| 748683265 | 1 second | 1024 megabytes | ['bitmasks', 'dp', 'graphs', 'math', 'probabilities', '*3000'] |
G. Tenzing and Random Operationstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYet another random problem.Tenzing has an array a of length n and an integer v.Tenzing will perform the following operation m times: Choose an integer i such that 1 \leq i \leq n unifo... | 2 2 5
2 2
| 84 | 2 seconds | 1024 megabytes | ['combinatorics', 'dp', 'math', 'probabilities', '*2800'] |
F. Tenzing and Treetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTenzing has an undirected tree of n vertices.Define the value of a tree with black and white vertices in the following way. The value of an edge is the absolute difference between the number of black... | 4
1 2
3 2
2 4
| 0 3 4 5 6 | 2 seconds | 512 megabytes | ['dfs and similar', 'greedy', 'shortest paths', 'sortings', 'trees', '*2500'] |
E. Tenzing and Triangletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n pairwise-distinct points and a line x+y=k on a two-dimensional plane. The i-th point is at (x_i,y_i). All points have non-negative coordinates and are strictly below the line. Alterna... | 4 6 1
1 2 1
2 1 1
1 1 1
3 2 6
| 4 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'geometry', 'greedy', 'math', '*2300'] |
D. Tenzing and His Animal Friends time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTell a story about me and my animal friends.Tenzing has n animal friends. He numbers them from 1 to n.One day Tenzing wants to play with his animal friends. To do so, Tenzing will host ... | 5 4
1 3 2
1 4 2
2 3 1
2 5 1
| 4 4 10000 1 10010 1 10100 1 11110 1 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', '*1900'] |
C. Tenzing and Ballstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEnjoy erasing Tenzing, identified as Accepted!Tenzing has n balls arranged in a line. The color of the i-th ball from the left is a_i.Tenzing can do the following operation any number of times: sele... | 251 2 2 3 341 2 1 2 | 4 3 | 1 second | 256 megabytes | ['dp', '*1500'] |
B. Tenzing and Bookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTenzing received 3n books from his fans. The books are arranged in 3 stacks with n books in each stack. Each book has a non-negative integer difficulty rating.Tenzing wants to read some (possibly zer... | 35 71 2 3 4 55 4 3 2 11 3 5 7 95 23 2 3 4 55 4 3 2 13 3 5 7 93 01 2 33 2 12 2 2 | Yes No Yes | 1 second | 256 megabytes | ['bitmasks', 'greedy', 'math', '*1100'] |
A. Tenzing and Tsondutime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTsondu always runs first! ! !Tsondu and Tenzing are playing a card game. Tsondu has n monsters with ability values a_1, a_2, \ldots, a_n while Tenzing has m monsters with ability values b_1, b_2, \l... | 61 391 2 32 31 21 1 13 21 2 31 13 31 1 12 2 210 101 2 3 3 2 2 1 1 2 23 3 3 3 2 1 1 1 1 110 101 2 3 4 5 6 7 8 9 106 7 8 9 10 11 1 1 1 1 | Tsondu Draw Tsondu Tenzing Draw Draw | 1 second | 256 megabytes | ['games', 'math', '*800'] |
F. Monocarp and a Strategic Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp plays a strategic computer game in which he develops a city. The city is inhabited by creatures of four different races — humans, elves, orcs, and dwarves.Each inhabitant of the ... | 5
0 0 1 0
1 3 4 2
2 5 1 2
4 5 4 3
1 4 4 5
| 85 | 1 second | 256 megabytes | ['geometry', 'sortings', 'two pointers', '*2700'] |
E. Fill the Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square matrix, consisting of n rows and n columns of cells, both numbered from 1 to n. The cells are colored white or black. Cells from 1 to a_i are black, and cells from a_i+1 to n are whi... | 630 0 0942 0 3 1542 0 3 1642 0 3 110100 2 2 1 5 10 3 4 1 120110 | 6 3 4 4 16 0 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'math', '*2200'] |
D. Pairs of Segmentstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTwo segments [l_1, r_1] and [l_2, r_2] intersect if there exists at least one x such that l_1 \le x \le r_1 and l_2 \le x \le r_2.An array of segments [[l_1, r_1], [l_2, r_2], \dots, [l_k, r_k]] is ... | 372 49 122 47 74 810 136 852 22 80 101 25 641 12 23 34 4 | 1 3 4 | 4 seconds | 512 megabytes | ['data structures', 'greedy', 'sortings', 'two pointers', '*2000'] |
C. Ranom Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNo, not "random" numbers.Ranom digits are denoted by uppercase Latin letters from A to E. Moreover, the value of the letter A is 1, B is 10, C is 100, D is 1000, E is 10000.A Ranom number is a sequence ... | 4DAAABDCAABABCDEEDCBADDDDAAADDABECD | 11088 10010 31000 15886 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'math', 'strings', '*1800'] |
B. Keep it Beautifultime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe array [a_1, a_2, \dots, a_k] is called beautiful if it is possible to remove several (maybe zero) elements from the beginning of the array and insert all these elements to the back of the array ... | 393 7 7 9 2 4 6 3 451 1 1 1 153 2 1 2 3 | 111110010 11111 11011 | 2 seconds | 512 megabytes | ['implementation', '*1000'] |
A. Game with Boardtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob play a game. They have a blackboard; initially, there are n integers written on it, and each integer is equal to 1.Alice and Bob take turns; Alice goes first. On their turn, the player h... | 236 | Bob Alice | 2 seconds | 512 megabytes | ['constructive algorithms', 'games', '*800'] |
G2. In Search of Truth (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the maximum number of queries. In this version, you are allowed to ask at most 1000 queries.This is an interactive problem.You ... | 1
5
6
7
2
10
9
8
4
3
1 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 ! 10 | 2 seconds | 256 megabytes | ['constructive algorithms', 'interactive', 'math', 'meet-in-the-middle', 'probabilities', '*2500'] |
G1. In Search of Truth (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the maximum number of queries. In this version, you are allowed to ask at most 2023 queries.This is an interactive problem.You ... | 1
5
6
7
2
10
9
8
4
3
1 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 ! 10 | 2 seconds | 256 megabytes | ['constructive algorithms', 'interactive', 'math', 'meet-in-the-middle', 'probabilities', '*2200'] |
F. Railgunstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTema is playing a very interesting computer game.During the next mission, Tema's character found himself on an unfamiliar planet. Unlike Earth, this planet is flat and can be represented as an n \times m rec... | 51 341 2 02 2 13 2 24 1 13 362 1 02 1 12 1 22 2 02 2 12 2 22 137 1 22 1 17 2 12 259 1 23 2 05 1 24 2 27 1 04 676 1 212 1 34 1 017 2 31 2 616 2 63 2 4 | 5 -1 3 6 10 | 3 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dp', 'graphs', '*2200'] |
E. Character Blockingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings of equal length s_1 and s_2, consisting of lowercase Latin letters, and an integer t.You need to answer q queries, numbered from 1 to q. The i-th query comes in the i-th s... | 2codeforcescodeblocks5 731 51 61 71 933coolclub2 52 1 2 2 32 2 2 2 41 233 | NO YES NO YES NO | 2 seconds | 256 megabytes | ['data structures', 'hashing', 'implementation', '*1600'] |
D. Wooden Toy Festivaltime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a small town, there is a workshop specializing in woodwork. Since the town is small, only three carvers work there.Soon, a wooden toy festival is planned in the town. The workshop employees wan... | 561 7 7 9 9 965 4 2 1 30 60914 19 37 59 1 4 4 98 731263 10 1 17 15 11 | 0 2 13 0 1 | 3 seconds | 256 megabytes | ['binary search', 'greedy', 'sortings', '*1400'] |
C. Ski Resorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDima Vatrushin is a math teacher at school. He was sent on vacation for n days for his good work. Dima has long dreamed of going to a ski resort, so he wants to allocate several consecutive days and go skii... | 73 1 15-5 0 -105 3 -338 12 9 0 54 3 1212 12 10 154 1 -50 -1 2 55 5 03 -1 4 -5 -31 1 556 1 30 3 -2 5 -4 -4 | 6 0 1 0 0 1 9 | 1 second | 256 megabytes | ['combinatorics', 'math', 'two pointers', '*1000'] |
B. Binary Cafetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time, Toma found himself in a binary cafe. It is a very popular and unusual place.The cafe offers visitors k different delicious desserts. The desserts are numbered from 0 to k-1. The cost of t... | 51 22 12 210 2179 100 | 2 2 3 4 180 | 1 second | 256 megabytes | ['bitmasks', 'combinatorics', 'math', '*1100'] |
A. Cipher Shifertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a string a (unknown to you), consisting of lowercase Latin letters, encrypted according to the following rule into string s: after each character of string a, an arbitrary (possibly zero) numbe... | 38abacabac5qzxcq20ccooddeeffoorrcceess | ac q codeforces | 1 second | 256 megabytes | ['implementation', 'strings', 'two pointers', '*800'] |
E. Decreasing Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Consider the following game for two players: Initially, an array of integers a_1, a_2, \ldots, a_n of length n is written on blackboard. Game consists of rounds. On eac... | 4
10 4 6 3
3
1
0 | First 1 2 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'interactive', '*2400'] |
D. Ball Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n colorful balls arranged in a row. The balls are painted in n distinct colors, denoted by numbers from 1 to n. The i-th ball from the left is painted in color c_i. You want to reorder the ball... | 362 3 1 4 6 531 2 3117 3 4 6 8 9 10 2 5 11 1 | 3 2 2 2 2 2 0 0 0 10 5 4 4 4 4 4 4 4 4 4 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'sortings', '*2100'] |
C. Insert Zero and Invert Prefixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a sequence a_1, a_2, \ldots, a_n of length n, each element of which is either 0 or 1, and a sequence b, which is initially empty.You are going to perform n operations. On each o... | 451 1 0 0 01130 1 161 0 0 1 1 0 | YES 0 0 2 1 3 NO NO YES 0 1 0 2 4 2 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1300'] |
B. Lampstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n lamps, numbered by integers from 1 to n. Each lamp i has two integer parameters a_i and b_i.At each moment each lamp is in one of three states: it may be turned on, turned off, or broken.Initially all... | 442 21 61 101 1353 43 12 53 23 361 23 41 43 43 52 311 1 | 15 14 20 1 | 1 second | 256 megabytes | ['greedy', 'sortings', '*1100'] |
A. The Good Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers n and k.An array a_1, a_2, \ldots, a_n of length n, consisting of zeroes and ones is good if for all integers i from 1 to n both of the following conditions are satisfied: at... | 73 25 29 37 110 49 58 8 | 2 3 4 7 4 3 2 | 1 second | 256 megabytes | ['greedy', 'implementation', 'math', '*800'] |
F. Stuck Conveyortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There is an n by n grid of conveyor belts, in positions (1, 1) through (n, n) of a coordinate plane. Every other square in the plane is empty. Each conveyor belt can be c... | 3
-1 -1
0 2 | ? 2 2 >>< >>v ^<< ? 1 1 >>< >>v ^<< ! 1 2 ^ | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'interactive', '*3000'] |
E. Count Supersequencestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers, where all elements a_i lie in the range [1, k]. How many different arrays b of m integers, where all elements b_i lie in the range [1, k], contain a as a s... | 71 1000000 113 4 31 2 25 7 81 2 3 4 16 6 1818 2 2 5 2 161 10 218 10 12345671 1 2 1 2 2 2 15 1000000000 1000000000525785549 816356460 108064697 194447117 725595511 | 1 9 1079 1 1023 906241579 232432822 | 3 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', '*2500'] |
D. Bracket Walktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a string s of length n consisting of the characters '(' and ')'. You are walking on this string. You start by standing on top of the first character of s, and you want to make a sequence of move... | 10 9
(())()()))
9
7
2
6
3
6
7
4
8
| YES YES NO NO YES NO YES NO NO | 3 seconds | 256 megabytes | ['data structures', 'greedy', 'strings', '*2100'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.