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. Almost All Multiplestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven two integers n and x, a permutation^{\dagger} p of length n is called funny if p_i is a multiple of i for all 1 \leq i \leq n - 1, p_n = 1, and p_1 = x.Find the lexicographically minimal^{\d...
33 34 25 4
3 2 1 2 4 3 1 -1
1 second
256 megabytes
['greedy', 'number theory', '*1400']
B. XOR = Averagetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n. Find a sequence of n integers a_1, a_2, \dots, a_n such that 1 \leq a_i \leq 10^9 for all i and a_1 \oplus a_2 \oplus \dots \oplus a_n = \frac{a_1 + a_2 + \dots + a_n}{n}, whe...
3143
69 13 2 8 1 7 7 7
1 second
256 megabytes
['constructive algorithms', '*900']
A. SSeeeeiinngg DDoouubblleetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA palindrome is a string that reads the same backward as forward. For example, the strings \texttt{z}, \texttt{aaa}, \texttt{aba}, and \texttt{abccba} are palindromes, but \texttt{codeforces}...
4asururuerrorgornanutforajaroftuna
aa suurruurruus rgnororerrerorongr aannuuttffoorraajjaarrooffttuunnaa
1 second
256 megabytes
['constructive algorithms', 'strings', '*800']
B. Kevin and Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor his birthday, Kevin received the set of pairwise distinct numbers 1, 2, 3, \ldots, n as a gift.He is going to arrange these numbers in a way such that the minimum absolute difference between ...
243
2 4 1 3 1 2 3
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*800']
A. Technical Supporttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou work in the quality control department of technical support for a large company. Your job is to make sure all client issues have been resolved.Today you need to check a copy of a dialog between a...
54QQAA4QQAQ3QAA1Q14QAQQAQAAQQQAAA
Yes No Yes No Yes
1 second
256 megabytes
['greedy', '*800']
F. Minecraft Seriestime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLittle Misha goes to the programming club and solves nothing there. It may seem strange, but when you find out that Misha is filming a Minecraft series, everything will fall into place...Misha is ins...
2 2 1 2 1 1 2
0
6 seconds
512 megabytes
['brute force', 'two pointers', '*3500']
E. N Machinestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have been invited as a production process optimization specialist to some very large company. The company has n machines at its factory, standing one behind another in the production chain. Each machine...
3 2 1 3 * 2 + 1 + 1
6
1 second
256 megabytes
['binary search', 'brute force', 'greedy', '*3300']
D. The Beachtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew loves the sea. That's why, at the height of the summer season, he decided to go to the beach, taking a sunbed with him to sunbathe.The beach is a rectangular field with n rows and m columns. Some cell...
2 55 2.LR####LR.
4
1 second
256 megabytes
['constructive algorithms', 'dfs and similar', 'graphs', 'shortest paths', '*2400']
C. Wish I Knew How to Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary array a (all elements of the array are 0 or 1) of length n. You wish to sort this array, but unfortunately, your algorithms teacher forgot to teach you sorting algorithm...
330 1 050 0 1 1 161 1 1 0 0 1
3 0 249561107
2 seconds
256 megabytes
['dp', 'math', 'probabilities', '*2000']
B. Factorial Divisibilitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer x and an array of integers a_1, a_2, \ldots, a_n. You have to determine if the number a_1! + a_2! + \ldots + a_n! is divisible by x!.Here k! is a factorial of k — the p...
6 4 3 2 2 2 3 3
Yes
2 seconds
256 megabytes
['math', 'number theory', '*1600']
A2. Make Nonzero Sum (hard version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference is that in this version the array contains zeros. You can make hacks only if both versions of the problem are solved.You are gi...
540 0 0 07-1 1 0 1 0 1 050 -1 1 0 131 0 111
4 1 1 2 2 3 3 4 4 4 1 1 2 2 3 5 6 7 -1 2 1 1 2 3 -1
2 seconds
256 megabytes
['constructive algorithms', 'dp', 'greedy', '*1500']
A1. Make Nonzero Sum (easy version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference is that in this version the array can not contain zeros. You can make hacks only if both versions of the problem are solved.You...
441 1 1 16-1 1 1 1 1 131 -1 111
1 1 4 2 1 3 4 6 -1 -1
2 seconds
256 megabytes
['constructive algorithms', 'dp', 'greedy', '*1300']
H. BinaryStringForcestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string s of length n. We define a maximal substring as a substring that cannot be extended while keeping all elements equal. For example, in the string 11000111 there are thr...
4610001131015111116010101
8 5 15 18
2 seconds
256 megabytes
['constructive algorithms', 'data structures', 'dp', '*3500']
G. Dopingtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe call an array a of length n fancy if for each 1 < i \le n it holds that a_i = a_{i-1} + 1.Let's call f(p) applied to a permutation^\dagger of length n as the minimum number of subarrays it can be partitione...
4 666012 1 3 4 2
1 0 1 1
3 seconds
512 megabytes
['combinatorics', 'dp', 'math', '*3300']
F. Majoritytime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputEveryone was happy coding, until suddenly a power shortage happened and the best competitive programming site went down. Fortunately, a system administrator bought some new equipment recently, including som...
2 100
1
2 seconds
1024 megabytes
['combinatorics', 'dp', 'math', 'strings', '*2700']
E. Bracket Costtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDaemon Targaryen decided to stop looking like a Metin2 character. He turned himself into the most beautiful thing, a bracket sequence.For a bracket sequence, we can do two kind of operations: Select one...
51)4)()(3())5(((((10)(())))())
1 9 6 35 112
2 seconds
256 megabytes
['binary search', 'data structures', 'divide and conquer', 'dp', 'greedy', 'strings', '*2400']
D. Count GCDtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers n and m and an array a of n integers. For each 1 \le i \le n it holds that 1 \le a_i \le m.Your task is to count the number of different arrays b of length n such that: 1 \le b_...
53 54 2 12 11 15 502 3 5 2 34 100000000060 30 1 12 10000000001000000000 2
3 1 0 595458194 200000000
2 seconds
256 megabytes
['combinatorics', 'math', 'number theory', '*1800']
C. Complementary XORtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two binary strings a and b of length n. You would like to make all the elements of both strings equal to 0. Unfortunately, you can modify the contents of these strings using only the follow...
5301010121110410000011210103111111
YES 1 2 2 NO NO YES 2 1 2 2 2 YES 2 1 1 2 3
2 seconds
256 megabytes
['constructive algorithms', 'implementation', '*1400']
B. Maximum Substringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary string is a string consisting only of the characters 0 and 1. You are given a binary string s.For some non-empty substring^\dagger t of string s containing x characters 0 and y characters 1,...
6511100711001106011110710010104100010
9 12 16 12 9 1
1 second
256 megabytes
['brute force', 'greedy', 'implementation', '*800']
A. Indirect Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a_1, a_2, \ldots, a_n of size n, where each integer from 1 to n appears exactly once.You can do the following operation any number of times (possibly, zero): Choose any three...
731 2 331 3 275 3 4 7 6 2 177 6 5 4 3 2 152 1 4 5 352 1 3 4 571 2 6 7 4 3 5
Yes Yes No No No No Yes
1 second
256 megabytes
['constructive algorithms', 'implementation', 'math', '*800']
F. Distance to the Pathtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices. Initially, each vertex has a value 0.You need to perform m queries of two types: You are given a vertex index v. Print the value of the vertex v. ...
6 1 2 1 3 4 2 5 2 3 6 14 2 4 5 10 2 1 3 1 6 2 1 1 10 20 2 6 6 10 20 1 3 2 3 2 10 0 2 5 2 10 1 1 1 1 2 1 3 1 4 1 5 1 6
10 0 30 50 50 40 40 40 20
4 seconds
512 megabytes
['data structures', 'dfs and similar', 'trees', '*2800']
E. Cactus Walltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing Minecraft and wants to build a wall of cacti. He wants to build it on a field of sand of the size of n \times m cells. Initially, there are cacti in some cells of the field. Note that,...
42 4.#....#.3 3#.#....#.5 5.........................4 3#...#.#.#...
YES .#.# #.#. NO YES ....# ...#. ..#.. .#... #.... YES #.. .#. #.# ...
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'graphs', 'shortest paths', '*2400']
D. Counting Arraystime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider an array a of length n with elements numbered from 1 to n. It is possible to remove the i-th element of a if gcd(a_i, i) = 1, where gcd denotes the greatest common divisor. After an element i...
2 3
6
2 seconds
512 megabytes
['combinatorics', 'dp', 'math', 'number theory', '*1900']
C. Number Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. They have an array of positive integers a of size n.Before starting the game, Alice chooses an integer k \ge 0. The game lasts for k stages, the stages are numbered from ...
431 1 244 4 4 41151 3 2 1 1
2 0 1 3
2 seconds
256 megabytes
['binary search', 'data structures', 'games', 'greedy', 'implementation', '*1400']
B. Death's Blessingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a computer game. To pass the current level, you have to kill a big horde of monsters. In this horde, there are n monsters standing in the row, numbered from 1 to n. The i-th monster h...
411003100 1 1001 100 142 6 7 33 6 0 521000000000 10000000001000000000 1000000000
10 203 26 3000000000
2 seconds
256 megabytes
['greedy', '*900']
A. Cowardly Rookstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere's a chessboard of size n \times n. m rooks are placed on it in such a way that: no two rooks occupy the same cell; no two rooks attack each other. A rook attacks all cells that are in its row ...
22 21 22 13 12 2
NO YES
2 seconds
256 megabytes
['greedy', 'implementation', '*800']
F. Circular Xor Reversaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a_0, a_1, \ldots, a_{n-1} of length n. Initially, a_i = 2^i for all 0 \le i \lt n. Note that array a is zero-indexed. You want to reverse this array (that is, make a_i equal to...
2
3 1 0 1
2 seconds
256 megabytes
['bitmasks', 'constructive algorithms', '*3000']
E. Yet Another Array Counting Problemtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe position of the leftmost maximum on the segment [l; r] of array x = [x_1, x_2, \ldots, x_n] is the smallest integer i such that l \le i \le r and x_i = \max(x_l, x_{l+1}, \ldots...
43 31 3 24 22 2 2 26 96 9 6 9 6 99 10010 40 20 20 100 60 80 60 60
8 5 11880 351025663
2 seconds
512 megabytes
['binary search', 'data structures', 'divide and conquer', 'dp', 'flows', 'math', 'trees', '*2300']
D. ConstructOR time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers a, b, and d. Your task is to find any integer x which satisfies all of the following conditions, or determine that no such integers exist: 0 \le x \lt 2^{60}; a|x is divisi...
812 39 56 8 14100 200 2003 4 62 2 218 27 3420 666 69987654321 123456789 999999999
18 14 -1 -1 0 11 25599 184470016815529983
2 seconds
256 megabytes
['bitmasks', 'chinese remainder theorem', 'combinatorics', 'constructive algorithms', 'math', 'number theory', '*2100']
C. Zero-Sum Prefixestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe score of an array v_1,v_2,\ldots,v_n is defined as the number of indices i (1 \le i \le n) such that v_1+v_2+\ldots+v_i = 0.You are given an array a_1,a_2,\ldots,a_n of length n. You can perform ...
552 0 1 -1 031000000000 1000000000 040 0 0 083 0 2 -10 10 -30 30 091 0 0 1 -1 0 1 0 -1
3 1 4 4 5
1 second
256 megabytes
['brute force', 'data structures', 'dp', 'greedy', 'implementation', '*1600']
B. Diverse Substringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA non-empty digit string is diverse if the number of occurrences of each character in it doesn't exceed the number of distinct characters in it.For example: string "7" is diverse because 7 appears...
71727741010501100639999652345618789987887987998798
1 2 10 12 10 15 106
1 second
256 megabytes
['brute force', 'implementation', 'strings', '*1400']
A. The Ultimate Squaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n rectangular wooden blocks, which are numbered from 1 to n. The i-th block is 1 unit high and \lceil \frac{i}{2} \rceil units long.Here, \lceil \frac{x}{2} \rceil denotes the result of di...
325197654321
1 3 98827161
1 second
256 megabytes
['math', '*800']
E. List Generationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor given integers n and m, let's call a pair of arrays a and b of integers good, if they satisfy the following conditions: a and b have the same length, let their length be k. k \ge 2 and a_1 = 0, a...
41 11 22 2100 100
8 26 101 886336572
1 second
256 megabytes
['combinatorics', 'dp', 'math', '*2900']
D. Yet Another Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers a_1, a_2, a_3, \ldots, a_n.You have to answer q independent queries, each consisting of two integers l and r. Consider the subarray a[l:r] = [a_l, a_{l+1}, ...
7 6 3 0 3 3 1 2 3 3 4 4 6 3 7 5 6 1 6 2 2
-1 1 1 -1 2 0
1 second
256 megabytes
['binary search', 'bitmasks', 'constructive algorithms', 'data structures', '*1900']
C. Swap Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game on an array a of n positive integers. Alice and Bob make alternating moves with Alice going first.In his/her turn, the player makes the following move: If a_1 = 0, the player...
321 122 135 4 4
Bob Alice Alice
1 second
256 megabytes
['games', '*1200']
B. BAN BANtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n.Let's define s(n) as the string "BAN" concatenated n times. For example, s(1) = "BAN", s(3) = "BANBANBAN". Note that the length of the string s(n) is equal to 3n.Consider s(n). You c...
2 1 2
1 1 2 1 2 6
1 second
256 megabytes
['constructive algorithms', '*900']
A. Two Groupstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. You want to distribute these n integers into two groups s_1 and s_2 (groups can be empty) so that the following conditions are satisfied: For each i (1 \l...
4210 -104-2 -1 11 032 3 25-9 2 0 0 -4
0 8 7 11
1 second
256 megabytes
['constructive algorithms', 'greedy', '*800']
G. Olympiad Trainingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton decided to get ready for an Olympiad in Informatics. Ilya prepared n tasks for him to solve. It is possible to submit the solution for the i-th task in the first d_{i} days only. Anton cannot s...
44 1 1 01 2 11 1 10 1 21 2 23 1 1 11 1 27 2 19 3 24 2 1 0100 2 15 2 37 1 25 1 25 1 1 110 3 19 2 320 1 116 1 41 3 4
2 -1 17 35
1 second
256 megabytes
['binary search', 'data structures', 'dp', 'flows', 'geometry', 'implementation', 'sortings', '*3500']
F. Kazaeetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a consisting of n positive integers and you have to handle q queries of the following types: 1 i x: change a_{i} to x, 2 l r k: check if the number of occurrences of every positive integer ...
Input10 81234 2 3 3 2 1 1 2 3 42 1 6 21 1 12 1 6 22 1 9 21 10 52 1 9 31 3 52 3 10 2
OutputNOYESNOYESYES
3 seconds
256 megabytes
['data structures', 'hashing', 'probabilities', '*2800']
E2. Joking (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the hard version is the maximum number of questions.This is an interactive problem.There is a hidden integer 1 \le x \le n which you have to find. In...
Input6NO:(NO:)
Output? 5 1 2 5 4 3! 6? 4 1 2 3 4! 5
1 second
256 megabytes
['dp', 'interactive', '*3200']
E1. Joking (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the hard version is the maximum number of questions.This is an interactive problem.There is a hidden integer 1 \le x \le n which you have to find. In...
Input6NO:(NO:)
Output? 5 1 2 5 4 3! 6? 4 1 2 3 4! 5
1 second
256 megabytes
['binary search', 'constructive algorithms', 'interactive', 'ternary search', '*2500']
D. Paths on the Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree consisting of n vertices. The vertices are numbered from 1 to n, and the root is the vertex 1. You are also given a score array s_1, s_2, \ldots, s_n.A multiset of k simp...
25 41 2 1 36 2 1 5 75 31 2 1 36 6 1 4 10
54 56
3 seconds
256 megabytes
['dfs and similar', 'dp', 'greedy', 'sortings', 'trees', '*1900']
C. Permutation Operationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a of size n and you should perform n operations on it. In the i-th operation, you can choose a non-empty suffix of a and increase all of its elements by i. How can w...
441 2 3 451 3 2 4 532 3 111
1 1 1 1 1 4 3 2 1 1 3 3 1
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'implementation', 'math', '*1300']
B. Rebelliontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a of size n consisting only of zeroes and ones. You can do the following operation: choose two indices 1 \le i , j \le n, i \ne j, add a_{i} to a_{j}, remove a_{i} from a. Note that elem...
480 0 1 1 1 1 1 151 0 0 1 121 0111 1 0 0 1 0 0 1 1 1 0
0 1 1 3
1 second
256 megabytes
['constructive algorithms', 'greedy', 'two pointers', '*800']
A. Maxminatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a of size n consisting only of zeroes and ones and an integer k. In one operation you can do one of the following: Select 2 consecutive elements of a and replace them with their minimum (tha...
73 20 1 05 31 0 1 1 02 21 14 40 0 0 06 30 0 1 0 0 17 51 1 1 1 1 1 15 30 0 1 0 0
YES YES YES NO YES YES YES
1 second
256 megabytes
['constructive algorithms', 'greedy', '*800']
F. MEX vs MEDtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p_1, p_2, \ldots, p_n of length n of numbers 0, \ldots, n - 1. Count the number of subsegments 1 \leq l \leq r \leq n of this permutation such that mex(p_l, p_{l+1}, \ldots, p_r)...
81021 031 0 240 2 1 353 1 0 2 462 0 4 1 3 583 7 2 6 0 1 5 442 0 1 3
1 2 4 4 8 8 15 6
1 second
256 megabytes
['math', 'two pointers', '*2000']
E2. Divisible Numbers (hard version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an hard version of the problem. The only difference between an easy and a hard version is the constraints on a, b, c and d.You are given 4 positive integers a, b, c, d with a...
101 1 2 23 4 5 78 9 15 1812 21 14 2436 60 48 661024 729 373248 7301024 729 373247 7305040 40320 40319 1000000000999999999 999999999 1000000000 1000000000268435456 268435456 1000000000 1000000000
2 2 4 6 12 12 -1 -1 -1 -1 373248 730 -1 -1 15120 53760 -1 -1 536870912 536870912
4 seconds
256 megabytes
['brute force', 'math', 'number theory', '*1900']
E1. Divisible Numbers (easy version)time limit per test4 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 the constraints on a, b, c and d.You are given 4 positive integers a, b, c, d with a...
51 1 2 23 4 5 78 9 15 1812 21 14 2436 60 48 66
2 2 4 6 12 12 -1 -1 -1 -1
4 seconds
256 megabytes
['brute force', 'math', 'number theory', '*1500']
D. Divisibility by 2^ntime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of positive integers a_1, a_2, \ldots, a_n.Make the product of all the numbers in the array (that is, a_1 \cdot a_2 \cdot \ldots \cdot a_n) divisible by 2^n.You can perform ...
61223 2310 6 11413 17 1 151 1 12 1 1620 7 14 18 3 5
0 1 1 -1 2 1
2 seconds
256 megabytes
['greedy', 'math', 'sortings', '*1200']
C. Traffic Lighttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou find yourself on an unusual crossroad with a weird traffic light. That traffic light has three possible colors: red (r), yellow (y), green (g). It is known that the traffic light repeats its colors e...
65 rrggry1 gg3 rrrg5 yyrrgy7 rrgrgyrg9 yrrrgyyygy
3 0 2 4 1 4
1 second
256 megabytes
['binary search', 'implementation', 'two pointers', '*1000']
B. Even-Odd Increments time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n of integers a_1, a_2, \ldots, a_n. Process q queries of two types: query of the form "0 x_j": add the value x_j to all even elements of the array a, query of the form "1 x_j": add...
41 111 13 31 2 40 21 30 56 71 3 2 4 10 481 60 50 40 51 30 120 16 71000000000 1000000000 1000000000 11 15 170 171 100001 510 920 531 160 1
2 11 14 29 80 100 100 100 118 190 196 3000000094 3000060094 3000060400 3000060952 3000061270 3000061366 3000061366
2 seconds
256 megabytes
['implementation', 'math', '*800']
A. Number Replacementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn integer array a_1, a_2, \ldots, a_n is being transformed into an array of lowercase English letters using the following prodecure:While there is at least one number in the array: Choose any nu...
752 3 2 4 1cacta150a211 22ab41 2 2 1aaab51 2 3 2 1aaaaa61 10 2 9 3 8azzfdb71 2 3 4 1 1 2abababb
YES YES YES NO YES YES NO
2 seconds
256 megabytes
['greedy', 'implementation', '*800']
G. Antifibonacci Cuttime limit per test12 secondsmemory limit per test4 megabytesinputstandard inputoutputstandard outputNote that the memory limit is unusual.Let's define the sequence of Fibonacci strings as follows: f_0 is 0, f_1 is 1, f_i is f_{i-1} + f_{i-2} for i>1 (+ denotes the concatenation of two strings). So,...
1 10110101
3
12 seconds
4 megabytes
['bitmasks', 'combinatorics', 'constructive algorithms', 'data structures', 'dp', 'hashing', 'math', '*3000']
F. Intersection and Uniontime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given n segments on the coordinate axis. The i-th segment is [l_i, r_i]. Let's denote the set of all integer points belonging to the i-th segment as S_i.Let A \cup B be the union of two...
4 3 5 4 8 2 2 1 9
162
5 seconds
512 megabytes
['data structures', 'dp', 'matrices', 'probabilities', '*2300']
E. FTLtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp is playing a video game. In the game, he controls a spaceship and has to destroy an enemy spaceship.Monocarp has two lasers installed on his spaceship. Both lasers 1 and 2 have two values: p_i — the po...
5 10 4 9 16 1
20
4 seconds
512 megabytes
['binary search', 'dp', '*2400']
D. Problem with Random Teststime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of n characters. Each character of s is either 0 or 1.A substring of s is a contiguous subsequence of its characters.You have to choose two substrings of ...
5 11010
11111
4 seconds
512 megabytes
['brute force', 'dp', 'greedy', 'probabilities', '*1700']
C. Save the Magazinestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp has been collecting rare magazines for quite a while, and now he has decided to sell them. He distributed the magazines between n boxes, arranged in a row. The i-th box contains a_i magazi...
450111010 5 8 9 6601101120 10 9 30 20 1940000100 100 100 100401115 4 5 1
27 80 0 14
2 seconds
256 megabytes
['constructive algorithms', 'dp', 'greedy', '*1100']
B. Permutation Valuetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer n. You have to construct a permutation of size n.A permutation is an array where each integer from 1 to s (where s is the size of permutation) occurs exactly once. For examp...
256
1 4 3 5 2 4 1 6 2 5 3
2 seconds
512 megabytes
['constructive algorithms', 'greedy', '*800']
A. Passwordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp has forgotten the password to his mobile phone. The password consists of 4 digits from 0 to 9 (note that it can start with the digit 0).Monocarp remembers that his password had exactly two different...
280 1 2 4 5 6 8 918
6 216
2 seconds
256 megabytes
['brute force', 'combinatorics', 'implementation', 'math', '*800']
G. Orraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n nonnegative integers. Let's define the prefix OR array b as the array b_i = a_1~\mathsf{OR}~a_2~\mathsf{OR}~\dots~\mathsf{OR}~a_i, where \mathsf{OR} represents the bitwi...
541 2 4 875 1 2 3 4 5 521 10162 3 4 2 3 481 4 2 3 4 5 7 1
8 4 2 1 5 2 1 3 4 5 5 101 1 4 3 2 2 3 4 7 1 4 2 3 4 5 1
2 seconds
256 megabytes
['bitmasks', 'brute force', 'greedy', 'math', 'sortings', '*1500']
F. Smallertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlperen has two strings, s and t which are both initially equal to "a". He will perform q operations of two types on the given strings: 1 \;\; k \;\; x — Append the string x exactly k times at the end of str...
352 1 aa1 2 a2 3 a1 2 b2 3 abca21 5 mihai2 2 buiucani31 5 b2 3 a2 4 paiu
YES NO YES NO YES NO YES NO NO YES
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'strings', '*1500']
E. Scuzatime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur has a stairway with n steps. The i-th step is a_i meters higher than its predecessor. The first step is a_1 meters higher than the ground, and the ground starts at 0 meters. The stairs for the first tes...
34 51 2 1 51 2 4 9 102 21 10 13 11000000000 1000000000 10000000001000000000
1 4 4 9 9 0 2 3000000000
3 seconds
256 megabytes
['binary search', 'greedy', 'math', '*1200']
D. Coprimetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array of n positive integers a_1, a_2, \dots, a_n (1 \le a_i \le 1000). Find the maximum value of i + j such that a_i and a_j are coprime,^{\dagger} or -1 if no such i, j exist.For example consider t...
633 2 171 3 5 2 4 7 751 2 3 4 532 2 465 4 3 15 12 1651 2 2 3 6
6 12 9 -1 10 7
3 seconds
256 megabytes
['brute force', 'greedy', 'number theory', '*1100']
C. Stripestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn an 8 \times 8 grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is d...
4....B.......B.......B...RRRRRRRR....B.......B.......B.......B...RRRRRRRBB......BB......BB......BB......BB......BB......BRRRRRRRBRRRRRRBB.B.B..BBRRRRRRBB.B.B..BB.B.B..BBRRRRRRBB.B.B..BB.B.B..BB........................RRRRRRRR................................
R B B R
1 second
256 megabytes
['implementation', '*900']
B. Increasingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements ...
341 1 1 158 7 1 3 415
NO YES YES
1 second
256 megabytes
['greedy', 'implementation', 'sortings', '*800']
A. Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers a, b, and c. Determine if one of them is the sum of the other two.InputThe first line contains a single integer t (1 \leq t \leq 9261) — the number of test cases.The description of eac...
71 4 32 5 89 11 200 0 020 20 204 12 315 7 8
YES NO YES YES NO NO YES
1 second
256 megabytes
['implementation', '*800']
G. Kirill and Companytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKirill lives on a connected undirected graph of n vertices and m edges at vertex 1. One fine evening he gathered f friends, the i-th friend lives at the vertex h_i. So all friends are now in the ve...
36 71 22 32 43 54 53 66 552 3 4 5 641 2 3 56 71 22 32 43 54 53 66 562 3 4 5 6 541 2 3 54 41 21 32 33 433 4 221 3
2 1 1
3 seconds
256 megabytes
['bitmasks', 'brute force', 'dfs and similar', 'dp', 'flows', 'graphs', 'shortest paths', '*2200']
F. Multi-Colored Segmentstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDmitry has n segments of different colors on the coordinate axis Ox. Each segment is characterized by three integers l_i, r_i and c_i (1 \le l_i \le r_i \le 10^9, 1 \le c_i \le n), where l_i an...
931 2 13 4 15 6 22100000000 200000000 1900000000 1000000000 251 2 12 3 23 4 34 5 45 6 551 5 14 9 21 2 18 9 25 7 321 100 210 90 131 1 110 10 21000000000 1000000000 333 4 12 5 11 6 265 6 211 12 37 8 23 4 21 2 19 10 221 3 12 3 2
3 1 1 700000000 700000000 0 0 0 0 0 0 0 2 1 0 0 0 9 9 999999990 0 0 0 3 1 3 1 1 1 0 0
3 seconds
256 megabytes
['binary search', 'data structures', 'math', 'sortings', '*2000']
E. Sending a Sequence Over the Networktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe sequence a is sent over the network as follows: sequence a is split into segments (each element of the sequence belongs to exactly one segment, each segment is a group of conse...
791 1 2 3 1 3 2 2 3512 1 2 7 565 7 8 9 10 344 8 6 223 1104 6 2 1 9 4 9 3 4 211
YES YES YES NO YES YES NO
1 second
256 megabytes
['dp', '*1600']
D. Masha and a Beautiful Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe girl named Masha was walking in the forest and found a complete binary tree of height n and a permutation p of length m=2^n.A complete binary tree of height n is a rooted tree such that...
486 5 7 8 4 3 1 243 1 4 21187 8 4 3 1 2 6 5
4 -1 0 -1
2 seconds
256 megabytes
['dfs and similar', 'divide and conquer', 'graphs', 'sortings', 'trees', '*1300']
C. Minimize the Thicknesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a=[a_1,a_2,\dots,a_n] consisting of n positive integers.Let's call a group of consecutive elements a segment. Each segment is characterized by two indices: the index of...
4655 45 30 30 40 100410 23 7 13510 55 35 30 6564 1 1 1 1 4
3 4 2 3
2 seconds
256 megabytes
['brute force', 'greedy', 'math', 'two pointers', '*1100']
B. Funny Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence of n numbers is called permutation if it contains all numbers from 1 to n exactly once. For example, the sequences [3, 1, 4, 2], [1] and [2,1] are permutations, but [1,2,1], [0,1] and [1,3...
543752
3 4 2 1 -1 6 7 4 5 3 2 1 5 4 1 2 3 2 1
1 second
256 megabytes
['constructive algorithms', 'math', '*800']
A. Compare T-Shirt Sizestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo T-shirt sizes are given: a and b. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.For example, strings M,...
6XXXS XSXXXL XLXL MXXL XXLXXXXXS ML M
< > > = < >
1 second
256 megabytes
['implementation', 'implementation', 'strings', '*800']
I. Arranging Crystal Ballstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn the world of Compfestnesia, Pak Chanek discovers a secret underground dungeon. Inside it, there is a treasure chest that is surrounded by n statues that are arranged in a circular manner. T...
5 9 3 8 1 4 5 0
7
4 seconds
512 megabytes
['data structures', 'divide and conquer', 'divide and conquer', 'dp', 'geometry', 'graphs', 'number theory', '*3500']
H. MEX Tree Manipulationtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGiven a rooted tree, define the value of vertex u in the tree recursively as the MEX^\dagger of the values of its children. Note that it is only the children, not all of its descendants. In part...
7 1 1 3 2 5 2 1
1 1 3 2 4 4 7
5 seconds
512 megabytes
['data structures', 'trees', '*3300']
G. Dangerous Laser Powertime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPak Chanek has an n \times m grid of portals. The portal on the i-th row and j-th column is denoted as portal (i,j). The portals (1,1) and (n,m) are on the north-west and south-east corner of th...
2 3 8 8 2 6 5 7
110 100
4 seconds
512 megabytes
['constructive algorithms', 'dsu', 'sortings', '*3100']
F. Conditional Mixtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPak Chanek is given an array a of n integers. For each i (1 \leq i \leq n), Pak Chanek will write the one-element set \{a_i\} on a whiteboard.After that, in one operation, Pak Chanek may do the follow...
6 1 1 2 1 4 3
7
2 seconds
512 megabytes
['combinatorics', 'dp', 'math', '*2600']
E. Hanging Heartstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has n blank heart-shaped cards. Card 1 is attached directly to the wall while each of the other cards is hanging onto exactly one other card by a piece of string. Specifically, card i (i > 1)...
6 1 2 1 4 2
4
1 second
256 megabytes
['constructive algorithms', 'data structures', 'dfs and similar', 'dp', 'greedy', 'trees', '*1800']
D. Knowledge Cardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek, a renowned scholar, invented a card puzzle using his knowledge. In the puzzle, you are given a board with n rows and m columns. Let (r, c) represent the cell in the r-th row and the c-th co...
43 3 63 6 4 1 2 53 3 101 2 3 4 5 6 7 8 9 105 4 42 1 3 43 4 1010 4 9 3 5 6 8 2 7 1
YA TIDAK YA YA
1 second
256 megabytes
['constructive algorithms', 'data structures', '*1500']
C. Bricks and Bagstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n bricks numbered from 1 to n. Brick i has a weight of a_i.Pak Chanek has 3 bags numbered from 1 to 3 that are initially empty. For each brick, Pak Chanek must put it into one of the bags. Af...
353 1 5 2 3417 8 19 458265 265 265 265 265 265 265 265
6 63 0
1 second
256 megabytes
['constructive algorithms', 'games', 'greedy', 'sortings', '*1400']
B. Jumbo Extra Cheese 2time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has n two-dimensional slices of cheese. The i-th slice of cheese can be represented as a rectangle of dimensions a_i \times b_i. We want to arrange them on the two-dimensional plane suc...
344 14 51 12 332 42 62 312 65
26 24 134
1 second
256 megabytes
['geometry', 'greedy', 'sortings', '*800']
A. Factorise N+Mtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPak Chanek has a prime number^\dagger n. Find a prime number m such that n + m is not prime.^\dagger A prime number is a number with exactly 2 factors. The first few prime numbers are 2,3,5,7,11,13,\ldot...
37275619
2 7 47837
1 second
256 megabytes
['constructive algorithms', 'number theory', '*800']
F. Keyboard Designtime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputMonocarp has a dictionary of n words, consisting of 12 first letters of the Latin alphabet. The words are numbered from 1 to n. In every pair of adjacent characters in each word, the characters are d...
3 7 abacaba 10 cba 4 db
hjkildbacefg
4 seconds
1024 megabytes
['bitmasks', 'data structures', 'dp', 'string suffix structures', 'strings', '*2600']
E. Cleaning Robottime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider a hallway, which can be represented as the matrix with 2 rows and n columns. Let's denote the cell on the intersection of the i-th row and the j-th column as (i, j). The distance between the c...
2 01 11
2
3 seconds
512 megabytes
['bitmasks', 'dp', '*2400']
D. Reset K Edgestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree, consisting of n vertices. The vertices are numbered from 1 to n, the root is the vertex 1.You can perform the following operation at most k times: choose an edge (v, u) of...
55 11 1 2 25 21 1 2 26 01 2 3 4 56 11 2 3 4 54 31 1 1
2 1 5 3 1
4 seconds
256 megabytes
['binary search', 'data structures', 'dfs and similar', 'graphs', 'greedy', 'trees', '*1900']
C. Card Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider a game with n cards (n is even). Each card has a number written on it, between 1 and n. All numbers on the cards are different. We say that a card with number x is stronger than a card with number ...
5246860
1 0 1 3 2 1 12 7 1 42 27 1 341102826 248150916 1
2 seconds
512 megabytes
['combinatorics', 'constructive algorithms', 'dp', 'games', '*1500']
B. Array Recoverytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor an array of non-negative integers a of size n, we construct another array d as follows: d_1 = a_1, d_i = |a_i - a_{i - 1}| for 2 \le i \le n.Your task is to restore the array a from a given array d...
341 0 2 532 6 350 0 0 0 0
1 1 3 8 -1 0 0 0 0 0
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1100']
A. Immobile Knighttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a chess board of size n \times m. The rows are numbered from 1 to n, the columns are numbered from 1 to m.Let's call a cell isolated if a knight placed in that cell can't move to any other ce...
31 78 83 3
1 7 7 2 2 2
2 seconds
256 megabytes
['implementation', '*800']
H. Palindrome Addictstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYour task is to maintain a queue consisting of lowercase English letters as follows: "push c": insert a letter c at the back of the queue; "pop": delete a letter from the front of the queue. In...
12 push a pop push a push a push b push b push a push a pop pop pop push b
1 0 1 2 3 4 5 6 5 4 3 4
2 seconds
1024 megabytes
['data structures', 'strings', '*3300']
G. Anti-Increasing Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an n \times n grid. We write (i, j) to denote the cell in the i-th row and j-th column. For each cell, you are told whether yon can delete it or not. Given an integer k, you are ...
42 210014 311100101101001115 501111101111101111101111105 21000001111011110111101111
YES 01 11 YES 0011 1111 1111 1100 NO YES 01111 11000 10000 10000 10000
2 seconds
512 megabytes
['constructive algorithms', 'dp', 'greedy', 'math', '*2900']
F. Connectivity Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Given a simple undirected graph with n vertices numbered from 1 to n, your task is to color all the vertices such that for every color c, the following conditions h...
1 5 2 2 2 2 0 2 4 2 4
? 1 ? 1 ? 3 ? 3 ! 1 1 2 2 3
2 seconds
512 megabytes
['constructive algorithms', 'dsu', 'graphs', 'greedy', 'interactive', 'shortest paths', 'trees', '*2400']
E. Balance Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGiven an integer sequence a_1, a_2, \dots, a_n of length n, your task is to compute the number, modulo 998244353, of ways to partition it into several non-empty continuous subsequences such that the s...
61100000000021 140 0 1 051 2 3 2 151 3 5 7 9320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 2 150994942
2 seconds
512 megabytes
['combinatorics', 'dp', 'math', 'two pointers', '*2300']
D. Permutation Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGiven a permutation a_1, a_2, \dots, a_n of integers from 1 to n, and a threshold k with 0 \leq k \leq n, you compute a sequence b_1, b_2, \dots, b_n as follows. For every 1 \leq i \leq n in incre...
345 3 1 267 7 7 3 3 364 4 4 0 0 0
2 1 3 2 4 3 1 2 3 4 5 6 3 6 5 4 3 2 1
2 seconds
512 megabytes
['constructive algorithms', 'data structures', 'dfs and similar', 'dsu', 'graphs', 'trees', '*1900']
C. Even Number Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game on a sequence a_1, a_2, \dots, a_n of length n. They move in turns and Alice moves first.In the turn of each player, he or she should select an integer and remove ...
431 3 541 3 5 741 2 3 4410 20 30 40
Alice Alice Bob Alice
2 seconds
512 megabytes
['dp', 'games', 'greedy', 'math', '*1500']
B. Prefix Sum Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSuppose a_1, a_2, \dots, a_n is a sorted integer sequence of length n such that a_1 \leq a_2 \leq \dots \leq a_n. For every 1 \leq i \leq n, the prefix sum s_i of the first i terms a_1, a_2, \dots,...
45 51 2 3 4 57 4-6 -5 -3 03 32 3 43 23 4
Yes Yes No No
2 seconds
512 megabytes
['constructive algorithms', 'greedy', 'math', 'sortings', '*1200']
A. Glory Addictstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe hero is addicted to glory, and is fighting against a monster. The hero has n skills. The i-th skill is of type a_i (either fire or frost) and has initial damage b_i. The hero can perform all of the ...
440 1 1 11 10 100 100060 0 0 1 1 13 4 5 6 7 831 1 11000000000 1000000000 1000000000111
2112 63 3000000000 1
2 seconds
512 megabytes
['greedy', 'implementation', 'sortings', '*800']
G. Ela Takes Dancing Classtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDTL engineers love partying in the weekend. Ela does, too! Unfortunately, she didn't know how to dance yet. Therefore, she decided to take a dancing class.There are n students in the dancing c...
4 3 8 1 3 6 7 1011 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4
3 5 6 7 3 6 7 10
4 seconds
256 megabytes
['binary search', 'data structures', '*3500']
F. Ela and Prime GCDtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter a long, tough, but fruitful day at DTL, Ela goes home happily. She entertains herself by solving Competitive Programming problems. She prefers short statements, because she already read too ma...
521 11131 1 11422 1
0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 0 1 1 1 1 0 0 -1 2 0 1 1 0 1 2 1 1 0
2 seconds
256 megabytes
['constructive algorithms', 'math', 'number theory', '*3300']
E. Ela Goes Hikingtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEla likes to go hiking a lot. She loves nature and exploring the various creatures it offers. One day, she saw a strange type of ant, with a cannibalistic feature. More specifically, an ant would ea...
3452
0 250000002 250000002 500000004 0 250000002 250000002 250000002 250000002 0 1
2.5 seconds
256 megabytes
['combinatorics', 'dp', 'math', 'probabilities', '*2500']
D. Ela and the Wiring Wizardtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output Ela needs to send a large package from machine 1 to machine n through a network of machines. Currently, with the network condition, she complains that the network is too slow and the packa...
38 91 2 36 4 53 5 66 1 37 4 43 8 42 3 37 8 54 5 24 51 2 12 4 13 4 13 1 11 3 28 84 6 927 1 656 5 436 7 964 3 744 8 547 4 992 5 22
9 2 154
4 seconds
256 megabytes
['brute force', 'dp', 'graphs', 'greedy', 'implementation', 'shortest paths', '*2200']