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 |
|---|---|---|---|---|---|
D. Jumping Through Segmentstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is designing a level for a game. The level consists of n segments on the number line, where the i-th segment starts at the point with coordinate l_i and ends at the point with coordi... | 451 53 45 68 100 130 20 10 333 810 186 11410 200 515 172 2 | 7 0 5 13 | 5 seconds | 256 megabytes | ['binary search', 'constructive algorithms', '*1400'] |
C. Removal of Unattractive Pairstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad found a string s consisting of n lowercase Latin letters, and he wants to make it as short as possible.To do this, he can remove any pair of adjacent characters from s any number of ... | 104aabc5abaca10avbvvcvvvd7abcdefg5dabbb8aacebeaa7bbbbacc6dacfcc6fdfcdc9dbdcfbbdc | 0 1 2 1 1 0 1 0 0 1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', 'strings', '*1200'] |
B. YetnotherrokenKeoardtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has a problem — his laptop keyboard is broken.Now, when he presses the 'b' key, it acts like an unusual backspace: it deletes the last (rightmost) lowercase letter in the typed string. If... | 12ARaBbbitBabyYetAnotherBrokenKeyboardBubbleImprobableabbreviableBbBBBusyasaBeeinaBedofBloomingBlossomsCoDEBARbIEScodeforcesbobebobbesbTheBBlackbboard | ity YetnotherrokenKeoard le Imprle revile usyasaeeinaedofloominglossoms CDARIES codeforces es helaoard | 1 second | 256 megabytes | ['data structures', 'implementation', 'strings', '*1000'] |
A. Rooktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you probably know, chess is a game that is played on a board with 64 squares arranged in an 8\times 8 grid. Columns of this board are labeled with letters from a to h, and rows are labeled with digits from 1 t... | 1d5 | d1 d2 b5 g5 h5 d3 e5 f5 d8 a5 d6 d7 c5 d4 | 1 second | 256 megabytes | ['implementation', '*800'] |
M. Triangle Constructiontime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a regular N-sided polygon. Label one arbitrary side as side 1, then label the next sides in clockwise order as side 2, 3, \dots, N. There are A_i special points on side i. These po... | 4
3 1 4 6
| 4 | 1 second | 1024 megabytes | ['greedy', 'math', '*1700'] |
L. Palindromic Parenthesestime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputConstruct a parentheses sequence consisting of N characters such that it is balanced and the length of its longest palindromic subsequence (LPS) is exactly K. Determine whether such a construc... | 6 4
| (())() | 1 second | 1024 megabytes | ['constructive algorithms', '*2500'] |
K. Deck-Building Gametime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are playing a deck-building game with your friend. There are N cards, numbered from 1 to N. Card i has the value of A_i.You want to build two decks; one for you and one for your friend. A card ... | 4
16 12 4 8
| 9 | 1 second | 1024 megabytes | ['divide and conquer', 'math', '*2500'] |
J. Count BFS Graphtime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are currently researching a graph traversal algorithm called the Breadth First Search (BFS). Suppose you have an input graph of N nodes (numbered from 1 to N). The graph is represented by an adjac... | 3
1 2 3
| 3 | 1 second | 1024 megabytes | ['combinatorics', 'dp', '*2100'] |
I. Contingency Plan 2time limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are working as a manager in The ICPC Company. In the company building, there are N computers (numbered from 1 to N). There are N - 1 cables, numbered from 1 to N - 1, that connect all the compu... | 3
1 2
3 2
| 1 3 1 | 1 second | 1024 megabytes | ['graph matchings', '*2900'] |
H. Twin Friendstime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou meet two new friends who are twins. The name of the elder twin is A, which consists of N characters. While the name of the younger twin is B, which consists of M characters. It is known that N \leq M... | 3 4
AMA
ANAB
| 9 | 1 second | 1024 megabytes | ['combinatorics', 'dp', '*2200'] |
G. Grid Game 2time limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are playing "Grid Game 2" with your friend. There is a grid with 10^9 rows (numbered from 1 to 10^9) and 10^9 columns (numbered from 1 to 10^9). The cell at row r and column c is denoted as (r, c).Eac... | 2
2 3
2 4
| FIRST | 1 second | 1024 megabytes | ['games', 'number theory', '*2900'] |
F. Maximize The Valuetime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a one-based array consisting of N integers: A_1, A_2, \cdots, A_N. Initially, the value of each element is set to 0.There are M operations (numbered from 1 to M). Operation i is repre... | 2 6
1 1 -50
1 2 -20
2 2 -30
1 1 60
1 2 40
2 2 10
5
1 1 6
2 1 6
1 1 3
2 1 3
1 1 2
| 100 50 0 0 -20 | 1 second | 1024 megabytes | ['data structures', 'sortings', '*2100'] |
E. Merge Not Sorttime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are currently researching the Merge Sort algorithm. Merge Sort is a sorting algorithm that is based on the principle of Divide and Conquer. It works by dividing an array into two subarrays of equal... | 3
3 1 4 5 2 6
| 3 1 6 4 5 2 | 1 second | 1024 megabytes | ['constructive algorithms', 'dp', '*1900'] |
D. Spaceship Explorationtime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputIn The ICPC Galaxy, there exists a zone filled with asteroids that is unsafe to enter. The map of the galaxy is represented in a 2D Cartesian coordinate system. The zone is in the shape of an N... | 5
0 2
2 0
4 0
4 4
2 4
5
6 1 6 3
2 5 0 0
3 5 3 -1
1 4 5 4
3 4 3 0
| 2 5.6055512755 8.48528137422 4 -1 | 3 seconds | 1024 megabytes | ['binary search', 'geometry', '*2800'] |
B. Button Pressingtime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given N buttons (numbered from 1 to N) and N lamps (numbered from 1 to N). Each lamp can either be on or off. Initially, lamp i is on if A_i = 1, and off if A_i = 0.Button i is connected to la... | 2
4
0101
0100
3
000
010
| YES NO | 1 second | 1024 megabytes | ['bitmasks', 'constructive algorithms', 'hashing', '*2600'] |
A. Easy As ABCtime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are playing a word puzzle. The puzzle starts with a 3 by 3 grid, where each cell contains either the letter A, B, or C.The goal of this puzzle is to find the lexicographically smallest possible word o... | BCB
CAC
BCB
| ABC | 1 second | 1024 megabytes | ['brute force', '*1000'] |
F. Field Should Not Be Emptytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation^{\dagger} p of length n.We call index x good if for all y < x it holds that p_y < p_x and for all y > x it holds that p_y > p_x. We call f(p) the number of good i... | 551 2 3 4 552 1 3 4 572 1 5 3 7 6 462 3 5 4 1 677 6 5 4 3 2 1 | 3 5 2 3 2 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'divide and conquer', '*2600'] |
E. One-Xtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn this sad world full of imperfections, ugly segment trees exist.A segment tree is a tree where each node represents a segment and has its number. A segment tree for an array of n elements can be built in a re... | 5234553278 | 6 17 36 69 593324855 | 3 seconds | 512 megabytes | ['combinatorics', 'dfs and similar', 'dp', 'math', 'trees', '*2400'] |
D. Cyclic MEXtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor an array a, define its cost as \sum_{i=1}^{n} \operatorname{mex} ^\dagger ([a_1,a_2,\ldots,a_i]).You are given a permutation^\ddagger p of the set \{0,1,2,\ldots,n-1\}. Find the maximum cost across all... | 465 4 3 2 1 032 1 082 3 6 7 0 1 4 510 | 15 5 31 1 | 2 seconds | 512 megabytes | ['data structures', 'implementation', 'math', 'two pointers', '*2000'] |
C. Largest Subsequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven is a string s of length n. In one operation you can select the lexicographically largest^\dagger subsequence of string s and cyclic shift it to the right^\ddagger. Your task is to calculate t... | 65aaabc3acb3bac4zbca15czddeneeeemigec13cdefmopqsvxzz | 0 1 -1 2 6 0 | 1 second | 256 megabytes | ['greedy', 'strings', '*1400'] |
B. Begginer's Zeldatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree^{\dagger}. In one zelda-operation you can do follows: Choose two vertices of the tree u and v; Compress all the vertices on the path from u to v into one vertex. In other words, a... | 441 21 33 493 13 53 25 66 77 87 96 471 21 32 44 53 62 761 21 31 44 52 6 | 1 3 2 2 | 1 second | 256 megabytes | ['greedy', 'trees', '*1100'] |
A. Constructive Problemstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGridlandia has been hit by flooding and now has to reconstruct all of it's cities. Gridlandia can be described by an n \times m matrix.Initially, all of its cities are in economic collapse. The g... | 32 25 73 2 | 2 7 3 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Beautiful Treetime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLunchbox has a tree of size n rooted at node 1. Each node is then assigned a value. Lunchbox considers the tree to be beautiful if each value is distinct and ranges from 1 to n. In addition, a beautifu... | 7 5
1 2
1 3
1 4
3 5
4 6
3 7
1 6 5 1
2 6 7 3
1 2 7 1
1 7 5 7
2 4 2 2
| 1 6 7 5 3 4 2 | 4 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'graphs', 'implementation', 'trees', '*2800'] |
E. Tree Queriestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThose who don't work don't eat. Get the things you want with your own power. But believe, the earnest and serious people are the ones who have the last laugh... But even then, I won't give you a present.... | 7 7
1 2
1 3
3 4
2 5
2 6
6 7
2 0
2 1 1
2 2 1 6
3 1 4
3 1 1
5 0
5 2 1 6
| 3 2 1 4 1 4 1 | 4 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'graphs', 'implementation', 'trees', '*2500'] |
D2. Set To Max (Hard Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only differences between the two versions of this problem are the constraints on n and the time limit. You can make hacks only if all versions o... | 551 2 3 2 41 3 3 2 453 4 2 2 43 4 3 4 453 2 1 1 13 3 3 2 221 11 231 1 22 1 2 | YES NO YES NO NO | 4 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'divide and conquer', 'greedy', 'implementation', 'sortings', '*1800'] |
D1. Set To Max (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only differences between the two versions of this problem are the constraints on n and the time limit. You can make hacks only if all versions o... | 551 2 3 2 41 3 3 2 453 4 2 2 43 4 3 4 453 2 1 1 13 3 3 2 221 11 231 1 22 1 2 | YES NO YES NO NO | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', '*1600'] |
C. Array Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers. In one operation, you must pick some (i, j) such that 1\leq i < j\leq |a| and append |a_i - a_j| to the end of the a (i.e. increase n by 1 and set a_n to |a... | 45 23 9 7 15 14 37 4 15 126 242 47 50 54 62 792 1500000000000000000 1000000000000000000 | 1 0 3 500000000000000000 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'sortings', 'two pointers', '*1400'] |
B. Collecting Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers and a score. If your score is greater than or equal to a_i, then you can increase your score by a_i and remove a_i from the array. For each index i, outp... | 4520 5 1 4 231434 7 1442115999999999 999999999 999999999 1000000000 1000000000 | 4 3 0 3 1 1 0 2 0 4 4 4 4 4 | 1 second | 256 megabytes | ['binary search', 'dp', 'greedy', 'sortings', 'two pointers', '*1100'] |
A. Forked!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLunchbox is done with playing chess! His queen and king just got forked again!In chess, a fork is when a knight attacks two pieces of higher value, commonly the king and the queen. Lunchbox knows that knights... | 42 10 03 31 13 11 34 40 08 04 21 43 4 | 2 1 2 0 | 2 seconds | 256 megabytes | ['brute force', 'implementation', '*900'] |
F. Babysittingtime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTheofanis wants to play video games, however he should also take care of his sister. Since Theofanis is a CS major, he found a way to do both. He will install some cameras in his house in order to make su... | 37 61 21 31 41 62 35 73 31 21 31 12 41 21 22 11 1 | 2 3 2 | 7 seconds | 256 megabytes | ['2-sat', 'binary search', 'data structures', 'graphs', 'trees', '*2500'] |
E. Geo Gametime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Theofanis and his sister are playing the following game. They have n points in a 2D plane and a starting point (s_x,s_y). Each player (starting from the first player) chooses... | 2
6
4 6
7 6
8 5
2 1
6 2
6 4
3 3
2
5
1
4
1 1
3 2
2 1
3 3
1 2
2
3
| Second 4 6 3 First 1 4 | 2.5 seconds | 256 megabytes | ['greedy', 'interactive', 'math', '*2000'] |
D2. Maximum And Queries (hard version)time limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the two versions is the constraint on n and q, the memory and time limits. You can make hacks only if all versi... | 4 21 3 7 5210 | 2 6 | 7 seconds | 512 megabytes | ['bitmasks', 'divide and conquer', 'dp', 'greedy', '*2500'] |
D1. Maximum And Queries (easy version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference between the two versions is the constraint on n and q, the memory and time limits. You can make hacks only if all versi... | 4 2
1 3 7 5
2
10
| 2 6 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'greedy', '*1700'] |
C. Theofanis' Nightmaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTheofanis easily gets obsessed with problems before going to sleep and often has nightmares about them. To deal with his obsession he visited his doctor, Dr. Emix.In his latest nightmare, he has a... | 461 -3 7 -6 2 542 9 -5 -38-3 -4 2 -5 1 10 17 231830 | 32 4 343 830 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1400'] |
B. StORage roomtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Cyprus, the weather is pretty hot. Thus, Theofanis saw this as an opportunity to create an ice cream company. He keeps the ice cream safe from other ice cream producers by locking it inside big storag... | 41040 3 3 53 0 3 73 3 0 75 7 7 050 7 7 5 57 0 3 2 67 3 0 3 75 2 3 0 45 6 7 4 030 0 10 0 01 0 0 | YES 7 YES 1 3 2 5 YES 5 2 3 0 4 NO | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'greedy', '*1200'] |
A. Halloumi Boxestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTheofanis is busy after his last contest, as now, he has to deliver many halloumis all over the world. He stored them inside n boxes and each of which has some number a_i written on it. He wants to sort... | 53 21 2 33 19 9 94 46 4 2 14 310 3 830 142 13 1 | YES YES YES YES NO | 1 second | 256 megabytes | ['brute force', 'greedy', 'sortings', '*800'] |
F. Trees and XOR Queries Againtime limit per test6.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices. There is an integer written on each vertex; the i-th vertex has integer a_i written on it.You have to process q queries. The i-th query con... | 40 1 2 102 13 24 283 3 03 4 13 4 71 3 11 3 21 3 101 4 101 4 11 | YES YES NO YES YES NO YES YES | 6.5 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'divide and conquer', 'graphs', 'implementation', 'math', 'trees', '*2400'] |
E. Collapsing Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings s_1, s_2, \dots, s_n, consisting of lowercase Latin letters. Let |x| be the length of string x.Let a collapse C(a, b) of two strings a and b be the following operation: if... | 3abaabba | 20 | 2 seconds | 256 megabytes | ['data structures', 'strings', 'trees', '*1900'] |
D. Robot Queriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an infinite 2-dimensional grid. Initially, a robot stands in the point (0, 0). The robot can execute four commands: U — move from point (x, y) to (x, y + 1); D — move from point (x, y) to (x,... | 8 3RDLLUURU-1 2 1 70 0 3 40 1 7 8 | YES YES NO | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', 'implementation', '*1900'] |
C. Insert and Equalizetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer array a_1, a_2, \dots, a_n, all its elements are distinct.First, you are asked to insert one more integer a_{n+1} into this array. a_{n+1} should not be equal to any of a_... | 331 2 351 -19 17 -3 -15110 | 6 27 1 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', 'number theory', '*1300'] |
B. Getting Pointstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is a student at Berland State University. Due to recent changes in the Berland education system, Monocarp has to study only one subject — programming.The academic term consists of n days, and i... | 51 5 5 214 3000000000 1000000000 500000000100 20 1 108 120 10 2042 280 13 37 | 0 12 99 0 37 | 1 second | 256 megabytes | ['binary search', 'brute force', 'greedy', '*1100'] |
A. Binary Imbalancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting only of characters '0' and/or '1'.In one operation, you choose a position i from 1 to |s| - 1, where |s| is the current length of string s. Then you insert a char... | 3200211210 | YES NO YES | 2 seconds | 256 megabytes | ['constructive algorithms', '*800'] |
F. Landscapingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are appointed to a very important task: you are in charge of flattening one specific road.The road can be represented as a polygonal line starting at (0, 0), ending at (n - 1, 0) and consisting of n v... | 50 5 1 3 00 1 3 2 0 | 8.000000000000 4.000000000000 6.000000000000 6.000000000000 6.000000000000 | 2 seconds | 256 megabytes | ['binary search', 'geometry', 'two pointers', '*2900'] |
E. Compressed Treetime limit per test2 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.You can perform the following operation any number of times (possibly zero): ... | 341 -2 2 11 23 22 42-2 -52 17-2 4 -2 3 3 2 -11 22 33 43 54 64 7 | 3 0 9 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'greedy', 'sortings', 'trees', '*2200'] |
D. Yet Another Monster Fighttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is a sorcerer that fights monsters. Again. There are n monsters standing in a row, the amount of health points of the i-th monster is a_i.Vasya is a very powerful sorcerer who knows ma... | 6
2 1 5 6 4 3
| 8 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', 'implementation', 'math', '*1700'] |
C. Add, Divide and Floortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer array a_1, a_2, \dots, a_n (0 \le a_i \le 10^9). In one operation, you can choose an integer x (0 \le x \le 10^{18}) and replace a_i with \lfloor \frac{a_i + x}{2} \rflo... | 411024 662 1 2 1 2 120 32 | 0 2 2 5 1 1 6 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1400'] |
B. Chip and Ribbontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a ribbon divided into n cells, numbered from 1 to n from left to right. Initially, an integer 0 is written in each cell.Monocarp plays a game with a chip. The game consists of several turns. ... | 441 2 2 151 0 1 0 155 4 3 2 1112 | 1 2 4 11 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1100'] |
A. Line Triptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a road, which can be represented as a number line. You are located in the point 0 of the number line, and you want to travel from the point 0 to the point x, and back to the point 0.You travel by c... | 33 71 2 53 61 2 51 107 | 4 3 7 | 2 seconds | 256 megabytes | ['greedy', 'math', '*800'] |
F. Local Deletionstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor an array b_1, b_2, \ldots, b_m, for some i (1 < i < m), element b_i is said to be a local minimum if b_i < b_{i-1} and b_i < b_{i+1}. Element b_1 is said to be a local minimum if b_1 < b_2. Elemen... | 7 5
1 4 3 6 2 7 5
1 1
1 2
2 3
1 4
1 7
| 1 1 3 3 3 | 3 seconds | 256 megabytes | ['binary search', 'data structures', 'implementation', '*2800'] |
E. Transitive Graphtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a directed graph G with n vertices and m edges between them.Initially, graph H is the same as graph G. Then you decided to perform the following actions: If there exists a triple of v... | 35 62 2 4 1 31 21 32 43 44 55 27 7999999999 999999999 999999999 999999999 1000000000 999999999 10000000001 22 33 44 14 54 66 714 222 3 5 7 3 4 1 4 3 4 2 2 5 11 22 32 43 14 44 55 65 65 126 76 87 57 77 98 49 1110 911 1011 1012 1313 1414 12 | 5 12 6 5999999995 11 37 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'dsu', 'graphs', 'implementation', '*2100'] |
D. Small GCDtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet a, b, and c be integers. We define function f(a, b, c) as follows:Order the numbers a, b, c in such a way that a \le b \le c. Then return \gcd(a, b), where \gcd(a, b) denotes the greatest common divisor... | 252 3 6 12 1786 12 8 10 15 12 18 16 | 24 203 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'math', 'number theory', '*2000'] |
C. Anji's Binary Treetime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKeksic keeps getting left on seen by Anji. Through a mutual friend, he's figured out that Anji really likes binary trees and decided to solve her problem in order to get her attention.Anji has gi... | 53LRU2 30 00 03ULR3 20 00 02LU0 20 04RULR3 00 00 42 07LLRRRLU5 23 60 07 04 00 00 0 | 0 1 1 3 1 | 2.5 seconds | 256 megabytes | ['dfs and similar', 'dp', 'trees', '*1300'] |
B. Laura and Operationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLaura is a girl who does not like combinatorics. Nemanja will try to convince her otherwise.Nemanja wrote some digits on the board. All of them are either 1, 2, or 3. The number of digits 1 is a.... | 31 1 12 3 282 47 59 | 1 1 1 0 1 0 1 0 0 | 2 seconds | 256 megabytes | ['dp', 'math', '*900'] |
A. Cover in Watertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFilip has a row of cells, some of which are blocked, and some are empty. He wants all empty cells to have water in them. He has two actions at his disposal: 1 — place water in an empty cell. 2 — remov... | 53...7##....#7..#.#..4####10#...#..#.# | 2 2 5 0 2 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'strings', '*800'] |
G. Unusual Entertainmenttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is a connected graph without cycles.A permutation is an array consisting of n distinct integers from 1 to n in any order. For example, [5, 1, 3, 2, 4] is a permutation, but [2, 1, 1] is n... | 33 51 22 31 2 31 2 21 2 32 3 11 2 32 3 310 102 62 72 41 72 810 68 59 43 410 2 5 9 1 7 6 4 3 88 9 87 8 17 10 64 8 95 5 107 10 19 9 29 10 66 6 210 10 61 111 1 1 | YES NO YES NO YES NO YES YES YES NO YES YES NO NO NO YES | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dsu', 'shortest paths', 'sortings', 'trees', 'two pointers', '*1900'] |
F. Alex's whimstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTree is a connected graph without cycles. It can be shown that any tree of n vertices has exactly n - 1 edges.Leaf is a vertex in the tree with exactly one edge connected to it.Distance between two vertic... | 33 32225 64234324 9233222322 | 1 2 2 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 2 2 3 3 4 4 5 -1 -1 -1 4 3 2 5 4 3 4 2 5 4 5 2 5 3 4 1 2 2 3 3 4 4 3 2 4 2 3 -1 -1 -1 4 3 2 -1 -1 -1 -1 -1 -1 4 2 3 4 3 2 -1 -1 -1 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'shortest paths', 'trees', '*1600'] |
E. Queue Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad found an array a of n integers and decided to sort it in non-decreasing order.To do this, Vlad can apply the following operation any number of times: Extract the first element of the array and insert ... | 556 4 1 2 574 5 3 7 8 6 264 3 1 2 6 445 2 4 232 2 3 | 2 6 -1 -1 0 | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*1300'] |
D. Yarik and Musical Notestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYarik is a big fan of many kinds of music. But Yarik loves not only listening to music but also writing it. He likes electronic music most of all, so he has created his own system of music note... | 51243 1 3 221000 100031 1 1192 4 1 6 2 8 5 4 2 10 5 10 8 7 4 3 2 6 10 | 0 2 1 3 19 | 1 second | 256 megabytes | ['hashing', 'math', 'number theory', '*1300'] |
C. Yarik and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA subarray is a continuous part of array.Yarik recently found an array a of n elements and became very interested in finding the maximum sum of a non empty subarray. However, Yarik doesn't like consecu... | 751 2 3 4 549 9 8 86-1 4 -1 0 5 -44-1 2 4 -31-10003101 -99 10120-10 5 -8 10 6 -10 7 9 -2 -6 7 2 -4 6 -1 7 -6 -7 4 1 | 15 17 8 4 -1000 101 10 | 1 second | 256 megabytes | ['dp', 'greedy', 'two pointers', '*1100'] |
B. 250 Thousand Tons of TNTtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex is participating in the filming of another video of BrMeast, and BrMeast asked Alex to prepare 250 thousand tons of TNT, but Alex didn't hear him well, so he prepared n boxes and arrange... | 521 2610 2 3 6 1 341000000000 1000000000 1000000000 10000000001560978 82265 78961 56708 39846 31071 4913 4769 29092 91348 64119 72421 98405 222 14294819957 69913 37531 96991 57838 21008 14207 19198 | 1 9 0 189114 112141 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'number theory', '*1100'] |
A. Game with Integerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVanya and Vova are playing a game. Players are given an integer n. On their turn, the player can add 1 to the current integer or subtract 1. The players take turns; Vanya starts. If after Vanya's mo... | 61351009991000 | First Second First First Second First | 1 second | 256 megabytes | ['games', 'math', 'number theory', '*800'] |
F. Vova Escapes the Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFollowing a world tour, Vova got himself trapped inside an n \times m matrix. Rows of this matrix are numbered by integers from 1 to n from top to bottom, and the columns are numbered by integ... | 84 4#..#..V.....#..#3 6#.#####....#####V#3 3####V####6 5#.####...####.##V..##.#####..#7 5######.V.##.#.##.#.##.#.##...##.#.#3 7#.....#.#####.#...V.#5 8####.####..V#..##...#..##...##.####.####5 5#...###.####V####.###...# | 9 0 0 3 4 10 12 5 | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'divide and conquer', 'shortest paths', '*2600'] |
E. Sofia and Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSofia has a string s of length n, consisting only of lowercase English letters. She can perform operations of the following types with this string. Select an index 1 \le i \le |s| and remove the ch... | 85 5sofiaafios3 2cbabc5 1sofiae15 7anavolimilovanaaamanan26 4abcdefghijklmnopqrstuvwxyznope26 4zyxwvutsrqponmlkjihgfedcbanope7 3apricotcat3 3cbaacb | YES YES NO YES NO YES NO YES | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'sortings', 'strings', 'two pointers', '*2200'] |
D. Absolute Beautytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKirill has two integer arrays a_1,a_2,\ldots,a_n and b_1,b_2,\ldots,b_n of length n. He defines the absolute beauty of the array b as \sum_{i=1}^{n} |a_i - b_i|. Here, |x| denotes the absolute value o... | 631 3 53 3 321 21 221 22 141 2 3 45 6 7 8101 8 2 5 3 5 3 1 1 32 9 2 4 8 2 3 5 3 1347326 6958 3586533587 35863 59474 | 4 2 2 16 31 419045 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1900'] |
C. Colorful Gridtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputElena has a grid formed by n horizontal lines and m vertical lines. The horizontal lines are numbered by integers from 1 to n from top to bottom. The vertical lines are numbered by integers from 1 to m ... | 54 5 113 3 23 4 10000000003 3 125884 4 8 | YES R R B B R R R R B B B R R R B B R B B R B R B B B B B B R R R NO NO YES R B B B B R B B R R B B YES B B R R B R B R R R R B B R R B B B B B B R R R | 2 seconds | 256 megabytes | ['constructive algorithms', '*1700'] |
B. Milena and Admirertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMilena has received an array of integers a_1, a_2, \ldots, a_n of length n from a secret admirer. She thinks that making it non-decreasing should help her identify the secret admirer.She can use the... | 431 3 241 2 3 433 2 171 4 4 3 5 7 6 | 1 0 3 9 | 1 second | 256 megabytes | ['greedy', 'math', '*1500'] |
A. Milica and Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMilica has a string s of length n, consisting only of characters A and B. She wants to modify s so it contains exactly k instances of B. In one operation, she can do the following: Select an integer... | 5
5 2
AAABB
5 3
AABAB
5 0
BBBBB
3 0
BAA
10 3
BBBABBBBAB
| 0 1 1 B 1 5 A 1 2 A 1 6 A | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*800'] |
H2. Cyclic Hamming (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the two versions is the constraint on k. You can make hacks only if all versions of the problem are solved.In this s... | 1
0011
0101
| 1 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'fft', 'math', 'number theory', '*3500'] |
H1. Cyclic Hamming (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference between the two versions is the constraint on k. You can make hacks only if all versions of the problem are solved.In this s... | 1
0011
0101
| 1 | 2 seconds | 256 megabytes | ['brute force', 'divide and conquer', 'dp', 'fft', 'math', 'number theory', '*3400'] |
G. Pepe Racingtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There are n^2 pepes labeled 1, 2, \ldots, n^2 with pairwise distinct speeds. You would like to set up some races to find out the relative speed of these pepes.In one race, y... | 1
2
2
4
4
3
2 | ? 1 2 ? 3 4 ? 2 4 ? 2 3 ? 2 1 ! 4 3 2 | 5 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'interactive', 'sortings', '*3200'] |
F. Bracket Xoringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string s of length 2n where each element is \mathtt{0} or \mathtt{1}. You can do the following operation: Choose a balanced bracket sequence^\dagger b of length 2n. For every in... | 4101200003100111401011100 | -1 2 ()() ()() 1 (())() 2 (((()))) ()()(()) | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*2600'] |
E. Permutation Sortingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation^\dagger a of size n. We call an index i good if a_i=i is satisfied. After each second, we rotate all indices that are not good to the right by one position. Formally, ... | 253 2 4 1 562 1 4 6 5 3 | 1 0 1 1 0 2 1 2 1 0 1 | 4 seconds | 256 megabytes | ['data structures', 'sortings', '*2100'] |
D. Ones and Twostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a 1-indexed array a of length n where each element is 1 or 2.Process q queries of the following two types: "1 s": check if there exists a subarray^{\dagger} of a whose sum equals to s. ... | 25 52 1 2 1 21 51 61 72 4 21 73 22 2 21 61 5 | YES YES NO YES YES NO | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'divide and conquer', 'math', 'two pointers', '*1700'] |
C. Matching Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b of size n. The beauty of the arrays a and b is the number of indices i such that a_i > b_i.You are also given an integer x. Determine whether it is possible to rearran... | 71 0121 1123 02 4 34 1 23 12 4 34 1 23 22 4 34 1 23 32 4 34 1 25 26 4 5 6 29 7 9 1 1 | YES 2 NO NO YES 2 4 1 YES 4 1 2 NO YES 1 9 9 7 1 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'sortings', '*1400'] |
B. AB Flippingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of length n consisting of characters \texttt{A} and \texttt{B}. You are allowed to do the following operation: Choose an index 1 \le i \le n - 1 such that s_i = \texttt{A} and s_{... | 32AB4BBBA4AABB | 1 0 3 | 1 second | 256 megabytes | ['greedy', 'strings', 'two pointers', '*900'] |
A. Jagged Swapstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation^\dagger a of size n. You can do the following operation Select an index i from 2 to n - 1 such that a_{i - 1} < a_i and a_i > a_{i+1}. Swap a_i and a_{i+1}. Determine whether... | 631 2 351 3 2 5 455 4 3 2 133 1 242 3 1 455 1 2 3 4 | YES YES NO NO NO NO | 1 second | 256 megabytes | ['sortings', '*800'] |
G. Two Characters, Two Colorstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string consisting of characters 0 and/or 1. You have to paint every character of this string into one of two colors, red or blue.If you paint the i-th character red, you get... | 4701000106 6 6 7 7 6 63 3 5 4 7 6 75101119 8 5 7 54 4 7 8 41001000000007 7 6 5 2 2 5 3 8 38 6 9 6 6 8 9 7 7 98010100008 7 7 7 8 7 7 84 4 4 2 1 4 4 4 | 43 36 76 52 | 4 seconds | 512 megabytes | ['binary search', 'data structures', 'dp', 'flows', 'greedy', '*3100'] |
F. Fancy Arraystime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's call an array a of n non-negative integers fancy if the following conditions hold: at least one from the numbers x, x + 1, ..., x+k-1 appears in the array; consecutive elements of the array diff... | 43 0 11 4 254 7 21000000000 40 1000000000 | 9 25 582 514035484 | 4 seconds | 512 megabytes | ['combinatorics', 'dp', 'math', 'matrices', '*2600'] |
E. Infinite Card Gametime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp and Bicarp are playing a card game. Each card has two parameters: an attack value and a defence value. A card s beats another card t if the attack of s is strictly greater than the defence... | 338 7 47 1 1028 45 1098 8 5 5 5 4 4 1 42 7 5 2 8 9 7 1 9109 8 7 6 5 5 4 3 2 17 1 6 7 5 8 8 4 9 611051105 | 1 1 1 2 4 3 0 1 0 | 3 seconds | 512 megabytes | ['binary search', 'brute force', 'data structures', 'dfs and similar', 'dp', 'dsu', 'games', 'graphs', 'greedy', 'sortings', 'two pointers', '*2300'] |
D. XOR Constructiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given n-1 integers a_1, a_2, \dots, a_{n-1}.Your task is to construct an array b_1, b_2, \dots, b_n such that: every integer from 0 to n-1 appears in b exactly once; for every i from 1 to n... | 42 1 2 | 0 2 3 1 | 2 seconds | 512 megabytes | ['bitmasks', 'constructive algorithms', 'data structures', 'math', 'string suffix structures', 'trees', '*1900'] |
C. Torn Lucky Tickettime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA ticket is a non-empty string of digits from 1 to 9.A lucky ticket is such a ticket that: it has an even length; the sum of digits in the first half is equal to the sum of digits in the second h... | 105 93746 59 3746 593 746 5937 46 59374 6 | 20 | 2 seconds | 512 megabytes | ['brute force', 'dp', 'hashing', 'implementation', 'math', '*1400'] |
B. Points and Minimum Distancetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a sequence of integers a of length 2n. You have to split these 2n integers into n pairs; each pair will represent the coordinates of a point on a plane. Each number from the ... | 2215 1 10 5310 30 20 20 30 10 | 9 10 1 15 5 20 20 20 10 30 10 30 | 2 seconds | 512 megabytes | ['greedy', 'math', 'sortings', '*800'] |
A. Treasure Chesttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp has found a treasure map. The map represents the treasure location as an OX axis. Monocarp is at 0, the treasure chest is at x, the key to the chest is at y.Obviously, Monocarp wants to open t... | 35 7 210 5 05 8 2 | 7 10 9 | 2 seconds | 512 megabytes | ['math', '*800'] |
B. Two Out of Threetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n. You need to find an array b_1, b_2, \ldots, b_n consisting of numbers 1, 2, 3 such that exactly two out of the following three conditions are satisfied: ... | 961 2 3 2 2 377 7 7 7 7 7 741 1 2 271 2 3 4 5 6 752 3 3 3 231 2 191 1 1 7 7 7 9 9 9111893 84 50 21 88 52 16 50 63 1 30 85 29 67 63 58 37 69 | 1 2 3 1 1 1 -1 3 2 2 1 -1 2 1 2 1 3 -1 1 1 2 2 1 2 2 3 3 -1 3 2 1 3 3 3 3 2 2 1 1 2 3 1 3 1 1 2 | 3 seconds | 512 megabytes | ['constructive algorithms', '*1000'] |
A. Secret Sporttime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's consider a game in which two players, A and B, participate. This game is characterized by two positive integers, X and Y.The game consists of sets, and each set consists of plays. In each play, exa... | 75ABBAA3BBB7BBAAABA20AAAAAAAABBBAABBBBBAB1A13AAAABABBABBAB7BBBAAAA | A B A B A B A | 3 seconds | 512 megabytes | ['implementation', 'strings', '*800'] |
E. Cacti Symphonytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an undirected connected graph in which any two distinct simple cycles do not have common vertices. Since the graph can be very large, it is given to you in a compressed form: for each edg... | 3 3
1 2 0
2 3 0
3 1 0
| 12 | 3 seconds | 512 megabytes | ['combinatorics', 'dfs and similar', 'dp', 'graphs', '*3500'] |
D. Colorful Constructivetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have n colored cubes, the i-th cube has color a_i.You need to distribute all the cubes on shelves. There are a total of m shelves, the i-th shelf can hold s_i cubes. Also, s_1 + s_2 + \ldots... | 610 31 1 1 1 2 2 2 3 3 46 2 24 1 18 27 7 7 7 8 8 8 84 42 25 15 4 3 2 1537 31 2 2 2 2 3 41 2 41 2 412 76 6 6 6 6 6 6 6 6 7 8 92 2 2 2 2 1 11 2 2 2 1 1 120 211 20 15 6 8 18 12 16 8 20 10 12 3 12 20 11 15 8 17 178 123 5 | 1 3 4 2 1 3 1 1 2 2 8 7 8 7 8 7 8 7 2 4 5 3 1 -1 6 6 7 6 8 6 9 6 6 6 6 6 12 17 20 15 8 20 16 11 15 20 17 12 10 8 3 18 12 11 8 6 | 3 seconds | 512 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*2600'] |
C. Freedom of Choicetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's define the anti-beauty of a multiset \{b_1, b_2, \ldots, b_{len}\} as the number of occurrences of the number len in the multiset.You are given m multisets, where the i-th multiset contains n_... | 733 5 610 11 123 3 11 1 31242 4 412 131 517 1000 10061000 1001 1002 1003 1004 1005 1006147 145 143 143 143 143 14212 48 5048 5025 2521 1 1111 1 12111 1 11221 1 1112 1 11 21 124 8 1011 12 13 143 3 3 32 3 411 122 2 | 1 139 0 1 1 0 0 | 3 seconds | 512 megabytes | ['brute force', 'greedy', 'implementation', '*2000'] |
B. Neutral Tonalitytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers, as well as an array b consisting of m integers.Let \text{LIS}(c) denote the length of the longest increasing subsequence of array c. For example, \t... | 72 16 455 51 7 2 4 55 4 1 2 71 971 2 3 4 5 6 7 8 93 21 3 52 410 51 9 2 3 8 1 4 7 2 97 8 5 4 62 12 216 11 1 1 1 1 1777 | 6 5 4 1 1 7 7 2 2 4 4 5 5 9 8 7 7 6 5 4 3 2 1 1 3 5 2 4 1 9 2 3 8 8 1 4 4 7 7 2 9 6 5 2 2 1 777 1 1 1 1 1 1 | 3 seconds | 512 megabytes | ['constructive algorithms', 'greedy', 'sortings', 'two pointers', '*1700'] |
A. Anonymous Informanttime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array b_1, b_2, \ldots, b_n.An anonymous informant has told you that the array b was obtained as follows: initially, there existed an array a_1, a_2, \ldots, a_n, after which the ... | 65 34 3 3 2 33 1007 2 15 56 1 1 1 11 100000000018 489 10 11 12 13 14 15 82 11 42 | Yes Yes No Yes Yes No | 3 seconds | 512 megabytes | ['brute force', 'dfs and similar', 'graphs', 'implementation', '*1400'] |
F. A Growing Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree with the root at vertex 1, initially consisting of a single vertex. Each vertex has a numerical value, initially set to 0. There are also q queries of two types: The first... | 392 1 31 12 2 11 12 3 21 32 1 41 32 3 252 1 11 12 1 -11 12 1 151 11 12 1 12 1 32 2 10 | 7 5 8 6 2 1 0 1 4 14 4 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*2000'] |
E. Brukhovich and Examstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe boy Smilo is learning algorithms with a teacher named Brukhovich.Over the course of the year, Brukhovich will administer n exams. For each exam, its difficulty a_i is known, which is a non-neg... | 95 21 3 5 7 95 23 5 7 9 118 217 15 10 1 1 5 14 85 31 1 1 1 15 51 1 1 1 119 71 1 2 3 4 5 5 6 6 7 8 9 10 1 1 1 2 3 115 62 1 1 1 1 2 1 1 2 1 1 1 2 1 25 21 1 1 1 25 21 0 1 0 1 | 1 0 2 2 0 5 5 2 1 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', 'math', 'sortings', '*2500'] |
D. Suspicious logarithmstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet f(x) be the floor of the binary logarithm of x. In other words, f(x) is largest non-negative integer y, such that 2^y does not exceed x.Let g(x) be the floor of the logarithm of x with base f... | 12
4 6
4 7
4 8
4 100000
179 1000000000000000000
57 179
4 201018959
7 201018960
729 50624
728 50624
728 50625
729 50625
| 6 8 9 348641 41949982 246 1 0 149688 149690 149694 149692 | 1 second | 256 megabytes | ['binary search', 'brute force', 'math', '*1900'] |
C. Smilo and Monsterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy called Smilo is playing a new game! In the game, there are n hordes of monsters, and the i-th horde contains a_i monsters. The goal of the game is to destroy all the monsters. To do this, you ... | 441 3 1 141 2 1 163 2 1 5 2 421 6 | 4 4 11 5 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'sortings', 'two pointers', '*1500'] |
B. Deja Vutime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n, consisting of positive integers, and an array x of length q, also consisting of positive integers.There are q modification. On the i-th modification (1 \leq i \leq q), fo... | 45 31 2 3 4 42 3 47 37 8 12 36 48 6 310 4 25 42 2 2 2 21 1 1 15 51 2 4 8 165 2 3 4 1 | 1 2 3 6 6 7 10 14 38 58 6 3 3 3 3 3 3 1 3 7 11 19 | 2 seconds | 256 megabytes | ['brute force', 'math', 'sortings', '*1100'] |
A. Sorting with Twostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of integers a_1, a_2, \ldots, a_n. In one operation, you do the following: Choose a non-negative integer m, such that 2^m \leq n. Subtract 1 from a_i for all integers i, su... | 851 2 3 4 556 5 3 4 496 5 5 7 5 6 6 8 744 3 2 162 2 4 5 3 281 3 17 19 27 57 179 1353 17 57 179 92101 2 3 4 0 6 7 8 9 10 | YES YES YES NO NO NO YES YES | 2 seconds | 256 megabytes | ['constructive algorithms', 'sortings', '*800'] |
B. Qingshan Loves Stringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputQingshan has a string s, while Daniel has a string t. Both strings only contain \texttt{0} and \texttt{1}.A string a of length k is good if and only if a_i \ne a_{i+1} for all i=1,2,\ldots,k-1.... | 51 1103 31110103 2111006 7101100101010110 2100100100010 | Yes Yes No No No | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
A. Doremy's Paint 3time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn array b_1, b_2, \ldots, b_n of positive integers is good if all the sums of two adjacent elements are equal to the same value. More formally, the array is good if there exists a k such that b_1 + b... | 528 931 1 241 1 4 552 3 3 3 34100000 100000 100000 100000 | Yes Yes No No Yes | 1 second | 256 megabytes | ['constructive algorithms', '*800'] |
F. Doremy's Average Treetime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputDoremy has a rooted tree of size n whose root is vertex r. Initially there is a number w_i written on vertex i. Doremy can use her power to perform this operation at most k times: Choose a ver... | 46 1 11 9 2 6 1 81 21 32 43 63 57 7 23 1 3 3 1 1 27 17 27 41 52 34 66 5 13 1 3 1 1 35 35 15 63 41 23 2 11000000 999999 9999972 11 3 | 1 2 2 1 4 1 5 1 1 | 3 seconds | 1024 megabytes | ['data structures', 'dp', 'greedy', 'trees', '*3500'] |
E. Doremy's Swapping Treestime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputConsider two undirected graphs G_1 and G_2. Every node in G_1 and in G_2 has a label. Doremy calls G_1 and G_2 similar if and only if: The labels in G_1 are distinct, and the labels in G_2 a... | 321 22 131 32 32 32 141 22 33 44 22 11 3 | 1 2 4 | 2 seconds | 1024 megabytes | ['dfs and similar', 'graphs', 'trees', '*3500'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.