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. Weight of the System of Nested Segmentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the number line there are m points, i-th of which has integer coordinate x_i and integer weight w_i. The coordinates of all points are different, and the points are numbered...
3 3 8 0 10 -2 1 4 10 11 20 7 -1 9 1 2 3 5 -2 3 6 -1 2 1 3 3 -1 2 4 4 0 8 2 2 5 5 -1 3 -2 1 0 -2 0 -5 -3
12 2 6 5 1 7 8 10 1 6 5 2 3 4 -6 5 1 4 2
2 seconds
256 megabytes
['greedy', 'hashing', 'implementation', 'sortings', '*1200']
B. DIV + MODtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNot so long ago, Vlad came up with an interesting function: f_a(x)=\left\lfloor\frac{x}{a}\right\rfloor + x \bmod a, where \left\lfloor\frac{x}{a}\right\rfloor is \frac{x}{a}, rounded down, x \bmod a — the ...
5 1 4 3 5 8 4 6 10 6 1 1000000000 1000000000 10 12 8
2 4 5 999999999 5
2 seconds
256 megabytes
['math', '*900']
A. Deletions of Two Adjacent Letterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe string s is given, the string length is odd number. The string consists of lowercase letters of the Latin alphabet.As long as the string length is greater than 1, the following o...
5 abcde c abcde b x y aaaaaaaaaaaaaaa a contest t
YES NO NO YES YES
2 seconds
256 megabytes
['implementation', 'strings', '*800']
B. Game of Ball Passingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDaniel is watching a football team playing a game during their training session. They want to improve their passing skills during that session.The game involves n players, making multiple passes t...
4 4 2 3 3 2 3 1 5 2 2 0 0 4 1000000000 1000000000 1000000000 1000000000
1 2 0 1
1 second
256 megabytes
['greedy', 'implementation', '*1300']
A. Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a very popular computer game. The next level consists of n consecutive locations, numbered from 1 to n, each of them containing either land or water. It is known that the first and last locations ...
3 2 1 1 5 1 0 1 0 1 4 1 0 1 1
0 4 2
1 second
256 megabytes
['implementation', '*800']
F. Two Avenuestime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn order to make the capital of Berland a more attractive place for tourists, the great king came up with the following plan: choose two streets of the city and call them avenues. Certainly, these avenues...
36 51 22 32 44 54 631 65 32 55 51 22 33 44 55 161 51 31 32 42 55 38 101 22 33 44 55 66 77 87 11 83 642 53 72 57 8
5 4 2 5 4 5 1 5 3 2 3 7 6 2 3
8 seconds
512 megabytes
['data structures', 'dfs and similar', 'graphs', '*3500']
E. Air Reformtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBerland is a large country with developed airlines. In total, there are n cities in the country that are historically served by the Berlaflot airline. The airline operates bi-directional flights between m ...
34 31 2 12 3 24 3 35 51 2 11 3 12 4 14 5 25 1 36 61 2 32 3 13 6 53 4 24 5 42 4 2
3 3 3 1 1 1 2 2 4 4 5 3 4 4
3 seconds
512 megabytes
['data structures', 'dfs and similar', 'divide and conquer', 'dsu', 'graphs', 'implementation', 'trees', '*3200']
D. Serious Businesstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDima is taking part in a show organized by his friend Peter. In this show Dima is required to cross a 3 \times n rectangular field. Rows are numbered from 1 to 3 and columns are numbered from 1 to n....
4 3 1 0 2 -1 -3 1 9 2 3 2 4 1 1 2 5 2 3 4 1 4 14
13
5 seconds
512 megabytes
['data structures', 'divide and conquer', 'dp', 'implementation', 'shortest paths', '*2800']
C. Tyler and Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile looking at the kitchen fridge, the little boy Tyler noticed magnets with symbols, that can be aligned into a string s.Tyler likes strings, and especially those that are lexicographically small...
3 4 1 2 2 2 1 2 1
2
2 seconds
256 megabytes
['combinatorics', 'data structures', 'implementation', '*1900']
B. Integral Arraytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers numbered from 1 to n. Let's call an array integral if for any two, not necessarily different, numbers x and y from this array, x \ge y, the number \left ...
4 3 5 1 2 5 4 10 1 3 3 7 1 2 2 1 1 1
Yes No No Yes
2 seconds
512 megabytes
['brute force', 'constructive algorithms', 'data structures', 'math', '*1800']
A. Weird Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEgor has a table of size n \times m, with lines numbered from 1 to n and columns numbered from 1 to m. Each cell has a color that can be presented as an integer from 1 to 10^5.Let us denote the cell that li...
2 3 1 2 3 3 2 1
7
2 seconds
256 megabytes
['combinatorics', 'data structures', 'geometry', 'math', 'matrices', 'sortings', '*1400']
F. Madoka and Lazinesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka has become too lazy to write a legend, so let's go straight to the formal description of the problem.An array of integers a_1, a_2, \ldots, a_n is called a hill if it is not empty and there...
4 1 2 4 3
3
2 seconds
256 megabytes
['dp', 'greedy', '*3100']
E. Madoka and the Sixth-graderstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the most stunning success with the fifth-graders, Madoka has been trusted with teaching the sixth-graders.There's n single-place desks in her classroom. At the very beginning Madoka...
5 5 5 3 3 1 1 8 2 9 4
1 3 2 5 4
2 seconds
256 megabytes
['data structures', 'dfs and similar', 'greedy', '*2500']
D. Madoka and the Best School in Russiatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka is going to enroll in "TSUNS PTU". But she stumbled upon a difficult task during the entrance computer science exam: A number is called good if it is a multiple of d. A n...
8 6 2 12 2 36 2 8 2 1000 10 2376 6 128 4 16384 4
NO NO YES NO YES YES NO YES
2 seconds
256 megabytes
['constructive algorithms', 'dp', 'math', 'number theory', '*1900']
C. Madoka and Childish Prankstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka as a child was an extremely capricious girl, and one of her favorite pranks was drawing on her wall. According to Madoka's memories, the wall was a table of n rows and m columns, cons...
4 4 5 01000 10100 01010 00110 2 3 001 010 3 3 110 101 000 1 1 0
4 1 1 3 3 3 3 4 4 4 3 4 4 4 2 4 3 1 1 2 2 3 -1 0
1 second
256 megabytes
['constructive algorithms', 'greedy', '*1300']
B. Madoka and the Elegant Gifttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka's father just reached 1 million subscribers on Mathub! So the website decided to send him a personalized award — The Mathhub's Bit Button! The Bit Button is a rectangular table with ...
5 3 3 100 011 011 3 3 110 111 110 1 5 01111 4 5 11111 01010 01000 01000 3 2 11 00 11
YES NO YES NO YES
1 second
256 megabytes
['brute force', 'constructive algorithms', 'graphs', 'implementation', '*1200']
A. Madoka and Math Dadtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadoka finally found the administrator password for her computer. Her father is a well-known popularizer of mathematics, so the password is the answer to the following problem.Find the maximum deci...
5 1 2 3 4 5
1 2 21 121 212
1 second
256 megabytes
['implementation', 'math', '*800']
F. Playing Around the Tabletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n players, numbered from 1 to n sitting around a round table. The (i+1)-th player sits to the right of the i-th player for 1 \le i < n, and the 1-st player sits to the right of the ...
2 2 1 1 2
1 2 1
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'implementation', '*2900']
E. Power Boardtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a rectangular board of size n\times m (n rows, m columns). The n rows are numbered from 1 to n from top to bottom, and the m columns are numbered from 1 to m from left to right. The cell at the...
3 3
7
1.5 seconds
256 megabytes
['brute force', 'dp', 'math', 'number theory', '*2200']
D. Weight the Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree of n vertices numbered from 1 to n. A tree is a connected undirected graph without cycles. For each i=1,2, \ldots, n, let w_i be the weight of the i-th vertex. A vertex is called ...
4 1 2 2 3 2 4
3 4 1 1 1 1
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'dp', 'implementation', 'trees', '*2000']
C. Factorials and Powers of Twotime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA number is called powerful if it is a power of two or a factorial. In other words, the number m is powerful if there exists a non-negative integer d such that m=2^d or m=d!, where d!=1\c...
4 7 11 240 17179869184
2 3 4 1
3 seconds
256 megabytes
['bitmasks', 'brute force', 'constructive algorithms', 'dp', 'math', '*1500']
B. Quality vs Quantitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output \def\myred#1{\color{red}{\underline{\bf{#1}}}} \def\myblue#1{\color{blue}{\overline{\bf{#1}}}} \def\RED{\myred{Red}} \def\BLUE{\myblue{Blue}}You are given a sequence of n non-negative integers a...
4 3 1 2 3 5 2 8 6 3 1 4 3 5 4 2 5 1000000000 1000000000 1000000000 1000000000 1000000000
NO YES NO NO
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'greedy', 'sortings', 'two pointers', '*800']
A. Square Countingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuis has a sequence of n+1 integers a_1, a_2, \ldots, a_{n+1}. For each i = 1, 2, \ldots, n+1 it is guaranteed that 0\leq a_i < n, or a_i=n^2. He has calculated the sum of all the elements of the seque...
4 7 0 1 1 2 12 3 12
0 1 3 1
1 second
256 megabytes
['math', '*800']
F. Basistime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor an array of integers a, let's define |a| as the number of elements in it.Let's denote two functions: F(a, k) is a function that takes an array of integers a and a positive integer k. The result of this func...
3 2
2
6 seconds
512 megabytes
['combinatorics', 'fft', 'math', 'number theory', '*2900']
E. Expand the Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a grid of size n \times n. The rows are numbered top to bottom from 1 to n, the columns are numbered left to right from 1 to n.The robot is positioned in a cell (1, 1). It can perform two typ...
34RD5DRDRDRDR3D
13 9 3
2 seconds
256 megabytes
['brute force', 'combinatorics', 'data structures', 'implementation', 'math', '*1900']
D. Cross Coloringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a sheet of paper that can be represented with a grid of size n \times m: n rows and m columns of cells. All cells are colored in white initially.q operations have been applied to the sheet. Th...
2 1 1 3 2 1 1 1 1 2 2 2 3 2 1 1 1 2 2
3 4
2 seconds
256 megabytes
['data structures', 'implementation', 'math', '*1700']
C. Increase Subarray Sumstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n, consisting of n integers. You are also given an integer value x.Let f(k) be the maximum sum of a contiguous subarray of a after applying the followi...
3 4 2 4 1 3 2 3 5 -2 -7 -1 10 2 -6 -1 -2 4 -6 -1 -4 4 -5 -4
10 12 14 16 18 0 4 4 5 4 6 6 7 7 7 7 8 8 8 8
2 seconds
256 megabytes
['brute force', 'dp', 'greedy', 'implementation', '*1400']
B. Anti-Fibonacci Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a permutation p of length n anti-Fibonacci if the condition p_{i-2} + p_{i-1} \ne p_i holds for all i (3 \le i \le n). Recall that the permutation is the array of length n which ...
2 4 3
4 1 3 2 1 2 4 3 3 4 1 2 2 4 1 3 3 2 1 1 3 2 3 1 2
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'implementation', '*800']
A. Doors and Keystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe knight is standing in front of a long and narrow hallway. A princess is waiting at the end of it.In a hallway there are three doors: a red door, a green door and a blue door. The doors are placed o...
4 rgbBRG RgbrBG bBrRgG rgRGBb
YES NO YES NO
2 seconds
256 megabytes
['implementation', '*800']
B. Power Walkingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSam is a kindergartener, and there are n children in his group. He decided to create a team with some of his children to play "brawl:go 2".Sam has n power-ups, the i-th has type a_i. A child's strength ...
2 3 1 1 2 6 5 1 2 2 2 4
2 2 3 4 4 4 4 5 6
2 seconds
256 megabytes
['greedy', '*900']
A. Hard Waytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSam lives in Awesomeburg, its downtown has a triangular shape. Also, the following is true about the triangle: its vertices have integer coordinates, the coordinates of vertices are non-negative, and its v...
5 8 10 10 4 6 2 4 6 0 1 4 2 14 1 11 2 13 2 0 0 4 0 2 4 0 1 1 1 0 0
0.0000000 0 2.0000 0.00 1
1 second
256 megabytes
['geometry', '*800']
F. Covering Circletime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSam started playing with round buckets in the sandbox, while also scattering pebbles. His mom decided to buy him a new bucket, so she needs to solve the following task.You are given n distinct points ...
4 3 2 2 0 0 0 4 3 0 5 4 3 1 1 0 0 2 2 0 2 2 0 8 3 2 0 3 1 0 0 2 1 1 0 1 1 2 0 0 1 3 5 4 4 1 1 -3 3 2 2 5 3 5 5
2.00000000000000000000 1.00000000000000000000 0.50000000000000000000 4.00000000000000000000
6 seconds
256 megabytes
['geometry', '*3500']
E. Special Positionstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. Also you are given m distinct positions p_1, p_2, \ldots, p_m (1 \leq p_i \leq n).A non-empty subset of these positions T is randomly selected with equal probab...
4 2 1 2 3 4 1 4
665496247
5 seconds
512 megabytes
['combinatorics', 'divide and conquer', 'fft', 'math', '*3300']
D. Two Arraystime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSam changed his school and on the first biology lesson he got a very interesting task about genes.You are given n arrays, the i-th of them contains m different integers — a_{i,1}, a_{i,2},\ldots,a_{i,m}. A...
4 2 1 2 5 4 3 1 2 3 2 4 5 3
5
3 seconds
512 megabytes
['bitmasks', 'brute force', 'combinatorics', 'greedy', 'hashing', 'math', 'two pointers', '*2700']
C. Anonymity Is Importanttime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the work of a doctor, it is important to maintain the anonymity of clients and the results of tests. The test results are sent to everyone personally by email, but people are very impatien...
6 9 0 4 5 0 1 5 1 6 0 4 6 1 1 6 0 2 5 1 0 2 2 0 1 3 1 2
NO N/A YES YES NO
1.5 seconds
256 megabytes
['binary search', 'brute force', 'data structures', 'dsu', 'greedy', 'sortings', '*2200']
B. Repetitions Decodingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOlya has an array of integers a_1, a_2, \ldots, a_n. She wants to split it into tandem repeats. Since it's rarely possible, before that she wants to perform the following operation several (possib...
4 2 5 7 2 5 5 6 1 3 1 2 2 3 6 3 2 1 1 2 3
-1 0 1 2 4 1 3 5 3 5 3 10 3 2 8 6 5 0 3 8 3 5 3 6 2 7 1 4 2 6 6 2
1 second
256 megabytes
['constructive algorithms', 'implementation', 'sortings', '*2000']
A. Great Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence of positive integers is called great for a positive integer x, if we can split it into pairs in such a way that in each pair the first number multiplied by x is equal to the second number. Mo...
4 4 4 1 16 4 4 6 2 1 2 2 2 4 7 5 3 5 2 3 5 15 9 10 10 10 10 20 1 100 200 2000 3
0 2 3 3
1 second
256 megabytes
['brute force', 'greedy', 'sortings', '*1200']
F. Two Posterstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou want to advertise your new business, so you are going to place two posters on a billboard in the city center. The billboard consists of n vertical panels of width 1 and varying integer heights, held ...
6 2 2 3 5 4 5
18
2 seconds
1024 megabytes
['brute force', 'data structures', 'greedy', 'two pointers', '*3200']
E. Colorful Operationstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a_1,a_2, \dots, a_n. Each element initially has value 0 and color 1. You are also given q queries to perform: Color l r c: Change the color of elements a_l,a_{l+1},\cdots,a_r t...
5 8 Color 2 4 2 Add 2 2 Query 3 Color 4 5 3 Color 2 2 3 Add 3 3 Query 2 Query 5
2 5 3
4 seconds
256 megabytes
['brute force', 'data structures', 'implementation', '*2400']
D. Big Brushtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou found a painting on a canvas of size n \times m. The canvas can be represented as a grid with n rows and m columns. Each cell has some color. Cell (i, j) has color c_{i,j}.Near the painting you also fou...
4 4 5 5 3 3 1 1 5 3 2 2 5 4 2 2 4 4
6 1 3 3 3 3 4 2 2 5 1 1 5 2 1 1 3 1 2
3 seconds
256 megabytes
['constructive algorithms', 'data structures', 'greedy', 'implementation', '*2000']
C. Inversion Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p_1, p_2, \dots, p_n. Then, an undirected graph is constructed in the following way: add an edge between vertices i, j such that i < j if and only if p_i > p_j. Your task is...
6 3 1 2 3 5 2 1 4 3 5 6 6 1 4 2 5 3 1 1 6 3 2 1 6 5 4 5 3 1 5 2 4
3 3 1 1 2 1
1 second
256 megabytes
['data structures', 'dsu', 'graphs', 'math', '*1300']
B. Odd Swap Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n. You can perform operations on the array. In each operation you can choose an integer i (1 \le i < n), and swap elements a_i and a_{i+1} of the array, if a_i +...
4 4 1 6 31 14 2 4 2 5 2 9 6 7 10 3 6 6 6
Yes No No Yes
1 second
256 megabytes
['data structures', 'math', 'sortings', '*1100']
A. Reversetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p_1, p_2, \ldots, p_n of length n. You have to choose two integers l,r (1 \le l \le r \le n) and reverse the subsegment [l,r] of the permutation. The permutation will become p_1,p_2...
4 1 1 3 2 1 3 4 1 4 2 3 5 1 2 3 4 5
1 1 2 3 1 2 4 3 1 2 3 4 5
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*800']
H. Minimize Inversions Numbertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of length n.You can choose any subsequence, remove it from the permutation, and insert it at the beginning of the permutation keeping the same order.For every ...
3 1 1 4 4 2 1 3 5 5 1 3 2 4
0 0 4 2 2 1 4 5 4 2 2 1 5
2 seconds
256 megabytes
['data structures', 'greedy', 'math', 'sortings', '*3500']
G. Birthdaytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVitaly gave Maxim n numbers 1, 2, \ldots, n for his 16-th birthday. Maxim was tired of playing board games during the celebration, so he decided to play with these numbers. In one step Maxim can choose two nu...
2 2 3
-1 3 1 3 2 2 4 0
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*3000']
F. Towerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n vertices numbered from 1 to n. The height of the i-th vertex is h_i. You can place any number of towers into vertices, for each tower you can choose which vertex to put it in, as we...
3 1 2 1 1 2 2 3
4
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'trees', '*2500']
E. Best Pairtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. Let cnt_x be the number of elements from the array which are equal to x. Let's also define f(x, y) as (cnt_x + cnt_y) \cdot (x + y).Also you are given m bad pairs (x_i,...
3 6 1 6 3 6 7 3 3 3 6 2 0 3 4 7 4 1 2 2 3 1 5 1 1 5 3 5 1 3 2 5
40 14 15
2 seconds
256 megabytes
['binary search', 'brute force', 'implementation', '*2100']
D. Yet Another Minimization Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b, both of length n.You can perform the following operation any number of times (possibly zero): select an index i (1 \leq i \leq n) and swap a_i and b_...
3 1 3 6 4 3 6 6 6 2 7 4 1 4 6 7 2 4 2 5 3 5
0 987 914
2 seconds
256 megabytes
['dp', 'greedy', 'math', '*1800']
C. Andrew and Stonestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew has n piles with stones. The i-th pile contains a_i stones. He wants to make his table clean so he decided to put every stone either to the 1-st or the n-th pile.Andrew can perform the followi...
4 5 1 2 2 3 6 3 1 3 1 3 1 2 1 4 3 1 1 2
4 -1 1 -1
1 second
256 megabytes
['greedy', 'implementation', '*1200']
B. MEX and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet there be an array b_1, b_2, \ldots, b_k. Let there be a partition of this array into segments [l_1; r_1], [l_2; r_2], \ldots, [l_c; r_c], where l_1 = 1, r_c = k, and for any 2 \leq i \leq c holds tha...
4 2 1 2 3 2 0 1 4 2 0 5 1 5 0 1 1 0 1
4 14 26 48
1 second
256 megabytes
['brute force', 'dp', 'greedy', 'math', '*1100']
A. Sorting Partstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a of length n. You can exactly once select an integer len between 1 and n - 1 inclusively, and then sort in non-decreasing order the prefix of the array of length len and the suffix of ...
3 3 2 2 1 4 3 1 2 1 5 1 2 2 4 4
YES YES NO
1 second
256 megabytes
['brute force', 'sortings', '*800']
F. Closest Pair time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n weighted points on the OX-axis. The coordinate and the weight of the i-th point is x_i and w_i, respectively. All points have distinct coordinates and positive weights. Also, x_i < x_{i + 1}...
5 5 -2 2 0 10 1 1 9 2 12 7 1 3 2 3 1 5 3 5 2 4
9 11 9 24 11
3 seconds
256 megabytes
['data structures', 'greedy', '*2800']
E. Cars time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n cars on a coordinate axis OX. Each car is located at an integer point initially and no two cars are located at the same point. Also, each car is oriented either left or right, and they can move at a...
4 4 1 1 2 1 2 3 2 3 4 2 4 1
YES R 0 L -3 R 5 L 6
2 seconds
512 megabytes
['2-sat', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'sortings', '*2200']
D. Infinite Settime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n distinct positive integers.Let's consider an infinite integer set S which contains all integers x that satisfy at least one of the following conditions: x = a_i f...
2 4 6 1
9
2 seconds
256 megabytes
['bitmasks', 'dp', 'math', 'matrices', 'number theory', 'strings', '*1800']
C. Differential Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n elements. Your can perform the following operation no more than n times: Select three indices x,y,z (1 \leq x < y < z \leq n) and replace a_x with a_y - a_z. After t...
3 5 5 -4 2 -1 2 3 4 3 2 3 -3 -2 -1
2 1 2 3 3 4 5 -1 0
2 seconds
256 megabytes
['constructive algorithms', 'greedy', '*1200']
B. Avoid Local Maximumstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of size n. Each element in this array is an integer between 1 and 10^9.You can perform several operations to this array. During an operation, you can replace an element i...
5 3 2 1 2 4 1 2 3 1 5 1 2 1 2 1 9 1 2 1 3 2 3 1 2 1 9 2 1 3 1 3 1 3 1 3
0 2 1 2 1 1 3 3 1 1 1 2 2 2 1 2 1 2 3 3 2 3 3 2 1 2 2 1 3 3 3 1 1 1 3
2 seconds
256 megabytes
['greedy', '*800']
A. Min Or Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of size n.You can perform the following operation on the array: Choose two different integers i, j (1 \leq i < j \leq n), replace a_i with x and a_j with y. In order not to break ...
4 3 1 3 2 5 1 2 4 8 16 2 6 6 3 3 5 6
3 31 6 7
1 second
256 megabytes
['bitmasks', 'greedy', '*800']
F. Fibonacci Additionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne of my most productive days was throwing away 1,000 lines of code.— Ken ThompsonFibonacci addition is an operation on an array X of integers, parametrized by indices l and r. Fibonacci addition ...
3 5 3 2 2 1 0 0 0 A 1 3 A 1 3 B 1 1 B 2 2 A 3 3
YES NO NO NO YES
1 second
256 megabytes
['brute force', 'data structures', 'hashing', 'implementation', 'math', '*2700']
E. Fair Sharetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEven a cat has things it can do that AI cannot.— Fei-Fei LiYou are given m arrays of positive integers. Each array is of even length.You need to split all these integers into two equal multisets L and R,...
3 2 1 2 4 1 2 3 3 6 1 1 2 2 3 3
YES RL LRLR RLLRRL
1.5 seconds
256 megabytes
['constructive algorithms', 'data structures', 'dfs and similar', 'graph matchings', 'graphs', '*2400']
D. Finding Zerotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output This is an interactive problem.We picked an array of whole numbers a_1, a_2, \ldots, a_n (0 \le a_i \le 10^9) and concealed exactly one zero in it! Your goal is to find the location of this zero, that i...
1 4 2 3 3 2
? 1 2 3 ? 2 3 4 ? 3 4 1 ? 4 1 2 ! 2 3
1 second
256 megabytes
['constructive algorithms', 'interactive', 'math', '*2000']
C. OKEAtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeople worry that computers will get too smart and take over the world, but the real problem is that they're too stupid and they've already taken over the world.— Pedro DomingosYou work for a well-known departmen...
4 1 1 2 2 3 3 3 1
YES 1 YES 1 3 2 4 NO YES 1 2 3
1 second
256 megabytes
['constructive algorithms', '*1000']
B. Fortune Tellingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaha, try to solve this, SelectorUnlimited!— antontrygubO_oYour friends Alice and Bob practice fortune telling.Fortune telling is performed as follows. There is a well-known array a of n non-negative i...
4 1 7 9 2 2 0 2 1 3 4 0 1 1 2 3 4 2 1000000000 3000000000 1000000000 1000000000
Alice Alice Bob Alice
1 second
256 megabytes
['bitmasks', 'math', '*1400']
A. Reverse and Concatenatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputReal stupidity beats artificial intelligence every time.— Terry Pratchett, Hogfather, DiscworldYou are given a string s of length n and a number k. Let's denote by rev(s) the reversed string s ...
4 3 2 aab 3 3 aab 7 1 abacaba 2 0 ab
2 2 1 1
1 second
256 megabytes
['greedy', 'strings', '*800']
F. Perfect Matchingtime limit per test12 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices (numbered from 1 to n) and n-1 edges (numbered from 1 to n-1). Initially, all vertices except vertex 1 are inactive.You have to process queries of three...
6 1 4 6 1 3 2 1 2 5 1 1 4 2 1 2 2 1 3 2 1 5 1 6 2 3
1 1 1 0 0 4 2 1 3 0 0 0
12 seconds
512 megabytes
['data structures', 'divide and conquer', 'interactive', 'trees', '*2800']
E. Spanning Tree Queriestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a connected weighted undirected graph, consisting of n vertices and m edges.You are asked k queries about it. Each query consists of a single integer x. For each query, you select ...
5 8 4 1 4 3 1 0 3 5 3 2 5 4 3 4 8 4 3 4 4 2 8 5 3 9 3 11 1 1 10 0 1 2
4
4 seconds
256 megabytes
['binary search', 'data structures', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'math', 'sortings', 'trees', '*2400']
D. Make Them Equaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array of integers a of size n. Initially, all elements of the array are equal to 1. You can perform the following operation: choose two integers i (1 \le i \le n) and x (x > 0), and then i...
4 4 4 1 7 5 2 2 6 5 2 3 0 3 5 2 5 4 7 5 9 5 2 5 6 3 5 9 1 9 7 6 14 11 4 6 2 8 16 43 45 9 41 15 38
9 0 30 167
2 seconds
256 megabytes
['dp', 'greedy', '*1600']
C. Kill the Monstertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing a computer game. In this game, his character fights different monsters.A fight between a character and a monster goes as follows. Suppose the character initially has health h_C an...
4 25 4 9 20 1 1 10 25 4 12 20 1 1 10 100 1 45 2 0 4 10 9 2 69 2 4 2 7
YES NO YES YES
2 seconds
256 megabytes
['brute force', 'math', '*1100']
B. Minoritytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting only of characters '0' and '1'.You have to choose a contiguous substring of s and remove all occurrences of the character, which is a strict minority in it, from the subs...
4 01 1010101010111 00110001000 1
0 5 3 0
2 seconds
256 megabytes
['greedy', '*800']
A. Div. 7time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer n. You have to change the minimum number of digits in it in such a way that the resulting number does not have any leading zeroes and is divisible by 7.If there are multiple ways to do...
3 42 23 377
42 28 777
2 seconds
512 megabytes
['brute force', '*800']
E2. Distance Tree (hard version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis version of the problem differs from the previous one only in the constraint on n.A tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each...
341 22 31 421 271 21 33 43 53 65 7
1 2 2 2 1 1 2 2 3 3 3 3 3
2 seconds
512 megabytes
['binary search', 'dfs and similar', 'shortest paths', 'trees', '*2700']
E1. Distance Tree (easy version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis version of the problem differs from the next one only in the constraint on n.A tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each edg...
341 22 31 421 271 21 33 43 53 65 7
1 2 2 2 1 1 2 2 3 3 3 3 3
2 seconds
512 megabytes
['binary search', 'data structures', 'dfs and similar', 'graphs', 'shortest paths', 'trees', '*2400']
D. New Year Concerttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNew Year is just around the corner, which means that in School 179, preparations for the concert are in full swing.There are n classes in the school, numbered from 1 to n, the i-th class has prepared...
1 1
1
3 seconds
256 megabytes
['binary search', 'data structures', 'greedy', 'math', 'number theory', 'two pointers', '*2000']
C. Strange Testtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIgor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich. Igor knows how the test will be conducted: first of all, the teacher wil...
5 1 3 5 8 2 5 3 19 56678 164422
1 3 2 1 23329
1 second
256 megabytes
['binary search', 'bitmasks', 'brute force', 'dp', 'math', '*1600']
B. Roof Constructiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt has finally been decided to build a roof over the football field in School 179. Its construction will require placing n consecutive vertical pillars. Furthermore, the headmaster wants the heights ...
423510
0 1 2 0 1 3 2 1 0 4 4 6 3 2 0 8 9 1 7 5
1 second
256 megabytes
['bitmasks', 'constructive algorithms', '*1000']
A. ABCtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, the students of School 179 have developed a unique algorithm, which takes in a binary string s as input. However, they soon found out that if some substring t of s is a palindrome of length greater than ...
41121020141010
YES YES YES NO
1 second
256 megabytes
['implementation', '*800']
B. Fun with Even Subarraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n elements. You can apply the following operation to it any number of times: Select some subarray from a of even size 2k that begins at position l (1\le l \le l+2\c...
531 1 122 154 4 4 2 444 2 1 311
0 1 1 2 0
1 second
256 megabytes
['dp', 'greedy', '*1100']
A. Min Max Swaptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b of n positive integers each. You can apply the following operation to them any number of times: Select an index i (1\leq i\leq n) and swap a_i with b_i (i. e. a_i becomes...
361 2 6 5 1 23 4 3 2 2 533 3 33 3 321 22 1
18 9 2
1 second
256 megabytes
['greedy', '*800']
F. Making It Bipartitetime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph of n vertices indexed from 1 to n, where vertex i has a value a_i assigned to it and all values a_i are different. There is an edge between two vertices u and v i...
448 4 2 1430 2 3 5512 4 6 2 31085 195 5 39 3 13 266 154 14 2
2 0 1 2
4 seconds
512 megabytes
['flows', 'graph matchings', 'graphs', 'number theory', '*3400']
E. Expected Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a cyclic array a of size n, where a_i is the value of a in the i-th position, there may be repeated values. Let us define that a permutation of a is equal to another permutation of a if and ...
541 1 1 141 1 2 141 2 1 254 3 2 5 1121 3 2 3 2 1 3 3 1 3 3 2
1 2 3 5 358642921
2 seconds
256 megabytes
['combinatorics', 'math', 'number theory', 'probabilities', '*2900']
D. Flipping Rangetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers and a set B of m positive integers such that 1 \leq b_i \leq \lfloor \frac{n}{2} \rfloor for 1\le i\le m, where b_i is the i-th element of B. You can make the fol...
36 20 6 -2 1 -4 51 27 11 -1 1 -1 1 -1 125 1-1000000000 -1000000000 -1000000000 -1000000000 -10000000001
18 5 5000000000
2 seconds
256 megabytes
['constructive algorithms', 'dp', 'greedy', 'number theory', '*2400']
C. Paint the Middletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n elements numbered from 1 to n, the element i has value a_i and color c_i, initially, c_i = 0 for all i.The following operation can be applied: Select three elements i, j and k (1 \le...
7 1 2 1 2 7 4 7
2
2 seconds
256 megabytes
['dp', 'greedy', 'sortings', 'two pointers', '*2200']
B. Range and Partitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of n integers, find a range of values [x, y] (x \le y), and split a into exactly k (1 \le k \le n) subarrays in such a way that: Each subarray is formed by several continuous ele...
32 11 24 21 2 2 211 35 5 5 1 5 5 1 5 5 5 1
1 2 1 2 2 2 1 3 4 4 5 5 1 1 2 2 3 11
2 seconds
256 megabytes
['binary search', 'constructive algorithms', 'data structures', 'greedy', 'two pointers', '*1800']
A. And Matchingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a set of n (n is always a power of 2) elements containing all integers 0, 1, 2, \ldots, n-1 exactly once.Find \frac{n}{2} pairs of elements such that: Each element in the set is in exactly ...
44 04 14 24 3
0 3 1 2 0 2 1 3 0 1 2 3 -1
1 second
256 megabytes
['bitmasks', 'constructive algorithms', '*1500']
B. GCD Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider the array a composed of all the integers in the range [l, r]. For example, if l = 3 and r = 7, then a = [3, 4, 5, 6, 7].Given l, r, and k, is it possible for \gcd(a) to be greater than 1 after doi...
91 1 03 5 113 13 04 4 03 7 44 10 32 4 01 7 31 5 3
NO NO YES YES YES YES NO NO YES
2 seconds
256 megabytes
['greedy', 'math', 'number theory', '*800']
A. Download More RAMtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDid you know you can download more RAM? There is a shop with n different pieces of software that increase your RAM. The i-th RAM increasing software takes a_i GB of memory to run (temporarily, once t...
43 1020 30 109 100 105 11 1 5 1 11 1 1 1 15 12 2 2 2 2100 100 100 100 1005 8128 64 32 16 8128 64 32 16 8
29 6 1 256
1 second
256 megabytes
['brute force', 'greedy', 'sortings', '*800']
F. Spaceship Crisis Managementtime limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNASA (Norwegian Astronaut Stuff Association) is developing a new steering system for spaceships. But in its current state, it wouldn't be very safe if the spaceship would end up in a bunch...
3 0 1 2 4 1 3 -1 6 0 -1 1 -1 14 -2 10 -1 10 0 10 1 10 2 10 3 10 4 10 5 10 6 10 -1 -2 0 -2 1 -2 2 -2 3 -2
YES YES YES YES YES NO NO NO YES YES NO NO NO YES
8 seconds
256 megabytes
['binary search', 'data structures', 'geometry', 'sortings', '*3500']
E. Groceries in Meteor Towntime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMihai lives in a town where meteor storms are a common problem. It's annoying, because Mihai has to buy groceries sometimes, and getting hit by meteors isn't fun. Therefore, we ask you to fin...
6 9 1 3 1 2 3 2 4 5 3 4 6 4 3 4 5 3 1 1 1 1 3 1 2 1 1 1 5 6 3 4 2 6 6 3 4 3 1
-1 -1 4 3 5
2 seconds
256 megabytes
['binary search', 'data structures', 'dsu', 'trees', '*3100']
D2. Game on Sum (Hard Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference is the constraints on n, m and t. You can make hacks only if all versions of the problem are solved.Alice and Bob are given the numb...
73 3 22 1 106 3 106 4 10100 1 14 4 069 4 20
6 5 375000012 500000026 958557139 0 49735962
3 seconds
256 megabytes
['combinatorics', 'dp', 'games', 'math', '*2400']
D1. Game on Sum (Easy Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference is the constraints on n, m and t. You can make hacks only if all versions of the problem are solved.Alice and Bob are given the numb...
73 3 22 1 106 3 106 4 10100 1 14 4 069 4 20
6 5 375000012 500000026 958557139 0 49735962
3 seconds
256 megabytes
['combinatorics', 'dp', 'games', 'math', '*2100']
C. Grid Xortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote: The XOR-sum of set \{s_1,s_2,\ldots,s_m\} is defined as s_1 \oplus s_2 \oplus \ldots \oplus s_m, where \oplus denotes the bitwise XOR operation.After almost winning IOI, Victor bought himself an n\time...
3 2 1 5 5 1 4 1 14 8 9 3 1 5 9 4 13 11 1 1 15 4 11 4 2 4 1 6 3 7 3 10 15 9 4 2 12 7 15 1
4 9 5
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'implementation', 'interactive', 'math', '*2300']
B. Peculiar Movie Preferencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMihai plans to watch a movie. He only likes palindromic movies, so he wants to skip some (possibly zero) scenes to make the remaining parts of the movie palindromic.You are given a list s o...
65zxabcczxba2abbad4codeforces3abc3abcdcba2abab
YES NO NO YES YES NO
2 seconds
512 megabytes
['greedy', 'strings', '*1700']
A. Meximum Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMihai has just learned about the MEX concept and since he liked it so much, he decided to use it right away.Given an array a of n non-negative integers, Mihai wants to create a new array b that is forme...
651 0 2 0 382 2 3 4 0 1 2 01150 1 2 3 440 1 1 0100 0 2 1 1 1 0 0 1 1
1 4 2 5 1 1 0 1 5 2 2 2 4 3 2 2 0
2 seconds
256 megabytes
['binary search', 'constructive algorithms', 'greedy', 'implementation', 'math', 'two pointers', '*1400']
F. Not Splittingtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is a k \times k grid, where k is even. The square in row r and column c is denoted by (r,c). Two squares (r_1, c_1) and (r_2, c_2) are considered adjacent if \lvert r_1 - r_2 \rvert + \lvert c_1 -...
38 41 2 1 32 2 2 33 2 3 34 2 4 31 4 2 42 1 3 12 2 3 24 1 4 27 21 1 1 22 1 2 21 1 1 21 1 2 11 2 2 21 1 2 11 2 2 21 63 3 3 4
7 4 1
3 seconds
512 megabytes
['geometry', 'graphs', 'greedy', 'implementation', 'shortest paths', '*2700']
E. Not Escapingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMajor Ram is being chased by his arch enemy Raghav. Ram must reach the top of the building to escape via helicopter. The building, however, is on fire. Ram must choose the optimal path to reach the top o...
45 3 35 17 8 1 41 3 3 3 43 1 5 2 53 2 5 1 66 3 35 17 8 1 4 21 3 3 3 43 1 5 2 53 2 5 1 65 3 15 17 8 1 41 3 5 3 1005 5 53 2 3 7 53 5 4 2 12 2 5 4 54 4 5 2 31 2 4 2 23 3 5 2 4
16 NO ESCAPE -90 27
2 seconds
256 megabytes
['data structures', 'dp', 'implementation', 'shortest paths', 'two pointers', '*2200']
D. Not Addingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a_1, a_2, \dots, a_n consisting of n distinct integers. You are allowed to perform the following operation on it: Choose two elements from the array a_i and a_j (i \ne j) such that \gcd(...
5 4 20 1 25 30
3
2 seconds
256 megabytes
['brute force', 'dp', 'math', 'number theory', '*1900']
C. Not Assigningtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree of n vertices numbered from 1 to n, with edges numbered from 1 to n-1. A tree is a connected undirected graph without cycles. You have to assign integer weights to each edge of th...
321 241 34 32 171 21 33 43 56 27 2
17 2 5 11 -1
1.5 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'number theory', 'trees', '*1400']
B. Not Sittingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRahul and Tina are looking forward to starting their new year at college. As they enter their new classroom, they observe the seats of students are arranged in a n \times m grid. The seat in row r and colu...
24 31 2
3 3 4 4 4 4 4 4 5 5 5 5 1 1
1 second
256 megabytes
['games', 'greedy', 'sortings', '*1300']
A. Not Shadingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a grid with n rows and m columns. Some cells are colored black, and the rest of the cells are colored white.In one operation, you can select some black cell and do exactly one of the following: ...
93 5 1 4WBWWWBBBWBWWBBB4 3 2 1BWWBBWWBBWWB2 3 2 2WWWWWW2 2 1 1WWWB5 9 5 9WWWWWWWWWWBWBWBBBWWBBBWWBWWWBWBWBBBWWWWWWWWWW1 1 1 1B1 1 1 1W1 2 1 1WB2 1 1 1WB
1 0 -1 2 2 0 -1 1 1
1 second
256 megabytes
['constructive algorithms', 'implementation', '*800']
F. A Random Code Problemtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer array a_0, a_1, \dots, a_{n - 1}, and an integer k. You perform the following code with it:long long ans = 0; // create a 64-bit signed variable which is initially equal...
3 10 3 5 13 88
382842030
3 seconds
512 megabytes
['combinatorics', 'dp', 'math', 'number theory', 'probabilities', '*2800']
E. Black and White Treetime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices. Some of the vertices (at least two) are black, all the other vertices are white.You place a chip on one of the vertices of the tree, and then perfor...
8 0 1 0 0 0 0 1 0 8 6 2 5 7 8 6 5 4 5 6 1 7 3
0 1 1 1 1 0 1 1
4 seconds
512 megabytes
['dfs and similar', 'greedy', 'trees', '*2400']