problem_statement
stringlengths
147
8.53k
input
stringlengths
1
771
output
stringlengths
1
592
time_limit
stringclasses
32 values
memory_limit
stringclasses
21 values
tags
stringlengths
6
168
D. Trash Problemtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordinate of the i-th pile is the integer p_i. All piles have different co...
5 6 1 2 6 8 10 1 4 1 9 0 6 0 10 1 100 1 50
5 7 7 5 4 8 49
3 seconds
256 megabytes
['data structures', 'implementation', '*2100']
C. Mortal Kombat Towertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou and your friend are playing the game Mortal Kombat XI. You are trying to pass a challenge tower. There are n bosses in this tower, numbered from 1 to n. The type of the i-th boss is a_i. If the...
6 8 1 0 1 1 0 1 1 1 5 1 1 1 1 0 7 1 1 1 1 0 0 1 6 1 1 1 1 1 1 1 1 1 0
2 2 2 2 1 0
1 second
256 megabytes
['dp', 'graphs', 'greedy', 'shortest paths', '*1500']
B. Negative Prefixestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a, consisting of n integers.Each position i (1 \le i \le n) of the array is either locked or unlocked. You can take the values on the unlocked positions, rearrange them in any...
5 3 1 3 2 0 0 0 4 2 -3 4 -1 1 1 1 1 7 -8 4 -2 -6 4 7 1 1 0 0 0 1 1 0 5 0 1 -4 6 3 0 0 0 1 1 6 -1 7 10 4 -8 -1 1 0 0 0 0 1
1 2 3 2 -3 4 -1 -8 -6 1 4 4 7 -2 -4 0 1 6 3 -1 4 7 -8 10 -1
2 seconds
256 megabytes
['greedy', 'sortings', '*1300']
A. Buying Torchestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft k torches. One torch can be crafted using one stick and one coal.Hopefully, you've met a very handso...
5 2 1 5 42 13 24 12 11 12 1000000000 1000000000 1000000000 2 1000000000 1000000000
14 33 25 2000000003 1000000001999999999
1 second
256 megabytes
['math', '*1000']
B. Two Arraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRedDreamer has an array a consisting of n non-negative integers, and an unlucky integer T.Let's denote the misfortune of array b having length m as f(b) — the number of pairs of integers (i, j) such that 1 ...
2 6 7 1 2 3 4 5 6 3 6 3 3 3
1 0 0 1 1 0 1 0 0
1 second
256 megabytes
['greedy', 'math', 'sortings', '*1100']
A. Copy-pastetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output — Hey folks, how do you like this problem?— That'll do it. BThero is a powerful magician. He has got n piles of candies, the i-th pile initially contains a_i candies. BThero can cast a copy-paste spell as ...
3 2 2 1 1 3 5 1 2 3 3 7 3 2 2
1 5 4
1 second
256 megabytes
['greedy', 'math', '*800']
F. Showing Offtime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnother dull quarantine day was going by when BThero decided to start researching matrices of size n \times m. The rows are numerated 1 through n from top to bottom, and the columns are numerated 1 throug...
2 3 4 7 6 7 8 5 5 4 4 5 7 4 4 1 1 5
YES 1 1 1 1 2 1 1 1 3 2 1 1 R D L L D R D L U L R U NO
6 seconds
256 megabytes
['flows', 'graph matchings', 'greedy', 'implementation', '*3300']
E. Splittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, BThero decided to play around with arrays and came up with the following problem:You are given an array a, which consists of n positive integers. The array is numerated 1 through n. You execute the fol...
3 3 6 8 2 1 4 3 5 6 6
3 1 2
2 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'greedy', '*3200']
D. Graph and Queriestime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of n vertices and m edges. Initially there is a single integer written on every vertex: the vertex i has p_i written on it. All p_i are distinct intege...
5 4 6 1 2 5 4 3 1 2 2 3 1 3 4 5 1 1 2 1 2 3 1 1 1 2 1 2
5 1 2 0
1.5 seconds
256 megabytes
['data structures', 'dsu', 'graphs', 'implementation', 'trees', '*2600']
C. XOR Inversetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n non-negative integers. You have to choose a non-negative integer x and form a new array b of size n according to the following rule: for all i from 1 to n, b_i = a...
4 0 1 3 2
1 0
2 seconds
512 megabytes
['bitmasks', 'data structures', 'divide and conquer', 'dp', 'greedy', 'math', 'sortings', 'strings', 'trees', '*2000']
B. Make Them Equaltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times: choose three integers i, j and x (1 \le i, j \le n; 0 \...
3 4 2 16 4 18 6 1 2 3 4 5 6 5 11 19 1 1 3
2 4 1 2 2 3 3 -1 4 1 2 4 2 4 5 2 3 3 4 5 1
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*2000']
A. k-Amazing Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers numbered from 1 to n.Let's define the k-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having l...
3 5 1 2 3 4 5 5 4 4 4 4 2 6 1 3 1 5 3 1
-1 -1 3 2 1 -1 4 4 4 2 -1 -1 1 1 1 1
1 second
256 megabytes
['binary search', 'data structures', 'implementation', 'two pointers', '*1500']
F. Cakes for Clonestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou live on a number line. You are initially (at time moment t = 0) located at point x = 0. There are n events of the following type: at time t_i a small cake appears at coordinate x_i. To collect th...
3 2 2 5 5 6 1
YES
3 seconds
256 megabytes
['dp', '*2900']
E. New Game Plus!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWabbit is playing a game with n bosses numbered from 1 to n. The bosses can be fought in any order. Each boss needs to be defeated exactly once. There is a parameter called boss bonus which is initiall...
3 0 1 1 1
3
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*2200']
D. XOR-guntime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkady owns a non-decreasing array a_1, a_2, \ldots, a_n. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times.In one step you can s...
4 2 5 6 8
1
2 seconds
256 megabytes
['bitmasks', 'brute force', 'constructive algorithms', '*2000']
C. Bouncing Balltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right and numbered with consecutive integers starting from 1, and in each ce...
3 10 3 2 0101010101 2 2 5 4 1 00000 2 10 11 2 3 10110011000 4 3
2 4 10
1 second
256 megabytes
['brute force', 'dp', 'implementation', '*1400']
B. Repainting Streettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a street with n houses in a line, numbered from 1 to n. The house i is initially painted in color c_i. The street is considered beautiful if all houses are painted in the same color. Tom, th...
3 10 2 1 1 2 2 1 1 2 2 2 1 7 1 1 2 3 4 5 6 7 10 3 1 3 3 3 3 1 2 1 3 3
3 6 2
1 second
256 megabytes
['brute force', 'brute force', 'greedy', '*1100']
A. Prison Breaktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a prison that can be represented as a rectangular matrix with n rows and m columns. Therefore, there are n \cdot m prison cells. There are also n \cdot m prisoners, one in each prison cell. Let's...
3 10 10 1 1 3 5 2 4 10 2 5 1
18 4 6
1 second
256 megabytes
['brute force', 'math', '*800']
F. Roads and Ramentime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn the Land of Fire there are n villages and n-1 bidirectional road, and there is a path between any pair of villages by roads. There are only two types of roads: stone ones and sand ones. Since the L...
5 1 2 0 1 3 0 3 5 0 3 4 0 5 3 4 1 3 4
3 2 3 3 2
5 seconds
512 megabytes
['data structures', 'trees', '*2800']
E. Solo mid Oracletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMeka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for e...
7 1 1 1 1 2 2 2 2 1 2 3 4 4 3 2 1 228 21 11 3 239 21 11 3 1000000 1 1000000 1
1 2 1 5 534 -1 500000500000
1 second
256 megabytes
['greedy', 'math', 'ternary search', '*2100']
D. Shurikenstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at...
4 + + - 2 + - 3 + - 1 - 4
YES 4 2 3 1
1 second
256 megabytes
['data structures', 'greedy', 'implementation', '*1700']
C. Perform Easilytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret nu...
1 4 100 10 30 5 6 101 104 105 110 130 200
0
2 seconds
256 megabytes
['binary search', 'brute force', 'dp', 'implementation', 'sortings', 'two pointers', '*1900']
B. A New Techniquetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputAll techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n\cdot m different seals, denoted by distinct numbers. All of them were writ...
2 2 3 6 5 4 1 2 3 1 6 2 5 3 4 3 1 2 3 1 3 1 2
1 2 3 6 5 4 3 1 2
1 second
512 megabytes
['implementation', '*1100']
A. Finding Sasuketime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNaruto has sneaked into the Orochimaru's lair and is now looking for Sasuke. There are T rooms there. Every room has a door into it, each door can be described by the number n of seals on it and their i...
2 2 1 100 4 1 2 3 6
-100 1 1 1 1 -1
1 second
256 megabytes
['constructive algorithms', 'math', '*800']
G. No Game No Lifetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider the following game of Alice and Bob on a directed acyclic graph. Each vertex may contain an arbitrary number of chips. Alice and Bob make turns alternating. Alice goes first. In one tur...
1 0
0
2 seconds
256 megabytes
['bitmasks', 'games', 'math', 'matrices', '*2700']
F. The Thorny Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAccording to a legend the Hanoi Temple holds a permutation of integers from 1 to n. There are n stones of distinct colors lying in one line in front of the temple. Monks can perform the following oper...
3 3 2 3 1 3 2 1 3 3 1 2 3
3 0 3 1 3 2
2 seconds
256 megabytes
['greedy', 'math', '*3000']
E. Poman Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got a string S consisting of n lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's lef...
2 -1 ba
Yes
1 second
256 megabytes
['bitmasks', 'greedy', 'math', 'strings', '*2300']
D. Grime Zootime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCurrently, XXOC's rap is a string consisting of zeroes, ones, and question marks. Unfortunately, haters gonna hate. They will write x angry comments for every occurrence of subsequence 01 and y angry comment...
0?1 2 3
4
1 second
256 megabytes
['brute force', 'greedy', 'implementation', 'strings', '*2100']
C. Peaceful Rookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a n \times n chessboard. Rows and columns of the board are numbered from 1 to n. Cell (x, y) lies on the intersection of column number x and row number y.Rook is a chess piece, that can in...
4 3 1 2 3 3 2 2 1 1 2 5 3 2 3 3 1 1 2 5 4 4 5 5 1 2 2 3 3
1 3 4 2
1 second
256 megabytes
['dfs and similar', 'dsu', 'graphs', '*1700']
B. Fair Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe call a positive integer number fair if it is divisible by each of its nonzero digits. For example, 102 is fair (because it is divisible by 1 and 2), but 282 is not, because it isn't divisible by 8. Gi...
4 1 282 1234567890 1000000000000000000
1 288 1234568040 1000000000000000000
2 seconds
256 megabytes
['brute force', 'number theory', '*1000']
A. In-game Chattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have been assigned to develop a filter for bad messages in the in-game chat. A message is a string S of length n, consisting of lowercase English letters and characters ')'. The message is bad if the ...
5 2 )) 12 gl))hf)))))) 9 gege))))) 14 )aa))b)))))))) 1 )
Yes No Yes Yes Yes
1 second
256 megabytes
['implementation', '*800']
F. Subsequences of Length Twotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters).In one move, you can choose any character of...
4 2 bbaa ab
3
2 seconds
256 megabytes
['dp', 'strings', '*2100']
E. Two Platformstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n points on a plane. The i-th point has coordinates (x_i, y_i). You have two horizontal platforms, both of length k. Each platform can be placed anywhere on a plane but it should be placed hor...
4 7 1 1 5 2 3 1 5 4 1 3 6 7 2 5 4 1 1 1000000000 1000000000 5 10 10 7 5 15 8 20 199 192 219 1904 10 10 15 19 8 17 20 10 9 2 10 19 12 13 6 17 1 14 7 9 19 3
6 1 5 10
2 seconds
256 megabytes
['binary search', 'dp', 'sortings', 'two pointers', '*1800']
D. Decrease the Sum of Digitstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the ...
5 2 1 1 1 500 4 217871987498122 10 100000000000000001 1
8 0 500 2128012501878 899999999999999999
2 seconds
256 megabytes
['greedy', 'math', '*1500']
C. Yet Another Array Restorationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array: The array consists of n distinct positive (greater than 0) in...
5 2 1 49 5 20 50 6 20 50 5 3 8 9 13 22
1 49 20 40 30 50 10 26 32 20 38 44 50 8 23 18 13 3 1 10 13 4 19 22 25 16 7
1 second
256 megabytes
['brute force', 'math', 'number theory', '*1200']
B. Minimum Producttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four integers a, b, x and y. Initially, a \ge x and b \ge y. You can do the following operation no more than n times: Choose either a or b and decrease it by one. However, as a result of...
7 10 10 8 5 3 12 8 8 7 2 12343 43 4543 39 123212 1000000000 1000000000 1 1 1 1000000000 1000000000 1 1 1000000000 10 11 2 1 5 10 11 9 1 10
70 77 177177 999999999000000000 999999999 55 10
1 second
256 megabytes
['brute force', 'greedy', 'math', '*1100']
A. Yet Another Two Integers Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers a and b.In one move, you can choose some integer k from 1 to 10 and add it to a or subtract it from a. In other words, you choose an integer k \in [1; 10] an...
6 5 5 13 42 18 4 1337 420 123456789 1000000000 100500 9000
0 3 2 92 87654322 9150
1 second
256 megabytes
['greedy', 'math', '*800']
I. Bitwise Magictime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer k and an array a_1, a_2, \ldots, a_n of non-negative distinct integers not smaller than k and not greater than 2^c-1.In each of the next k seconds, one element is chosen...
4 1 3 1 2 3 4
0 0 0 748683265 0 499122177 0 748683265
6 seconds
256 megabytes
['dp', 'math', '*3200']
H. Rainbow Triplestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a_1, a_2, \ldots, a_n of non-negative integers.You need to find the largest number m of triples (i_1, j_1, k_1), (i_2, j_2, k_2), ..., (i_m, j_m, k_m) such that: 1 \leq i_p < ...
8 1 1 2 0 0 3 0 1 0 6 0 0 1 2 0 0 6 0 1 0 0 1 0 6 0 1 3 2 0 0 6 0 0 0 0 5 0 12 0 1 0 2 2 2 0 0 3 3 4 0
0 0 1 2 1 1 1 2
2 seconds
256 megabytes
['binary search', 'data structures', 'flows', 'greedy', '*3300']
G. Clusterization Countingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n computers in the company network. They are numbered from 1 to n.For each pair of two computers 1 \leq i < j \leq n you know the value a_{i,j}: the difficulty of sending data betwee...
4 0 3 4 6 3 0 2 1 4 2 0 5 6 1 5 0
1 0 1 1
3 seconds
256 megabytes
['combinatorics', 'dp', 'dsu', 'fft', 'graphs', 'trees', '*2700']
F. Two Differenttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n.You should find a list of pairs (x_1, y_1), (x_2, y_2), ..., (x_q, y_q) (1 \leq x_i, y_i \leq n) satisfying the following condition.Let's consider some function f: \mathbb{N} ...
3
1 1 2
3 seconds
256 megabytes
['constructive algorithms', 'divide and conquer', '*2300']
E. Avoid Rainbow Cyclestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given m sets of integers A_1, A_2, \ldots, A_m; elements of these sets are integers between 1 and n, inclusive.There are two arrays of positive integers a_1, a_2, \ldots, a_m and b_1, b_2,...
3 2 1 2 3 4 5 2 1 2 2 1 2 2 1 2
11
1 second
256 megabytes
['data structures', 'dsu', 'graphs', 'greedy', 'sortings', 'trees', '*2400']
D. Searchlightstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n robbers at coordinates (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) and m searchlight at coordinates (c_1, d_1), (c_2, d_2), ..., (c_m, d_m). In one move you can move each robber to the right (incr...
1 1 0 0 2 3
3
1 second
256 megabytes
['binary search', 'brute force', 'data structures', 'dp', 'implementation', 'sortings', 'two pointers', '*2000']
C. Discrete Accelerationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a road with length l meters. The start of the road has coordinate 0, the end of the road has coordinate l.There are two cars, the first standing at the start of the road and the second ...
5 2 10 1 9 1 10 1 5 7 1 2 3 4 6 2 1000000000 413470354 982876160 9 478 1 10 25 33 239 445 453 468 477
3.000000000000000 3.666666666666667 2.047619047619048 329737645.750000000000000 53.700000000000000
3 seconds
256 megabytes
['binary search', 'dp', 'implementation', 'math', 'two pointers', '*1500']
B. Arrays Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a non-decreasing array of non-negative integers a_1, a_2, \ldots, a_n. Also you are given a positive integer k.You want to find m non-decreasing arrays of non-negative integers b_1, b_2, \ldot...
6 4 1 0 0 0 1 3 1 3 3 3 11 3 0 1 2 2 3 3 3 4 4 4 4 5 3 1 2 3 4 5 9 4 2 2 3 5 7 11 13 13 17 10 7 0 1 1 2 3 3 4 5 5 6
-1 1 2 2 2 1
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1400']
A. Circle Coloringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three sequences: a_1, a_2, \ldots, a_n; b_1, b_2, \ldots, b_n; c_1, c_2, \ldots, c_n.For each i, a_i \neq b_i, a_i \neq c_i, b_i \neq c_i.Find a sequence p_1, p_2, \ldots, p_n, that satis...
5 3 1 1 1 2 2 2 3 3 3 4 1 2 1 2 2 1 2 1 3 4 3 4 7 1 3 3 1 1 1 1 2 4 4 3 2 2 4 4 2 2 2 4 4 2 3 1 2 1 2 3 3 3 1 2 10 1 1 1 2 2 2 3 3 3 1 2 2 2 3 3 3 1 1 1 2 3 3 3 1 1 1 2 2 2 3
1 2 3 1 2 1 2 1 3 4 3 2 4 2 1 3 2 1 2 3 1 2 3 1 2 3 2
1 second
256 megabytes
['constructive algorithms', '*800']
E. Egor in the Republic of Dagestantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEgor is a famous Russian singer, rapper, actor and blogger, and finally he decided to give a concert in the sunny Republic of Dagestan.There are n cities in the republic, some of them...
3 4 1 2 0 1 3 1 2 3 0 2 3 1
2 011
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'dp', 'graphs', 'greedy', 'shortest paths', '*2500']
D. Discrete Centrifugal Jumpstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n beautiful skyscrapers in New York, the height of the i-th one is h_i. Today some villains have set on fire first n - 1 of them, and now the only safety building is n-th skyscrap...
5 1 3 1 4 5
3
2 seconds
256 megabytes
['data structures', 'dp', 'graphs', '*2200']
C. Chocolate Bunnytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.We hid from you a permutation p of length n, consisting of the elements from 1 to n. You want to guess it. To do that, you can give us 2 different indices i and j, and we...
3 1 2 1 0
? 1 2 ? 3 2 ? 1 3 ? 2 1 ! 1 3 2
1 second
256 megabytes
['constructive algorithms', 'interactive', 'math', 'two pointers', '*1600']
B. Big Vovatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recen...
7 2 2 5 4 1 8 2 3 3 3 8 9 5 64 25 75 100 50 1 42 6 96 128 88 80 52 7 5 2 4 8 16 17
5 2 8 2 1 3 9 3 8 100 50 25 75 64 42 128 96 80 88 52 7 17 2 4 8 16
1 second
256 megabytes
['brute force', 'greedy', 'math', 'number theory', '*1300']
A. Ahahahahahahahahatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlexandra has an even-length array a, consisting of 0s and 1s. The elements of the array are enumerated from 1 to n. She wants to remove at most \frac{n}{2} elements (where n — length of array) in th...
4 2 1 0 2 0 0 4 0 1 1 1 4 1 1 0 0
1 0 1 0 2 1 1 4 1 1 0 0
1 second
256 megabytes
['constructive algorithms', 'math', '*1100']
E. Deleting Numberstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There is an unknown integer x (1\le x\le n). You want to find x.At first, you have a set of integers \{1, 2, \ldots, n\}. You can perform the following operations no mor...
10 2 4 0
B 4 A 2 A 8 C 4
1 second
512 megabytes
['interactive', 'math', 'number theory', '*2600']
D. Three Sequencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a sequence of n integers a_1, a_2, \ldots, a_n.You have to construct two sequences of integers b and c with length n that satisfy: for every i (1\leq i\leq n) b_i+c_i=a_i b is non-decr...
4 2 -1 7 3 2 2 4 -3 3 4 2
5 5 6
2 seconds
512 megabytes
['constructive algorithms', 'data structures', 'greedy', 'math', '*2200']
C. Link Cut Centroidstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputFishing Prince loves trees, and he especially loves trees with only one centroid. The tree is a connected graph without cycles.A vertex is a centroid of a tree only when you cut this vertex (remove ...
2 5 1 2 1 3 2 4 2 5 6 1 2 1 3 1 4 2 5 2 6
1 2 1 2 1 3 2 3
1 second
512 megabytes
['constructive algorithms', 'dfs and similar', 'graphs', 'trees', '*1700']
B. Maximum Producttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array of integers a_1,a_2,\ldots,a_n. Find the maximum possible value of a_ia_ja_ka_la_t among all five indices (i, j, k, l, t) (i<j<k<l<t).InputThe input consists of multiple test ca...
4 5 -1 -2 -3 -4 -5 6 -1 -2 -3 1 2 -1 6 -1 0 0 0 -1 -1 6 -9 -7 -5 -3 -2 1
-120 12 0 945
2 seconds
512 megabytes
['brute force', 'dp', 'greedy', 'implementation', 'sortings', '*1200']
A. Subset Mextime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputGiven a set of integers (it can contain equal elements).You have to split it into two subsets A and B (both of them can contain equal elements or be empty). You have to maximize the value of mex(A)+mex(B).H...
4 6 0 2 1 5 0 1 3 0 1 2 4 0 2 0 1 6 1 2 3 4 5 6
5 3 4 0
1 second
512 megabytes
['greedy', 'implementation', 'math', '*900']
B. Array Cancellationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given an array a of n integers, such that a_1 + a_2 + \cdots + a_n = 0.In one operation, you can choose two different indices i and j (1 \le i, j \le n), decrement a_i by one and increment a_...
7 4 -3 5 -3 1 2 1 -1 4 -3 2 -3 4 4 -1 1 1 -1 7 -5 7 -6 -4 17 -13 4 6 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1 0
3 0 4 1 8 3000000000 0
1 second
256 megabytes
['constructive algorithms', 'implementation', '*1000']
A. Permutation Forgerytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice ...
3 2 1 2 6 2 1 6 5 4 3 5 2 4 3 1 5
2 1 1 2 5 6 3 4 3 1 5 2 4
1 second
256 megabytes
['constructive algorithms', '*800']
E. Brickstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA brick is defined as a rectangle with integer side lengths with either width 1 or height 1 (or both).There is an n\times m grid, and each cell is colored either black or white. A tiling is a way to place bric...
3 4 #.## #### ##..
4
4 seconds
256 megabytes
['flows', 'graph matchings', 'graphs', '*2800']
D. Game of Pairstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Consider a fixed positive integer n. Two players, First and Second play a game as follows: First considers the 2n numbers 1, 2, \dots, 2n, and partitions them as he wants...
2 1 1 2 2 0
Second 1 3
4 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'interactive', 'math', 'number theory', '*2800']
C. Fixed Point Removaltime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet a_1, \ldots, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are co...
13 5 2 2 3 9 5 4 6 5 7 8 3 11 13 3 1 0 0 2 4 5 0 0 12
5 11 6 1 0
4 seconds
256 megabytes
['binary search', 'constructive algorithms', 'data structures', 'greedy', 'two pointers', '*2300']
B. Tree Tagtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a fun game of tree tag.The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.Initially, A...
4 4 3 2 1 2 1 2 1 3 1 4 6 6 1 2 5 1 2 6 5 2 3 3 4 4 5 9 3 9 2 5 1 2 1 6 1 9 1 3 9 5 7 9 4 8 4 3 11 8 11 3 3 1 2 11 9 4 9 6 5 2 10 3 2 5 9 8 3 7 4 7 10
Alice Bob Alice Alice
1 second
256 megabytes
['dfs and similar', 'dp', 'games', 'trees', '*1900']
A. Balanced Bitstringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (\frac{k...
9 6 4 100110 3 2 1?1 3 2 1?0 4 4 ???? 7 4 1?0??1? 10 10 11??11??11 4 2 1??1 4 4 ?0?0 6 2 ????00
YES YES NO YES YES NO NO YES NO
2 seconds
256 megabytes
['implementation', 'strings', '*1500']
C. Chess Rushtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe mythic world of Chess Land is a rectangular grid of squares with R rows and C columns, R being greater than or equal to C. Its rows and columns are numbered from 1 to R and 1 to C, respectively. The ...
8 8 5 P 1 2 R 4 8 Q 2 3 B 3 6 K 5 5
0 0 2 2 2 5 2 2 7 393
1.5 seconds
256 megabytes
['*special problem', 'combinatorics', 'dp', 'implementation', 'math', '*3200']
B. Spring cleaningtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpring cleanings are probably the most boring parts of our lives, except this year, when Flóra and her mother found a dusty old tree graph under the carpet.This tree has N nodes (numbered from 1 to N),...
7 3 1 2 2 4 4 5 5 6 5 7 3 4 1 4 2 2 4 1 1
-1 10 8
1 second
256 megabytes
['*special problem', 'data structures', 'dfs and similar', 'graphs', 'trees', '*2300']
A. The Potion of Great Powertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time, in the Land of the Shamans, everyone lived on the Sky-High Beanstalk. Each shaman had a unique identifying number i between 0 and N-1, and an altitude value H_i, representi...
6 5 11 4 2 42 1000 54 68 234 0 1 2 0 3 4 3 5 3 5 1 3 5 3 0 5 3 0 1 3 3 5 0 3 4 3 0 8 0 5 5 3 0 11
26 0 1000000000 14
3 seconds
256 megabytes
['*special problem', '2-sat', 'binary search', 'data structures', 'graphs', 'interactive', 'sortings', 'two pointers', '*2400']
C. Star Trektime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe United Federation of Planets is an alliance of N planets, they are indexed from 1 to N. Some planets are connected by space tunnels. In a space tunnel, a starship can fly both ways really fast. There are...
3 1 1 2 2 3
4
1 second
256 megabytes
['*special problem', 'combinatorics', 'dfs and similar', 'dp', 'games', 'graphs', 'matrices', 'trees', '*2600']
B. Roadstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe government of Treeland wants to build a new road network. There are 2N cities in Treeland. The unfinished plan of the road network already contains N road segments, each of which connects two cities with ...
5 1 3 3 6 5 1 5 3 3 3 6 5 2 1 4 1 2 3 4 2
2 1 1 3 2 3 2 1 3 3 2 3 5 1 4 2
1.5 seconds
256 megabytes
['*special problem', 'geometry', 'sortings', '*2900']
A. Fancy Fencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverybody knows that Balázs has the fanciest fence in the whole town. It's built up from N fancy sections. The sections are rectangles standing closely next to each other on the ground. The ith section has...
2 1 2 1 2
12
1 second
256 megabytes
['*special problem', 'data structures', 'dsu', 'implementation', 'math', 'sortings', '*1800']
F. Reverse and Swaptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length 2^n. You should process q queries on it. Each query has one of the following 4 types: Replace(x, k) — change a_x to k; Reverse(k) — reverse each subarray [(i-1) ...
2 3 7 4 9 9 1 2 8 3 1 4 2 4
24
3 seconds
256 megabytes
['binary search', 'bitmasks', 'data structures', '*2400']
E. Divide Squaretime limit per test2 secondsmemory limit per test384 megabytesinputstandard inputoutputstandard outputThere is a square of size 10^6 \times 10^6 on the coordinate plane with four points (0, 0), (0, 10^6), (10^6, 0), and (10^6, 10^6) as its vertices.You are going to draw segments on the plane. All segmen...
3 3 2 3 1000000 4 0 4 3 0 1000000 4 0 1 2 0 5 3 1 1000000
7
2 seconds
384 megabytes
['data structures', 'geometry', 'implementation', 'sortings', '*2400']
D. Maximum Distributed Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions: each integer must be greater than ...
3 4 1 2 2 3 3 4 2 2 2 4 3 4 1 3 3 2 2 3 2 7 6 1 2 3 4 6 7 3 5 1 3 6 4 7 5 13 3
17 18 286
2 seconds
256 megabytes
['dfs and similar', 'dp', 'greedy', 'implementation', 'math', 'number theory', 'sortings', 'trees', '*1800']
C. Mere Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output You are given an array a_1, a_2, \dots, a_n where all a_i are integers and greater than 0. In one operation, you can choose two different indices i and j (1 \le i, j \le n). If gcd(a_i, a_j) is equal to t...
4 1 8 6 4 3 6 6 2 9 4 4 5 6 7 5 7 5 2 2 4
YES YES YES NO
2 seconds
256 megabytes
['constructive algorithms', 'math', 'number theory', 'sortings', '*1300']
B. Ternary Sequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two sequences a_1, a_2, \dots, a_n and b_1, b_2, \dots, b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respec...
3 2 3 2 3 3 1 4 0 1 2 3 0 0 0 1 0 0 1
4 2 0
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1100']
A. Distance and Axistime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe have a point A with coordinate x = n on OX-axis. We'd like to find an integer point B (also on OX-axis), such that the absolute difference between the distance from O to B and the distance from A ...
6 4 0 5 8 0 1000000 0 0 1 0 1000000 1000000
0 3 1000000 0 1 0
1 second
256 megabytes
['constructive algorithms', 'math', '*900']
G. Mercenariestime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the army should ...
3 0 1 1 2 3 1 3
3
7 seconds
512 megabytes
['bitmasks', 'brute force', 'combinatorics', 'dp', 'dsu', 'math', 'two pointers', '*2600']
F. x-prime Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer value x and a string s consisting of digits from 1 to 9 inclusive.A substring of a string is a contiguous subsequence of that string.Let f(l, r) be the sum of digits of a s...
116285317 8
2
2 seconds
256 megabytes
['brute force', 'dfs and similar', 'dp', 'string suffix structures', 'strings', '*2800']
E. Clear the Multisettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a multiset containing several integers. Initially, it contains a_1 elements equal to 1, a_2 elements equal to 2, ..., a_n elements equal to n.You may apply two types of operations: choose...
4 1 4 1 1
2
2 seconds
256 megabytes
['data structures', 'divide and conquer', 'dp', 'greedy', '*2200']
D. Zigzagstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2 \dots a_n. Calculate the number of tuples (i, j, k, l) such that: 1 \le i < j < k < l \le n; a_i = a_k and a_j = a_l; InputThe first line contains a single integer t (1 \le ...
2 5 2 2 2 2 2 6 1 3 3 1 2 3
5 2
2 seconds
256 megabytes
['brute force', 'combinatorics', 'data structures', 'math', 'two pointers', '*1900']
C. Binary String Reconstructiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n c...
3 101110 2 01 1 110 1
111011 10 -1
2 seconds
256 megabytes
['2-sat', 'brute force', 'constructive algorithms', 'greedy', '*1500']
B. RPG Protagonisttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.You decided to rob a t...
3 33 27 6 10 5 6 100 200 10 10 5 5 1 19 1 3 19 5
11 20 3
2 seconds
256 megabytes
['brute force', 'greedy', 'math', '*1700']
A. String Similaritytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i...
4 1 1 3 00000 4 1110000 2 101
1 000 1010 00
2 seconds
256 megabytes
['constructive algorithms', 'strings', '*800']
F. Yet Another Segments Subsettime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n segments on a coordinate axis OX. The i-th segment has borders [l_i; r_i]. All points x, for which l_i \le x \le r_i holds, belong to the i-th segment.Your task is to choos...
4 4 1 5 2 4 2 3 3 4 5 1 5 2 3 2 5 3 5 2 2 3 1 3 2 4 2 3 7 1 10 2 8 2 5 3 4 4 4 6 8 7 7
3 4 2 7
3 seconds
256 megabytes
['data structures', 'dp', 'graphs', 'sortings', '*2300']
E2. Weights Division (hard version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEasy and hard versions are actually different problems, so we advise you to read both statements carefully.You are given a weighted rooted tree, vertex 1 is the root of this tree. Als...
4 4 18 2 1 9 2 3 2 4 1 4 1 1 2 3 20 2 1 8 1 3 1 7 2 5 50 1 3 100 1 1 5 10 2 2 3 123 2 5 4 55 1 2 100 1 2 409 2
0 0 11 6
3 seconds
256 megabytes
['binary search', 'dfs and similar', 'greedy', 'sortings', 'trees', 'two pointers', '*2200']
E1. Weights Division (easy version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEasy and hard versions are actually different problems, so we advise you to read both statements carefully.You are given a weighted rooted tree, vertex 1 is the root of this tree.A tr...
3 3 20 2 1 8 3 1 7 5 50 1 3 100 1 5 10 2 3 123 5 4 55 2 100 1 2 409
0 8 3
3 seconds
256 megabytes
['data structures', 'dfs and similar', 'greedy', 'trees', '*2000']
D. Binary String To Subsequencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string s consisting of n zeros and ones.Your task is to divide the given string into the minimum number of subsequences in such a way that each character of the st...
4 4 0011 6 111111 5 10101 8 01010000
2 1 2 2 1 6 1 2 3 4 5 6 1 1 1 1 1 1 4 1 1 1 1 1 2 3 4
2 seconds
256 megabytes
['constructive algorithms', 'data structures', 'greedy', 'implementation', '*1500']
C. Boats Competitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people who want to participate in a boat competition. The weight of the i-th participant is w_i. Only teams consisting of two people can participate in this competition. As an organizer,...
5 5 1 2 3 4 5 8 6 6 6 6 6 6 8 8 8 1 2 2 1 2 1 1 2 3 1 3 3 6 1 1 3 4 2 2
2 3 4 1 2
2 seconds
256 megabytes
['brute force', 'greedy', 'two pointers', '*1200']
B. Gifts Fixingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The i-th gift consists of a_i candies and b_i or...
5 3 3 5 6 3 2 3 5 1 2 3 4 5 5 4 3 2 1 3 1 1 1 2 2 2 6 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1 1 1 1 3 10 12 8 7 5 4
6 16 0 4999999995 7
1 second
256 megabytes
['greedy', '*800']
A. Remove Smallesttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given the array a consisting of n positive (greater than zero) integers.In one move, you can choose two indices i and j (i \ne j) such that the absolute difference between a_i and a_j is no mor...
5 3 1 2 2 4 5 5 5 5 3 1 2 4 4 1 3 4 4 1 100
YES YES NO NO YES
1 second
256 megabytes
['greedy', 'sortings', '*800']
G. Running Competitiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA running competition is going to be held soon. The stadium where the competition will be held can be represented by several segments on the coordinate plane: two horizontal segments: one connect...
3 10 5 0 3 5 10 6 24 30 14 16 18 10
24 30 14 16 -1 -1
2 seconds
512 megabytes
['bitmasks', 'fft', 'math', 'number theory', '*2600']
F. Controversial Roundstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob play a game. The game consists of several sets, and each set consists of several rounds. Each round is won either by Alice or by Bob, and the set ends when one of the players has wo...
6 11?000
6 3 2 1 0 0
2 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'two pointers', '*2500']
E. Two Types of Spellstime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.There are two types of spells: fire spell of power x deals x damage to the monster, and lightning ...
6 1 5 0 10 1 -5 0 5 1 11 0 -10
5 25 10 15 36 21
3.5 seconds
256 megabytes
['binary search', 'data structures', 'greedy', 'implementation', 'math', 'sortings', '*2200']
D. Colored Rectanglestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three multisets of pairs of colored sticks: R pairs of red sticks, the first pair has length r_1, the second pair has length r_2, \dots, the R-th pair has length r_R; G pairs of gr...
1 1 1 3 5 4
20
2 seconds
256 megabytes
['dp', 'greedy', 'sortings', '*1800']
C. Good Subarraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots , a_n consisting of integers from 0 to 9. A subarray a_l, a_{l+1}, a_{l+2}, \dots , a_{r-1}, a_r is good if the sum of elements of this subarray is equal to the l...
3 3 120 5 11011 6 600005
3 6 1
2 seconds
256 megabytes
['data structures', 'dp', 'math', '*1600']
B. Substring Removal Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob play a game. They have a binary string s (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on.During their move, th...
5 01111001 0000 111111 101010101 011011110111
4 0 6 3 6
2 seconds
256 megabytes
['games', 'greedy', 'sortings', '*800']
A. Bad Triangletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots , a_n, which is sorted in non-decreasing order (a_i \le a_{i + 1}). Find three indices i, j, k such that 1 \le i < j < k \le n and it is impossible to construct a no...
3 7 4 6 11 11 15 18 20 4 10 10 10 11 3 1 1 1000000000
2 3 6 -1 1 2 3
1 second
256 megabytes
['geometry', 'math', '*800']
B. Power Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a list of positive integers a_0, a_1, ..., a_{n-1} a power sequence if there is a positive integer c, so that for every 0 \le i \le n-1 then a_i = c^i.Given a list of n positive integers a_0,...
3 1 3 2
1
1 second
256 megabytes
['brute force', 'math', 'number theory', 'sortings', '*1500']
A. Juggling Letterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings s_1, s_2, \ldots, s_n consisting of lowercase Latin letters.In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j...
4 2 caa cbb 3 cba cba cbb 4 ccab cbac bca acbcc 4 acb caf c cbafc
YES NO YES NO
1 second
256 megabytes
['greedy', 'strings', '*800']
E. Distance Matchingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer k and a tree T with n nodes (n is even).Let dist(u, v) be the number of edges on the shortest path from node u to node v in T.Let us define a undirected weighted complete gr...
4 2 1 2 2 3 3 4
YES 2 1 3 4
2 seconds
512 megabytes
['constructive algorithms', 'dfs and similar', 'trees', '*3200']
D. Rainbow Rectanglestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputShrimpy Duc is a fat and greedy boy who is always hungry. After a while of searching for food to satisfy his never-ending hunger, Shrimpy Duc finds M&M candies lying unguarded on a L \times L grid....
4 2 4 3 2 2 3 1 1 1 1 1 1 2 1
20
4 seconds
512 megabytes
['data structures', 'sortings', 'two pointers', '*3300']