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. Fighting Tournamenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBurenka is about to watch the most interesting sporting event of the year — a fighting tournament organized by her friend Tonya.n athletes participate in the tournament, numbered from 1 to n. Bure... | 33 13 1 21 24 21 3 4 24 53 25 21 2 3 5 45 10000000004 6 | 2 0 1 0 4 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'implementation', 'two pointers', '*1400'] |
B. Mathematical Circustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new entertainment has appeared in Buryatia — a mathematical circus! The magician shows two numbers to the audience — n and k, where n is even. Next, he takes all the integers from 1 to n, and spl... | 44 12 012 1014 11 | YES 1 2 3 4 NO YES 3 4 7 8 11 12 2 1 6 5 10 9 YES 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
A. Chip Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBurenka and Tonya are playing an old Buryat game with a chip on a board of n \times m cells.At the beginning of the game, the chip is located in the lower left corner of the board. In one move, the player ca... | 61 11 45 62 26 3999999999 1000000000 | Tonya Burenka Burenka Tonya Burenka Burenka | 1 second | 256 megabytes | ['games', 'math', '*800'] |
F. Burenka, an Array and Queriestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEugene got Burenka an array a of length n of integers from 1 to m for her birthday. Burenka knows that Eugene really likes coprime integers (integers x and y such that they have only one... | 5 5 5 3
1 2 3 2 5
1 1
2 4
4 5
| 5 2 2 | 3 seconds | 256 megabytes | ['data structures', 'math', 'number theory', '*3300'] |
E. Impressionismtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBurenka has two pictures a and b, which are tables of the same size n \times m. Each cell of each painting has a color — a number from 0 to 2 \cdot 10^5, and there are no repeating colors in any row or ... | 3 3
1 0 2
0 0 0
2 0 1
2 0 1
0 0 0
1 0 2
| 1 1 1 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'implementation', 'math', '*3500'] |
D. Permutation for Burenkatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe call an array a pure if all elements in it are pairwise distinct. For example, an array [1, 7, 9] is pure, [1, 3, 3, 7] isn't, because 3 occurs twice in it.A pure array b is similar to a pu... | 44 31 4 3 25 0 7 069145 31 2 5 4 30 5 10 0 03 918115 21 4 3 2 50 0 0 0 07 9 1 561004 24 1 3 20 5 3 0246 | YES NO NO YES YES NO YES YES NO NO | 2 seconds | 256 megabytes | ['data structures', 'graph matchings', 'greedy', 'math', 'trees', '*3300'] |
C. Tonya and Burenka-179time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTonya was given an array of a of length n written on a postcard for his birthday. For some reason, the postcard turned out to be a cyclic array, so the index of the element located strictly to t... | 42 11 21 34 44 1 3 22 64 61 13 119 31 7 9 4 5 2 3 6 83 12 19 16 31 1 1 1 1 11 54 43 8 | 3 5 14 16 24 24 24 57 54 36 36 6 18 27 28 | 3 seconds | 256 megabytes | ['data structures', 'greedy', 'math', 'number theory', '*2400'] |
B. Fibonacci Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn all schools in Buryatia, in the 1 class, everyone is told the theory of Fibonacci strings."A block is a subsegment of a string where all the letters are the same and are bounded on the left and r... | 61121 121 233 1 327 5626 8 3 4 13 34 | YES YES NO YES NO YES | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', 'number theory', '*2000'] |
A2. Burenka and Traditions (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of this problem. The difference between easy and hard versions is only the constraints on a_i and on n. You can make hacks only if both versions of the p... | 745 5 5 531 3 220 032 5 761 2 3 3 2 11027 27 34 32 2 31 23 56 52 451822 1799 57 23 55 | 2 2 0 2 4 7 4 | 1 second | 256 megabytes | ['data structures', 'dp', 'greedy', '*1900'] |
A1. Burenka and Traditions (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of this problem. The difference between easy and hard versions is only the constraints on a_i and on n. You can make hacks only if both versions of the p... | 745 5 5 531 3 220 032 5 761 2 3 3 2 11027 27 34 32 2 31 23 56 52 451822 1799 57 23 55 | 2 2 0 2 4 7 4 | 1 second | 256 megabytes | ['dp', 'greedy', '*1800'] |
F. Madoka and The First Sessiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOh no, on the first exam Madoka got this hard problem:Given integer n and m pairs of integers (v_i, u_i). Also there is an array b_1, b_2, \ldots, b_n, initially filled with zeros.Then fo... | 5 5
1 1 1 1 1
-2 0 2 1 -1
1 5
1 4
3 5
3 4
4 5
| YES 1 5 1 4 5 3 4 3 5 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'flows', 'graph matchings', 'graphs', 'implementation', '*2500'] |
E. Madoka and The Best Universitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka wants to enter to "Novosibirsk State University", but in the entrance exam she came across a very difficult task:Given an integer n, it is required to calculate \sum{\operatorname... | 3
| 1 | 1 second | 256 megabytes | ['math', 'number theory', '*2200'] |
D. Madoka and The Corruption Schemetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka decided to entrust the organization of a major computer game tournament "OSU"!In this tournament, matches are held according to the "Olympic system". In other words, there are 2... | 1 1
| 2 | 1 second | 256 megabytes | ['combinatorics', 'constructive algorithms', 'greedy', 'math', '*1900'] |
C. Madoka and Formal Statementtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array of integer a_1, a_2, \ldots, a_n. In one operation you can make a_i := a_i + 1 if i < n and a_i \leq a_{i + 1}, or i = n and a_i \leq a_1.You need to check whether the array ... | 531 2 51 2 522 21 343 4 1 26 4 2 532 4 14 5 351 2 3 4 56 5 6 7 6 | YES NO NO NO YES | 1 second | 256 megabytes | ['greedy', '*1300'] |
B. Madoka and Underground Competitionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka decided to participate in an underground sports programming competition. And there was exactly one task in it:A square table of size n \times n, where n is a multiple of k, i... | 33 3 3 22 1 1 26 3 4 2 | X.. ..X .X. XX XX .X..X. X..X.. ..X..X .X..X. X..X.. ..X..X | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*1100'] |
A. Madoka and Strange Thoughtstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka is a very strange girl, and therefore she suddenly wondered how many pairs of integers (a, b) exist, where 1 \leq a, b \leq n, for which \frac{\operatorname{lcm}(a, b)}{\operatorname... | 612345100000000 | 1 4 7 10 11 266666666 | 1 second | 256 megabytes | ['math', 'number theory', '*800'] |
F. Bags with Ballstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n bags, each bag contains m balls with numbers from 1 to m. For every i \in [1, m], there is exactly one ball with number i in each bag.You have to take exactly one ball from each bag (all b... | 52 3 81 1 11 5 103 7 20001337666 42424242 2000 | 1028 1 3 729229716 652219904 | 3 seconds | 512 megabytes | ['combinatorics', 'dp', 'math', 'number theory', '*2500'] |
E. Swap and Maximum Blocktime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array of length 2^n. The elements of the array are numbered from 1 to 2^n.You have to process q queries to this array. In the i-th query, you will be given an integer k (0 \le ... | 3
-3 5 -3 2 8 -20 6 -1
3
1
0
1
| 18 8 13 | 4 seconds | 512 megabytes | ['bitmasks', 'data structures', 'dfs and similar', 'divide and conquer', 'dp', '*2500'] |
D. Chip Movetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a chip on the coordinate line. Initially, the chip is located at the point 0. You can perform any number of moves; each move increases the coordinate of the chip by some positive integer (which is ... | 8 1
| 1 1 2 2 3 4 5 6 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'math', '*2000'] |
C. Robot in a Hallwaytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a grid, consisting of 2 rows and m columns. The rows are numbered from 1 to 2 from top to bottom. The columns are numbered from 1 to m from left to right.The robot starts in a cell (1, 1).... | 430 0 14 3 250 4 8 12 162 6 10 14 1840 10 10 1010 10 10 1020 00 0 | 5 19 17 3 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'implementation', 'ternary search', '*2000'] |
B. Permutation Chaintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation of length n is a sequence of integers from 1 to n such that each integer appears in it exactly once.Let the fixedness of a permutation p be the number of fixed points in it — the numbe... | 223 | 2 1 2 2 1 3 1 2 3 3 2 1 3 1 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
A. 2-3 Movestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i. e., if your current coordinate is x, it can b... | 413412 | 2 1 2 4 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
F. Crop Squarestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Farmer Stanley grows corn on a rectangular field of size n \times m meters with corners in points (0, 0), (0, m), (n, 0), (n, m). This year the harvest was plentiful and c... | 3 3
0.5
0.5 | ? 4 0 0 2 0 2 3 0 3 ? 4 0 0 0 1 3 1 3 0 ! 1.5 0.5 | 1 second | 256 megabytes | ['constructive algorithms', 'geometry', 'interactive', 'math', '*2700'] |
E. Long Way Hometime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStanley lives in a country that consists of n cities (he lives in city 1). There are bidirectional roads between some of the cities, and you know how long it takes to ride through each of them. Addition... | 3 1 2
1 3 1
| 0 1 1 | 3 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'dp', 'geometry', 'graphs', 'greedy', 'shortest paths', '*2400'] |
D. 2+ doorstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Narrator has an integer array a of length n, but he will only tell you the size n and q statements, each of them being three integers i, j, x, which means that a_i \mid a_j = x, where | denotes the bit... | 4 3
1 2 3
1 3 2
4 1 2
| 0 3 2 2 | 1.5 seconds | 256 megabytes | ['2-sat', 'bitmasks', 'graphs', 'greedy', '*1900'] |
C. Monoblocktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStanley has decided to buy a new desktop PC made by the company "Monoblock", and to solve captcha on their website, he needs to solve the following task.The awesomeness of an array is the minimum number of b... | 5 5
1 2 3 4 5
3 2
4 2
3 1
2 1
2 2
| 29 23 35 25 35 | 1 second | 256 megabytes | ['combinatorics', 'data structures', 'implementation', 'math', '*1700'] |
B. Beautiful Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStanley defines the beauty of an array a of length n, which contains non-negative integers, as follows: \sum\limits_{i = 1}^{n} \left \lfloor \frac{a_{i}}{k} \right \rfloor, which means that we divide ... | 81 6 3 1003 6 3 123 6 3 195 4 7 385 4 7 8099978 1000000000 100000000 10000000000000000001 1 0 04 1000000000 1000000000 1000000000000000000 | -1 -1 0 0 19 0 3 3 3 29 -1 -1 0 0 0 0 1000000000000000000 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1000'] |
A. Crossmarkettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStanley and Megan decided to shop in the "Crossmarket" grocery store, which can be represented as a matrix with n rows and m columns. Stanley and Megan can move to an adjacent cell using 1 unit of power. T... | 77 55 71 1100000 10000057 2281 55 1 | 15 15 0 299998 340 5 5 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*800'] |
G. Path Prefixestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree. It contains n vertices, which are numbered from 1 to n. The root is the vertex 1.Each edge has two positive integer values. Thus, two positive integers a_j and b_j are given... | 491 5 64 5 12 9 104 2 11 2 12 3 36 4 38 1 341 1 1002 1 13 101 141 100 12 1 13 1 101101 1 42 3 52 5 13 4 33 1 55 3 55 2 11 3 26 2 1 | 0 3 1 2 1 1 2 3 0 0 3 1 2 2 0 1 2 1 1 2 2 1 1 | 3 seconds | 256 megabytes | ['binary search', 'data structures', 'dfs and similar', 'trees', '*1700'] |
F. Build a Tree and That Is Ittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is a connected undirected graph without cycles. Note that in this problem, we are talking about not rooted trees.You are given four positive integers n, d_{12}, d_{23} and d_{31}. C... | 95 1 2 15 2 2 25 2 2 35 2 2 45 3 2 34 2 1 14 3 1 14 1 2 37 1 4 1 | YES 1 2 4 1 3 1 2 5 YES 4 3 2 5 1 5 5 3 NO YES 2 4 4 1 2 5 5 3 YES 5 4 4 1 2 5 3 5 YES 2 3 3 4 1 3 NO YES 4 3 1 2 2 4 NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'trees', '*1900'] |
E. Add Modulo 10time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n integers a_1, a_2, \dots, a_nYou can apply the following operation an arbitrary number of times: select an index i (1 \le i \le n) and replace the value of the element a_i ... | 1026 1132 18 2255 10 5 10 541 2 4 824 5393 96 102240 6250 30222 4421 5 | Yes No Yes Yes No Yes No No Yes No | 2 seconds | 256 megabytes | ['brute force', 'math', 'number theory', '*1400'] |
D. Color with Occurrencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given some text t and a set of n strings s_1, s_2, \dots, s_n. In one step, you can choose any occurrence of any string s_i in the text t and color the corresponding characters of the t... | 6bababa2baabacaba2bacacababacabaca3ababacacabaca3acbcodeforces4defcodeefoforcesaaaabbbbcccceeee4eeeeccccaaaabbbb | 3 2 2 1 1 2 4 -1 4 1 1 2 6 3 3 3 7 4 3 1 1 2 2 3 1 4 2 4 5 2 1 4 3 1 4 5 2 9 1 13 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'dp', 'greedy', 'strings', '*1600'] |
C. Minimum Varied Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFind the minimum number with the given sum of digits s such that all digits in it are distinct (i.e. all digits are unique).For example, if s=20, then the answer is 389. This is the minimum numbe... | 42084510 | 389 8 123456789 19 | 1 second | 256 megabytes | ['greedy', '*800'] |
B. Remove Prefixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp was presented with some sequence of integers a of length n (1 \le a_i \le n). A sequence can make Polycarp happy only if it consists of different numbers (i.e. distinct numbers).In order to mak... | 543 1 4 351 1 1 1 11166 5 4 3 2 171 2 1 7 1 2 1 | 1 4 0 0 5 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', '*800'] |
A. Everyone Loves to Sleeptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad, like everyone else, loves to sleep very much.Every day Vlad has to do n things, each at a certain time. For each of these things, he has an alarm clock set, the i-th of them is triggered... | 31 6 138 03 6 012 3014 456 02 23 3520 1510 30 | 1 47 0 0 10 55 | 2 seconds | 256 megabytes | ['implementation', 'math', '*900'] |
F. Lost Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMy orzlers, we can optimize this problem from O(S^3) to O\left(T^\frac{5}{9}\right)!— Spyofgame, founder of Orzlim religionA long time ago, Spyofgame invented the famous array a (1-indexed) of length n that... | 3
0 2 1
| 1 2 3 | 1 second | 256 megabytes | ['bitmasks', 'combinatorics', 'constructive algorithms', 'dp', 'math', '*2900'] |
E. Cross Swappingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a square matrix A of size n \times n whose elements are integers. We will denote the element on the intersection of the i-th row and the j-th column as A_{i,j}.You can perform operations o... | 232 1 22 1 21 1 243 3 1 21 1 3 13 2 3 22 3 3 1 | 2 1 1 2 1 1 2 2 2 3 1 1 2 3 1 2 1 3 3 3 3 2 3 2 1 | 1 second | 256 megabytes | ['2-sat', 'data structures', 'dsu', 'greedy', 'matrices', '*2400'] |
D. Tournament Countdowntime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There was a tournament consisting of 2^n contestants. The 1-st contestant competed with the 2-nd, the 3-rd competed with the 4-th, and so on. After that, the winner... | 1
3
2
0
2
| ? 1 4 ? 1 6 ? 5 7 ! 7 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'interactive', 'number theory', 'probabilities', '*1800'] |
C. Build Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA \mathbf{0}-indexed array a of size n is called good if for all valid indices i (0 \le i \le n-1), a_i + i is a perfect square^\dagger.Given an integer n. Find a permutation^\ddagger p of [0,1,2,\ld... | 3347 | 1 0 2 0 3 2 1 1 0 2 6 5 4 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dp', 'math', '*1200'] |
B. Optimal Reductiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider an array a of n positive integers.You may perform the following operation: select two indices l and r (1 \leq l \leq r \leq n), then decrease all elements a_l, a_{l + 1}, \dots, a_r by 1.... | 342 3 5 431 2 343 1 3 2 | YES YES NO | 1 second | 256 megabytes | ['constructive algorithms', 'sortings', '*1000'] |
A. Traveling Salesman Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down).More formally, if you are st... | 340 -21 0-1 00 230 2-3 00 -110 0 | 12 12 0 | 1 second | 256 megabytes | ['geometry', 'greedy', 'implementation', '*800'] |
F. Triametertime limit per test4.5 secondsmemory limit per test768 megabytesinputstandard inputoutputstandard output — What is my mission? — To count graph diameters.You and Your SubmissionA tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each edge. The degree of a vertex ... | 4
1 2 2
4
1 2 3 4
| 1 2 2 2 | 4.5 seconds | 768 megabytes | ['binary search', 'data structures', 'dfs and similar', 'trees', '*3200'] |
E2. LCM Sum (hard version)time limit per test3.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe are sum for we are manySome NumberThis version of the problem differs from the previous one only in the constraint on t. You can make hacks only if both versions of the problem are solved... | 51 43 58 8668 866 86868 | 3 1 78975 969 109229059713337 | 3.5 seconds | 512 megabytes | ['brute force', 'data structures', 'math', 'number theory', 'two pointers', '*2500'] |
E1. LCM Sum (easy version)time limit per test3.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe are sum for we are manySome NumberThis version of the problem differs from the next one only in the constraint on t. You can make hacks only if both versions of the problem are solved.You... | 51 43 58 8668 866 86868 | 3 1 78975 969 109229059713337 | 3.5 seconds | 512 megabytes | ['binary search', 'brute force', 'combinatorics', 'math', 'number theory', 'two pointers', '*2300'] |
D. Empty Graphtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output — Do you have a wish? — I want people to stop gifting each other arrays.O_o and Another Young BoyAn array of n positive integers a_1,a_2,\ldots,a_n fell down on you from the skies, along with a positi... | 63 12 4 13 21 9 843 110 2 63 2179 17 10000000002 15 92 24 2 | 4 168 10 1000000000 9 1000000000 | 1.5 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', 'shortest paths', '*2000'] |
C. Sort Zerotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn array is sorted if it has no inversionsA Young BoyYou are given an array of n positive integers a_1,a_2,\ldots,a_n. In one operation you do the following: Choose any integer x. For all i such that a_i ... | 533 3 241 3 1 354 1 5 3 242 4 1 211 | 1 2 4 3 0 | 1 second | 256 megabytes | ['greedy', 'sortings', '*1100'] |
B. Woeful Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputI wonder, does the falling rain Forever yearn for it's disdain?Effluvium of the MindYou are given a positive integer n.Find any permutation p of length n such that the sum \operatorname{lcm}(1,p_1) ... | 212 | 1 2 1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'number theory', '*800'] |
A. Wonderful Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGod's Blessing on This PermutationForces!A Random PebbleYou are given a permutation p_1,p_2,\ldots,p_n of length n and a positive integer k \le n. In one operation you can choose two indices i an... | 43 12 3 13 31 2 34 23 4 1 21 11 | 1 0 2 0 | 1 second | 256 megabytes | ['greedy', 'implementation', '*800'] |
B. Partytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA club plans to hold a party and will invite some of its n members. The n members are identified by the numbers 1, 2, \dots, n. If member i is not invited, the party will gain an unhappiness value of a_i.There ... | 41 013 12 1 31 35 51 2 3 4 51 21 31 41 52 35 51 1 1 1 11 22 33 44 55 1 | 0 2 3 2 | 2 seconds | 256 megabytes | ['brute force', 'graphs', '*1300'] |
A. Perfect Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n.The weight of a permutation p_1, p_2, \ldots, p_n is the number of indices 1\le i\le n such that i divides p_i. Find a permutation p_1,p_2,\dots, p_n with the min... | 214 | 1 2 1 4 3 | 1 second | 256 megabytes | ['constructive algorithms', '*800'] |
E. Two Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays of integers a_1,a_2,\dots,a_n and b_1,b_2,\dots,b_m. Alice and Bob are going to play a game. Alice moves first and they take turns making a move.They play on a grid of size n \time... | 2 1
3 2
2
| 4 | 2 seconds | 256 megabytes | ['binary search', 'games', 'graph matchings', '*2400'] |
D. Recover the Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRhodoks has a tree with n vertices, but he doesn't remember its structure. The vertices are indexed from 1 to n.A segment [l,r] (1 \leq l \leq r \leq n) is good if the vertices with indices l, l + 1,... | 341111111101611111111111111111111112100100000001111000000011000000000100000000100100011110000100000100001001111101 | 1 2 2 3 2 4 1 2 2 3 3 4 4 5 5 6 2 3 6 7 10 11 2 4 6 8 10 12 1 4 5 8 9 12 5 12 2 12 | 3 seconds | 256 megabytes | ['constructive algorithms', 'trees', '*3400'] |
C. XOR Triangletime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Since n may be very large, you are given its binary representation.You should compute the number of triples (a,b,c) with 0 \leq a,b,c \leq n such that a \oplus b, b \o... | 101 | 12 | 4 seconds | 512 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dp', 'greedy', 'math', '*2500'] |
B. Raintime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are the owner of a harvesting field which can be modeled as an infinite line, whose positions are identified by integers.It will rain for the next n days. On the i-th day, the rain will be centered at positi... | 43 61 55 53 42 31 35 22 51 610 66 124 51 612 55 59 78 3 | 001 11 00 100110 | 4 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'geometry', 'greedy', 'implementation', 'math', '*2100'] |
A. Color the Picturetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA picture can be represented as an n\times m grid (n rows and m columns) so that each of the n \cdot m cells is colored with one color. You have k pigments of different colors. You have a limited amo... | 64 6 312 9 83 3 28 83 3 29 54 5 210 115 4 29 1110 10 311 45 14 | Yes No Yes Yes No No | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1500'] |
F. Multiset of Stringstime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given three integers n, k and f.Consider all binary strings (i. e. all strings consisting of characters 0 and/or 1) of length from 1 to n. For every such string s, you need to choose an in... | 1 42 2
| 3 | 6 seconds | 512 megabytes | ['bitmasks', 'brute force', 'dp', 'fft', 'flows', 'graphs', 'math', 'meet-in-the-middle', 'trees', '*2500'] |
E. XOR Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to a_i.Recall that a simple path is a path that visits each vertex at most once. Let the wei... | 6
3 2 1 3 2 1
4 5
3 4
1 4
2 1
6 1
| 2 | 3 seconds | 256 megabytes | ['bitmasks', 'data structures', 'dfs and similar', 'dsu', 'greedy', 'trees', '*2400'] |
D. Rorororobottime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a grid, consisting of n rows and m columns. The rows are numbered from 1 to n from bottom to top. The columns are numbered from 1 to m from left to right. The i-th column has the bottom a_i cells... | 11 10
9 0 0 10 3 4 8 11 10 8
6
1 2 1 3 1
1 2 1 3 2
4 3 4 5 2
5 3 11 5 3
5 3 11 5 2
11 9 9 10 1
| YES NO NO NO YES YES | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'math', '*1700'] |
C. Recover an RBStime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence (or, shortly, an RBS) is a bracket sequence that can be transformed into a correct arithmetic expressio... | 5(?))??????()???(?)()?) | YES NO YES YES NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'strings', '*1800'] |
B. Also Try Minecrafttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are beta testing the new secret Terraria update. This update will add quests to the game!Simply, the world map can be represented as an array of length n, where the i-th column of the world has... | 7 6
10 8 9 6 8 12 7
1 2
1 7
4 6
7 1
3 5
4 2
| 2 10 0 7 3 1 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'implementation', '*900'] |
A. Three Doorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are three doors in front of you, numbered from 1 to 3 from left to right. Each door has a lock on it, which can only be opened with a key with the same number on it as the number on the door.There a... | 430 1 210 3 223 1 021 3 0 | YES NO YES NO | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'math', '*800'] |
B. Difference of GCDstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers n, l, and r. You need to construct an array a_1,a_2,\dots,a_n (l\le a_i\le r) such that \gcd(i,a_i) are all distinct or report there's no solution.Here \gcd(x, y) denote... | 4
5 1 5
9 1000 2000
10 30 35
1 1000000000 1000000000
| YES 1 2 3 4 5 YES 1145 1926 1440 1220 1230 1350 1001 1000 1233 NO YES 1000000000 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1100'] |
A. Difference Operationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n positive integers.You are allowed to perform this operation any number of times (possibly, zero): choose an index i (2 \le i \le n), and change a_i to a... | 425 1031 2 341 1 1 199 9 8 2 4 4 3 5 3 | YES YES YES NO | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
F. Bugabootime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputA transformation of an array of positive integers a_1,a_2,\dots,a_n is defined by replacing a with the array b_1,b_2,\dots,b_n given by b_i=a_i\oplus a_{(i\bmod n)+1}, where \oplus denotes the bitwise XOR op... | 3 2 1 1
1 1
3 1
4
2 0 123456789
2 1 111111111
1 -1 987654321
3 -1 555555555
| 1 0 1 2 | 2 seconds | 1024 megabytes | ['bitmasks', 'constructive algorithms', 'dp', 'number theory', '*3500'] |
E. Replacetime limit per test1.5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given an integer array a_1,\ldots, a_n, where 1\le a_i \le n for all i.There's a "replace" function f which takes a pair of integers (l, r), where l \le r, as input and outputs the pair f\big( (l, ... | 5 6
2 5 4 1 3
4 4
1 5
1 4
3 5
4 5
2 3
| -1 0 1 2 3 4 | 1.5 seconds | 1024 megabytes | ['binary search', 'data structures', '*3500'] |
D. Partial Virtual Treestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKawashiro Nitori is a girl who loves competitive programming. One day she found a rooted tree consisting of n vertices. The root is vertex 1. As an advanced problem setter, she quickly thought o... | 4 998244353
1 2
2 3
1 4
| 1 6 6 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'dp', 'math', 'trees', '*3000'] |
C. DFS Treestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a connected undirected graph consisting of n vertices and m edges. The weight of the i-th edge is i.Here is a wrong algorithm of finding a minimum spanning tree (MST) of a graph:vis := an array... | 5 5
1 2
3 5
1 3
3 2
4 2
| 01111 | 1 second | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'greedy', 'sortings', 'trees', '*2400'] |
B. Difference Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n non-negative integers. It is guaranteed that a is sorted from small to large.For each operation, we generate a new array b_i=a_{i+1}-a_{i} for 1 \le i < n. The... | 531 10 10044 8 9 1350 0 0 8 1362 4 8 16 32 6470 0 0 0 0 0 0 | 81 3 1 2 0 | 1 second | 256 megabytes | ['brute force', 'data structures', 'implementation', 'sortings', '*1900'] |
A. Doremy's IQtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDoremy is asked to test n contests. Contest i can only be tested on day i. The difficulty of contest i is a_i. Initially, Doremy's IQ is q. On day i Doremy will choose whether to test contest i or not. She... | 51 112 11 23 11 2 14 21 4 3 15 25 1 2 4 3 | 1 11 110 1110 01111 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'implementation', '*1600'] |
E. Qpwoeirut and Verticestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a connected undirected graph with n vertices and m edges. Vertices of the graph are numbered by integers from 1 to n and edges of the graph are numbered by integers from 1 to m.Yo... | 32 1 21 21 11 25 5 51 21 32 43 43 51 43 42 22 53 53 2 11 32 31 3 | 0 1 3 3 0 5 5 2 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dfs and similar', 'divide and conquer', 'dsu', 'greedy', 'trees', '*2300'] |
D2. Chopping Carrots (Hard Version)time limit per test4 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the versions is the constraints on n, k, a_i, and the sum of n over all test cases. You can make hacks only if both... | 75 24 5 6 8 115 124 5 6 8 113 12 9 157 32 3 5 5 6 9 106 5654 286 527 1436 2450 26813 9516 340 22412 21 3 | 2 0 13 1 4 7 0 | 4 seconds | 64 megabytes | ['brute force', 'constructive algorithms', 'data structures', 'dp', 'greedy', 'math', 'number theory', 'two pointers', '*2400'] |
D1. Chopping Carrots (Easy Version)time limit per test4 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference between the versions is the constraints on n, k, a_i, and the sum of n over all test cases. You can make hacks only if both... | 75 24 5 6 8 115 124 5 6 8 113 12 9 157 32 3 5 5 6 9 106 5654 286 527 1436 2450 26813 9516 340 22412 21 3 | 2 0 13 1 4 7 0 | 4 seconds | 64 megabytes | ['binary search', 'brute force', 'constructive algorithms', 'greedy', 'number theory', '*1700'] |
C. Qpwoeirut And The Citytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputQpwoeirut has taken up architecture and ambitiously decided to remodel his city.Qpwoeirut's city can be described as a row of n buildings, the i-th (1 \le i \le n) of which is h_i floors high. Y... | 632 1 251 2 1 4 363 1 4 5 5 284 2 1 3 5 3 6 161 10 1 1 10 181 10 11 1 10 11 10 1 | 2 0 3 3 0 4 | 1 second | 256 megabytes | ['dp', 'flows', 'greedy', 'implementation', '*1400'] |
B. Making Towerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a sequence of n colored blocks. The color of the i-th block is c_i, an integer between 1 and n.You will place the blocks down in sequence on an infinite coordinate grid in the following way. I... | 671 2 3 1 2 3 164 2 2 2 4 41155 4 5 3 563 3 3 1 3 381 2 3 4 4 3 2 1 | 3 2 2 0 0 0 0 0 3 0 2 0 0 1 0 0 1 1 1 1 0 4 0 0 0 2 2 2 2 0 0 0 0 | 1 second | 256 megabytes | ['dp', 'greedy', 'math', '*1100'] |
A. Another String Minimization Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a sequence a_1, a_2, \ldots, a_n of length n, consisting of integers between 1 and m. You also have a string s, consisting of m characters B.You are going to perform the fo... | 64 51 1 3 11 524 11 1 1 12 41 32 77 54 55 5 3 5 | ABABA BABBB A AABB ABABBBB ABABA | 1 second | 256 megabytes | ['2-sat', 'constructive algorithms', 'greedy', 'string suffix structures', 'strings', '*800'] |
F. Mark and the Online Examtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMark is administering an online exam consisting of n true-false questions. However, he has lost all answer keys. He needs a way to retrieve the answers before his client gets infuriated.Fortu... | 3
1
3 | FTT TTF | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'interactive', 'probabilities', '*2900'] |
E. Mark and Professor Korotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of n positive integers a_1, a_2,\dots,a_n on it.Then, pr... | 5 4
2 2 2 4 5
2 3
5 3
4 1
1 4
| 6 5 4 5 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'combinatorics', 'data structures', 'greedy', '*2300'] |
D. Mark and Lightbulbstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMark has just purchased a rack of n lightbulbs. The state of the lightbulbs can be described with binary string s = s_1s_2\dots s_n, where s_i=\texttt{1} means that the i-th lightbulb is turned ... | 4401000010410100100501001000116000101010011 | 2 -1 -1 5 | 1.5 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', 'greedy', 'math', 'sortings', '*1800'] |
C. Mark and His Unfinished Essaytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne night, Mark realized that there is an essay due tomorrow. He hasn't written anything yet, so Mark decided to randomly copy-paste substrings from the prompt to make the essay.More for... | 24 3 3mark1 45 73 8110127 3 3creamii2 33 42 991112 | m a r e a r | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*1400'] |
B. Mark the Dust Sweepertime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMark is cleaning a row of n rooms. The i-th room has a nonnegative dust level a_i. He has a magical cleaning machine that can do the following three-step operation. Select two indices i<j su... | 432 0 050 2 0 2 062 0 3 0 4 640 0 0 10 | 3 5 11 0 | 1.5 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*900'] |
A. Mark the Photographertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMark is asked to take a group photo of 2n people. The i-th person has height h_i units.To do so, he ordered these people into two rows, the front row and the back row, each consisting of n people... | 33 61 3 9 10 12 163 12 5 2 2 2 51 28 6 | YES NO YES | 1 second | 256 megabytes | ['greedy', 'sortings', '*800'] |
H2. Game of AI (hard version)time limit per test12 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThis is the hard version of this problem. The difference between easy and hard versions is the constraint on k and the time limit. Notice that you need to calculate the answer for all pos... | 8 998244353
| 0 2 24 360 6800 153150 4057452 123391016 | 12 seconds | 1024 megabytes | ['combinatorics', 'fft', 'math', '*3500'] |
H1. Game of AI (easy version)time limit per test2.5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThis is the easy version of this problem. The difference between easy and hard versions is the constraint on k and the time limit. Also, in this version of the problem, you only need to ... | 1 998244353
| 0 | 2.5 seconds | 1024 megabytes | ['combinatorics', 'constructive algorithms', 'dp', 'fft', 'math', '*3200'] |
G. Mio and Lucky Arraytime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMio has an array a consisting of n integers, and an array b consisting of m integers. Mio can do the following operation to a: Choose an integer i (1 \leq i \leq n) that has not been chosen befor... | 5
5
1 2 3 4 5
5
2 0 6 0 10
5
1 2 3 4 5
3
3 5 3
8
-3 2 -3 -4 4 0 1 -2
4
10 -6 7 -7
5
1 2 3 4 5
4
1 10 1 1
5
0 0 0 0 0
2
10 12
| 1 1 1 4 5 1 3 4 6 8 -1 -1 | 5 seconds | 256 megabytes | ['constructive algorithms', 'fft', 'math', 'strings', '*3500'] |
F. Colouring Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. There are n cells in a row. Initially each cell is either red or blue. Alice goes first.On each turn, Alice chooses two neighbouring cells which contain at least one re... | 83BRB5RRBBB6RBRBRB8BBRRBRRB6BRRBRB12RBRBRBRBRRBB12RBRBRBRBBBRR4RBBR | Bob Bob Alice Alice Alice Alice Bob Bob | 1 second | 256 megabytes | ['constructive algorithms', 'dp', 'games', '*2600'] |
E. Count Secondstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCirno has a DAG (Directed Acyclic Graph) with n nodes and m edges. The graph has exactly one node that has no out edges. The i-th node has an integer a_i on it.Every second the following happens: Let S b... | 53 21 1 11 22 35 51 0 0 0 01 22 33 44 51 510 11998244353 0 0 0 998244353 0 0 0 0 01 22 33 44 55 66 77 88 99 101 37 95 61293 1145 9961 9961 19191 22 33 45 41 42 46 910 10 10 10 10 101 21 32 34 36 33 56 56 16 2 | 3 5 4 28010 110 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'dp', 'graphs', 'implementation', 'math', '*2200'] |
D. Magical Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEric has an array b of length m, then he generates n additional arrays c_1, c_2, \dots, c_n, each of length m, from the array b, by the following way:Initially, c_i = b for every 1 \le i \le n. Eric sec... | 7
3 9
0 1 2 0 0 2 1 1 0
0 1 1 1 2 0 0 2 0
0 1 2 0 0 1 2 1 0
3 7
25 15 20 15 25 20 20
26 14 20 14 26 20 20
25 15 20 15 20 20 25
3 9
25 15 20 15 25 20 20 20 20
26 14 20 14 26 20 20 20 20
25 15 20 15 25 15 20 20 25
3 11
25 15 20 15 25 20 20 20 20 20 20
26 14 20 14 26 20 20 20 20 20 20
25 15 20 15 25 20 15 20 20 20 25
3 13... | 3 1 3 10 3 15 3 20 3 25 3 30 1 1378716 | 2 seconds | 256 megabytes | ['constructive algorithms', 'hashing', 'implementation', 'math', '*1900'] |
C. Virustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n houses numbered from 1 to n on a circle. For each 1 \leq i \leq n - 1, house i and house i + 1 are neighbours; additionally, house n and house 1 are also neighbours.Initially, m of these n houses are... | 810 33 6 86 22 520 33 7 1241 51 11 21 31 4110 52 4 6 8 105 53 2 5 4 11000000000 111000000000 41 1000000000 10 16 | 7 5 11 28 9 5 2 15 | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*1200'] |
B. Luke is a Foodietime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuke likes to eat. There are n piles of food aligned in a straight line in front of him. The i-th pile contains a_i units of food. Luke will walk from the 1-st pile towards the n-th pile, and he wants... | 75 33 8 5 6 75 33 10 9 8 712 825 3 3 17 8 6 1 16 15 25 17 2310 21 2 3 4 5 6 7 8 9 108 22 4 6 8 6 4 12 148 22 7 8 9 6 13 21 2815 511 4 13 23 7 10 5 21 20 11 17 5 29 16 11 | 0 1 2 1 2 4 6 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', '*1000'] |
A. Two 0-1 Sequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAquaMoon has two binary sequences a and b, which contain only 0 and 1. AquaMoon can perform the following two operations any number of times (a_1 is the first element of a, a_2 is the second element ... | 106 2001001116 2110111016 2000001116 2111111018 510000101110107 4101000110018 6010100100100108 40101010110018 41010101001107 5101110011100 | YES YES NO NO NO YES YES NO NO YES | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*800'] |
G. Good Key, Bad Keytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n chests. The i-th chest contains a_i coins. You need to open all n chests in order from chest 1 to chest n.There are two types of keys you can use to open a chest: a good key, which cos... | 54 510 10 3 11 213 1210 10 2912 515 74 89 45 18 69 67 67 11 96 23 592 5785 60 | 11 0 13 60 58 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'greedy', 'math', '*1600'] |
F. Yet Another Problem About Pairs Satisfying an Inequalitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots a_n. Count the number of pairs of indices 1 \leq i, j \leq n such that a_i < i < a_j < j.InputThe first line contains an... | 581 1 2 3 8 2 1 421 2100 2 1 6 3 4 1 2 8 321 100000000030 1000000000 2 | 3 0 10 0 1 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', 'greedy', 'sortings', '*1300'] |
E. Mirror Gridtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a square grid with n rows and n columns. Each cell contains either 0 or 1. In an operation, you can select a cell of the grid and flip it (from 0 \to 1 or 1 \to 0). Find the minimum number o... | 5301011001010511100110110101110011110005010001010101010000100100151100100000111111011001111 | 1 0 9 7 6 | 2 seconds | 256 megabytes | ['implementation', '*1200'] |
D. Double Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings s_1, s_2, \dots, s_n of length at most \mathbf{8}. For each string s_i, determine if there exist two strings s_j and s_k such that s_i = s_j + s_k. That is, s_i is the concatena... | 35ababababcabacbc3xxxxxx8codeforcescodescodforcforcesecode | 10100 011 10100101 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'strings', '*1100'] |
C. Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuca has a cypher made up of a sequence of n wheels, each with a digit a_i written on it. On the i-th wheel, he made b_i moves. Each move is one of two types: up move (denoted by \texttt{U}): it increases the... | 339 3 13 DDD4 UDUU2 DU20 99 DDDDDDDDD9 UUUUUUUUU50 5 9 8 310 UUUUUUUUUU3 UUD8 UUDUUDDD10 UUDUUDUDDU4 UUUU | 2 1 1 9 0 0 4 9 6 9 | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*800'] |
B. ICPC Balloonstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn an ICPC contest, balloons are distributed as follows: Whenever a team solves a problem, that team gets a balloon. The first team to solve a problem gets an additional balloon. A contest has 26 pro... | 63ABA1A3ORZ5BAAAA4BKPT10CODEFORCES | 5 2 6 7 8 17 | 1 second | 256 megabytes | ['data structures', 'implementation', '*800'] |
A. YES or YES?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a string s of length 3, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes... | 10YESyESyesYesYeSNooorZyEzYasXES | YES YES YES YES YES NO NO NO NO NO | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*800'] |
G2. Passable Paths (hard version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. The only difference between an easy and a hard version is in the number of queries.Polycarp grew a tree from n vertices. We remind you that a tree... | 5
1 2
2 3
2 4
4 5
5
3
3 2 5
5
1 2 3 4 5
2
1 4
3
1 3 5
3
1 5 4
| YES NO YES NO YES | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*2000'] |
G1. Passable Paths (easy version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. The only difference between an easy and a hard version is in the number of queries.Polycarp grew a tree from n vertices. We remind you that a tre... | 5
1 2
2 3
2 4
4 5
5
3
3 2 5
5
1 2 3 4 5
2
1 4
3
1 3 5
3
1 5 4
| YES NO YES NO YES | 2 seconds | 256 megabytes | ['dfs and similar', 'trees', '*1900'] |
F. Equate Multisetstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMultiset —is a set of numbers in which there can be equal elements, and the order of the numbers does not matter. Two multisets are equal when each value occurs the same number of times. For example,... | 542 4 5 241 4 6 1131 4 174 5 3154 7 10 13 142 14 14 26 4252 2 4 4 428 46 62 71 9861 2 10 16 64 8020 43 60 74 85 99 | YES NO YES YES YES | 4 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'math', 'number theory', '*1700'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.