0% found this document useful (0 votes)
1K views8 pages

A. Vasya The Hipster: CR-1 Implementation Long Challenge (Practice)

Uploaded by

Dhruv Singla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views8 pages

A. Vasya The Hipster: CR-1 Implementation Long Challenge (Practice)

Uploaded by

Dhruv Singla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1/10/22, 5:53 AM Problems - Codeforces

CR-1 Implementation Long Challenge (Practice)

A. Vasya the Hipster You think that a matrix looks beautiful, if the single number one of the
matrix is located in its middle (in the cell that is on the intersection of the
1 second, 256 megabytes third row and the third column). Count the minimum number of moves
needed to make the matrix beautiful.
One day Vasya the Hipster decided to count how many socks he had. It
turned out that he had a red socks and b blue socks. Input
The input consists of five lines, each line contains five integers: the j-th
According to the latest fashion, hipsters should wear the socks of different
integer in the i-th line of the input represents the element of the matrix that
colors: a red one on the left foot, a blue one on the right foot.
is located on the intersection of the i-th row and the j-th column. It is
Every day Vasya puts on new socks in the morning and throws them away guaranteed that the matrix consists of 24 zeroes and a single number
before going to bed as he doesn't want to wash them. one.
Vasya wonders, what is the maximum number of days when he can dress Output
fashionable and wear different socks, and after that, for how many days Print a single integer — the minimum number of moves needed to make
he can then wear the same socks until he either runs out of socks or the matrix beautiful.
cannot make a single pair from the socks he's got.

Can you help him? input


0 0 0 0 0

Input 0 0 0 0 1

The single line of the input contains two positive integers a and b 0 0 0 0 0

(1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got. 0 0 0 0 0

0 0 0 0 0

Output output
Print two space-separated integers — the maximum number of days when
3

Vasya can wear different socks and the number of days when he can wear
the same socks until he either runs out of socks or cannot make a single
pair from the socks he's got. input
0 0 0 0 0

Keep in mind that at the end of the day Vasya throws away the socks that 0 0 0 0 0

he's been wearing on that day. 0 1 0 0 0

0 0 0 0 0

input 0 0 0 0 0

3 1
output
output 1

1 1

C. Bear and Big Brother


input
1 second, 256 megabytes
2 3

Bear Limak wants to become the largest of bears, or at least to become


output
larger than his brother Bob.
2 0

Right now, Limak and Bob weigh a and b respectively. It's guaranteed that
input Limak's weight is smaller than or equal to his brother's weight.

7 3
Limak eats a lot and his weight is tripled after every year, while Bob's
weight is doubled after every year.
output
3 2
After how many full years will Limak become strictly larger (strictly
heavier) than Bob?
In the first sample Vasya can first put on one pair of different socks, after
that he has two red socks left to wear on the second day.
Input
The only line of the input contains two integers a and b
(1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob
B. Beautiful Matrix respectively.
2 seconds, 256 megabytes Output
Print one integer, denoting the integer number of years after which Limak
You've got a 5 × 5 matrix, consisting of 24 zeroes and a single number
will become strictly larger than Bob.
one. Let's index the matrix rows by numbers from 1 to 5 from top to
bottom, let's index the matrix columns by numbers from 1 to 5 from left to input
right. In one move, you are allowed to apply one of the two following
4 7

transformations to the matrix:


output
1. Swap two neighboring matrix rows, that is, rows with indexes i and
2

i + 1 for some integer i (1 ≤ i < 5).


2. Swap two neighboring matrix columns, that is, columns with indexes j input
and j + 1 for some integer j (1 ≤ j < 5).
4 9

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 1/8
1/10/22, 5:53 AM Problems - Codeforces

output 1. Set to be the maximum value of your array.


2. For every from to , replace with .
3

The goal is to predict the contents in the array after operations. Please
input help Ray determine what the final sequence will look like!
1 1

Input
output Each test contains multiple test cases. The first line contains the number
1
of cases ( ). Description of the test cases follows.

The first line of each test case contains two integers and (
In the first sample, Limak weighs 4 and Bob weighs 7 initially. After one
) – the length of your array and the
year their weights are 4·3 = 12 and 7·2 = 14 respectively (one weight is
number of operations to perform.
tripled while the other one is doubled). Limak isn't larger than Bob yet.
After the second year weights are 36 and 28, so the first weight is greater The second line of each test case contains integers
than the second one. Limak became larger than Bob after two years so – the initial contents of your array.
you should print 2.
It is guaranteed that the sum of over all test cases does not exceed
In the second sample, Limak's and Bob's weights in next years are: 12 .
and 18, then 36 and 36, and finally 108 and 72 (after three years). The
answer is 3. Remember that Limak wants to be larger than Bob and he Output
For each case, print the final version of array after operations
won't be satisfied with equal weights.
described above.
In the third sample, Limak becomes larger than Bob after the first year.
Their weights will be 3 and 2 then. input
3

2 1

D. Elephant -199 192

5 19

1 second, 256 megabytes


5 -1 4 2 0

1 2

An elephant decided to visit his friend. It turned out that the elephant's 69

house is located at point 0 and his friend's house is located at point


x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, output
4 or 5 positions forward. Determine, what is the minimum number of steps 391 0

he need to make in order to get to his friend's house. 0 6 1 3 5

Input
The first line of the input contains an integer x (1 ≤ x ≤ 1 000 000) — The In the first test case the array changes as follows:
coordinate of the friend's house.
Initially, the array is . .
Output
After the operation, the array becomes
Print the minimum number of steps that elephant needs to make to get
.
from point 0 to point x.

input F. LCM Problem


5
2 seconds, 256 megabytes
output
Let be the minimum positive integer that is divisible by both
1
and . For example, , .

input You are given two integers and . Find two integers and such that
and .
12

output Input
The first line contains one integer ( ) — the number of
3
test cases.

In the first sample the elephant needs to make one step of length 5 to Each test case is represented by one line containing two integers and (
reach the point x. ).

In the second sample the elephant can get to point x if he moves by 3, 5 Output
and 4. There are other ways to get the optimal answer but the elephant For each test case, print two integers:
cannot reach x in less than three moves.
if it is impossible to find integers and meeting the constraints in
the statement, print two integers equal to ;
E. Omkar and Infinity Clock otherwise, print the values of and (if there are multiple valid
2 seconds, 256 megabytes answers, you may print any of them).

Being stuck at home, Ray became extremely bored. To pass time, he asks input
Lord Omkar to use his time bending power: Infinity Clock! However, Lord
4

Omkar will only listen to mortals who can solve the following problem: 1 1337

13 69

You are given an array of integers. You are also given an integer . 2 4

Lord Omkar wants you to do operations with this array. 88 89

Define one operation as the following:

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 2/8
1/10/22, 5:53 AM Problems - Codeforces

output Pick a red ball, a green ball, and a blue ball and then change their
color to white.
6 7

14 21

2 4
You should answer if it's possible to arrange all the balls into a palindrome
-1 -1
after several (possibly zero) number of described operations.

Input
G. Substring Removal Game The first line contains one integer ( ) denoting the number
of test cases.
2 seconds, 256 megabytes
For each of the next cases, the first line contains four integers , ,
Alice and Bob play a game. They have a binary string (a string such that and ( ).
each character in it is either or ). Alice moves first, then Bob, then
Alice again, and so on. Output
For each test case, print "Yes" if it's possible to arrange all the balls into a
During their move, the player can choose any number (not less than one) palindrome after doing several (possibly zero) number of described
of consecutive equal characters in and delete them. operations. Otherwise, print "No".
For example, if the string is , there are possible moves (deleted
characters are bold): input
4

1. ; 0 1 1 1

2. ; 8 1 9 3

0 0 0 0

3. ; 1000000000 1000000000 1000000000 1000000000

4. ;
output
5. ;
6. . No

Yes

Yes

After the characters are removed, the characters to the left and to the right
Yes

of the removed block become adjacent. I. e. the following sequence of


moves is valid: . In the first test case, you're not able to do any operation and you can
The game ends when the string becomes empty, and the score of each never arrange three balls of distinct colors into a palindrome.
player is the number of -characters deleted by them. In the second test case, after doing one operation, changing
Each player wants to maximize their score. Calculate the resulting score to , one of those possible palindromes may be
of Alice. "rrrwwwbbbbrbbbbwwwrrr".

Input A palindrome is a word, phrase, or sequence that reads the same


The first line contains one integer ( ) — the number of backwards as forwards. For example, "rggbwbggr", "b", "gg" are
test cases. palindromes while "rgbb", "gbbgr" are not. Notice that an empty word,
phrase, or sequence is palindrome.
Each test case contains exactly one line containing a binary string (
).
I. Multiply by 2, divide by 6
Output
For each test case, print one integer — the resulting score of Alice (the 1 second, 256 megabytes
number of -characters deleted by her). You are given an integer . In one move, you can either multiply by two
or divide by (if it is divisible by without the remainder).
input
Your task is to find the minimum number of moves needed to obtain
5

01111001
from or determine if it's impossible to do that.
0000

You have to answer independent test cases.


111111

101010101

011011110111
Input
The first line of the input contains one integer ( ) — the
output number of test cases. Then test cases follow.
4

0
The only line of the test case contains one integer ( ).
6

3
Output
6
For each test case, print the answer — the minimum number of moves
needed to obtain from if it's possible to do that or -1 if it's impossible
Questions about the optimal strategy will be ignored. to obtain from .

H. Boboniu Likes to Color Balls input


7

1 second, 256 megabytes 1

Boboniu gives you 3

12

red balls, 12345

green balls, 15116544

387420489

blue balls,
white balls.

He allows you to do the following operation as many times as you want:

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 3/8
1/10/22, 5:53 AM Problems - Codeforces

output input
0
4

-1
6

2
3 7 1 4 1 2

-1
3 7 3 6 3 2

-1
5

12
1 1 1 1 1

36
1 2 1 3 1

Consider the sixth test case of the example. The answer can be obtained 42 42

42 42

by the following sequence of moves from the given integer :


1

1. Divide by and get ; 6

2. divide by and get ;


output
3. divide by and get ;
4. divide by and get ; YES

NO

5. multiply by and get ; YES

6. divide by and get ; NO

7. divide by and get ;


8. divide by and get ; The first test case is described in the statement: we can perform a push
9. multiply by and get ; operation with parameters to make equal to .
10. divide by and get ; In the second test case, we would need at least two operations to make
11. divide by and get ; equal to .
12. divide by and get .
In the third test case, arrays and are already equal.

In the fourth test case, it's impossible to make equal to , because the
J. Single Push integer has to be positive.
1 second, 256 megabytes

You're given two arrays and , both of the same length K. Filling Shapes
. 1 second, 256 megabytes
In order to perform a push operation, you have to choose three integers
You have a given integer . Find the number of ways to fill all tiles
satisfying and . Then, you will add to
with the shape described in the picture below. Upon filling, no empty
elements .
spaces are allowed. Shapes cannot overlap.
For example, if and you choose
, the array will become .

You can do this operation at most once. Can you make array equal to
array ?

(We consider that if and only if, for every , )

Input
The first line contains a single integer ( ) — the number of
test cases in the input.

The first line of each test case contains a single integer (


) — the number of elements in each array.

The second line of each test case contains integers (


This picture describes when . The left one is the shape and the
).
right one is tiles.
The third line of each test case contains integers ( Input
). The only line contains one integer ( ) — the length.

It is guaranteed that the sum of over all test cases doesn't exceed . Output
Print the number of ways to fill.
Output
For each test case, output one line containing "YES" if it's possible to
input
make arrays and equal by performing at most once the described
4

operation or "NO" if it's impossible.


output
You can print each letter in any case (upper or lower).
4

input
1

output
0

In the first example, there are possible cases of filling.

In the second example, you cannot fill the shapes in tiles.

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 4/8
1/10/22, 5:53 AM Problems - Codeforces

L. Make It Good In the second test case of the example, the initial array is not good. Let's
erase first elements of , the result is . The resulting array is
1 second, 256 megabytes
good. You can prove that if you erase fewer number of first elements, the
You are given an array consisting of integers. You have to find the result will not be good.
length of the smallest (shortest) prefix of elements you need to erase from
to make it a good array. Recall that the prefix of the array M. Omkar and Waterslide
is a subarray consisting several first elements: the
prefix of the array of length is the array ( 2 seconds, 256 megabytes
).
Omkar is building a waterslide in his water park, and he needs your help
The array of length is called good, if you can obtain a non- to ensure that he does it as efficiently as possible.
decreasing array ( ) from it, repeating the
Omkar currently has supports arranged in a line, the -th of which has
following operation times (initially, is empty):
height . Omkar wants to build his waterslide from the right to the left, so
his supports must be nondecreasing in height in order to support the
select either the first or the last element of , remove it from , and
waterslide. In operation, Omkar can do the following: take any
append it to the end of the array .
contiguous subsegment of supports which is nondecreasing by
For example, if we do operations: take , then , then and at heights and add to each of their heights.
last , then becomes and . Help Omkar find the minimum number of operations he needs to perform
Consider the following example: . This array is to make his supports able to support his waterslide!
good because we can obtain non-decreasing array from it by the
An array is a subsegment of an array if can be obtained from by
following sequence of operations:
deletion of several (possibly zero or all) elements from the beginning and
several (possibly zero or all) elements from the end.
1. take the first element of , so , ;
2. take the last element of , so , ; An array is called nondecreasing if for every
3. take the last element of , so , ; from to .
4. take the first element of , so , ;
Input
5. take the first element of , so , ;
Each test contains multiple test cases. The first line contains the number
6. take the last element of , so , ; of test cases ( ). Description of the test cases follows.
7. take the only element of , so ,  — is
non-decreasing. The first line of each test case contains an integer (
) — the number of supports Omkar has.
Note that the array consisting of one element is good.
The second line of each test case contains integers
Print the length of the shortest prefix of to delete (erase), to make to  — the heights of the supports.
be a good array. Note that the required length can be .
It is guaranteed that the sum of over all test cases does not exceed
You have to answer independent test cases. .
Input Output
The first line of the input contains one integer ( ) — the For each test case, output a single integer — the minimum number of
number of test cases. Then test cases follow. operations Omkar needs to perform to make his supports able to support
his waterslide.
The first line of the test case contains one integer ( )—
the length of . The second line of the test case contains integers
input
( ), where is the -th element of .
3

It is guaranteed that the sum of does not exceed ( 4

). 5 3 2 5

Output 1 2 3 5 3

For each test case, print the answer: the length of the shortest prefix of
1 1 1

elements you need to erase from to make it a good array.


output
input 3

1 2 3 4

7
The subarray with which Omkar performs the operation is bolded.
4 3 3 8 4 5 2

In the first test case:


3

1 1 1

7
First operation:
1 3 1 4 5 3 2

5 4 3 2 3

Second operation:
output
0

4
Third operation:
0

In the third test case, the array is already nondecreasing, so Omkar does
In the first test case of the example, the array is already good, so we operations.
don't need to erase any prefix.

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 5/8
1/10/22, 5:53 AM Problems - Codeforces

N. Game with Chips O. LCM Challenge


1 second, 256 megabytes 2 seconds, 256 megabytes

Petya has a rectangular Board of size . Initially, chips are placed Some days ago, I learned the concept of LCM (least common multiple).
on the board, -th chip is located in the cell at the intersection of -th I've played with it for several times and I want to make a big number with
row and -th column. it.

In one action, Petya can move all the chips to the left, right, down or up But I also don't want to use many numbers, so I'll choose three positive
by cell. integers (they don't have to be distinct) which are not greater than n. Can
you help me to find the maximum possible least common multiple of these
If the chip was in the cell, then after the operation:
three integers?
left, its coordinates will be ; Input
right, its coordinates will be ; 6
The first line contains an integer n (1 ≤ n ≤ 10 ) — the n mentioned in the
down, its coordinates will be ; statement.
up, its coordinates will be .
Output
If the chip is located by the wall of the board, and the action chosen by Print a single integer — the maximum possible LCM of three not
Petya moves it towards the wall, then the chip remains in its current necessarily distinct positive integers that are not greater than n.
position.
input
Note that several chips can be located in the same cell.
9

For each chip, Petya chose the position which it should visit. Note that it's
not necessary for a chip to end up in this position. output
504

Since Petya does not have a lot of free time, he is ready to do no more
than actions.
input
You have to find out what actions Petya should do so that each chip visits 7

the position that Petya selected for it at least once. Or determine that it is
not possible to do this in actions. output
210

Input
The first line contains three integers ( ) — the The least common multiple of some positive integers is the least positive
number of rows and columns of the board and the number of chips, integer which is multiple for each of them.
respectively.
The result may become very large, 32-bit integer won't be enough. So
The next lines contains two integers each ( using 64-bit integers is recommended.
) — the starting position of the -th chip.
For the last example, we can chose numbers 7, 6, 5 and the LCM of them
The next lines contains two integers each (
is 7·6·5 = 210. It is the maximum value we can get.
) — the position that the -chip should visit
at least once.
P. The Best Vacation
Output
In the first line print the number of operations so that each chip visits the 2 seconds, 256 megabytes
position that Petya selected for it at least once.
You've been in love with Coronavirus-chan for a long time, but you didn't
In the second line output the sequence of operations. To indicate know where she lived until now. And just now you found out that she lives
operations left, right, down, and up, use the characters in a faraway place called Naha.
respectively.
You immediately decided to take a vacation and visit Coronavirus-chan.
If the required sequence does not exist, print -1 in the single line. Your vacation lasts exactly days and that's the exact number of days
you will spend visiting your friend. You will spend exactly consecutive
input (successive) days visiting Coronavirus-chan.
3 3 2
They use a very unusual calendar in Naha: there are months in a year,
1 2
-th month lasts exactly days. Days in the -th month are numbered
2 1

3 3
from to . There are no leap years in Naha.
3 2

The mood of Coronavirus-chan (and, accordingly, her desire to hug you)


output depends on the number of the day in a month. In particular, you get
3
hugs if you visit Coronavirus-chan on the -th day of the month.
DRD
You know about this feature of your friend and want to plan your trip to get
as many hugs as possible (and then maybe you can win the heart of
input Coronavirus-chan).
5 4 3

3 4
Please note that your trip should not necessarily begin and end in the
3 1
same year.
3 3

5 3
Input
1 3
The first line of input contains two integers and ( )—
1 4

the number of months in the year and the number of days you can spend
output with your friend.
9

The second line contains integers , is the number of


DDLUUUURR
days in the -th month ( ).

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 6/8
1/10/22, 5:53 AM Problems - Codeforces
It is guaranteed that . Input
The first line contains four integers , , and (
Output
, , ): the number of flowers
Print one integer — the maximum number of hugs that you can get from
on the liana, the number of flowers in one wreath, the amount of citizens
Coronavirus-chan during the best vacation in your life.
and the length of Diana's flower sequence respectively.

input The second line contains integers , , ..., ( )


3 2
 — types of flowers on the liana.
1 3 1

The third line contains integers , , ..., ( )  — the


output sequence in Diana's schematic.
5
Output
If it's impossible to remove some of the flowers so that there would be at
input least workpieces and at least one of them fullfills Diana's schematic
3 6
requirements, output .
3 3 3

Otherwise in the first line output one integer  — the number of flowers to
output
be removed by Diana.
12
In the next line output different integers  — the positions of the flowers
to be removed.
input
5 6
If there are multiple answers, print any.
4 2 3 1 3

output input
7 3 2 2

15
1 2 3 3 2 1 2

2 2

In the first test case, the numbers of the days in a year are (indices of
days in a corresponding month) . Coronavirus-chan will hug output
you the most if you come on the third day of the year: hugs. 1

In the second test case, the numbers of the days are


. You will get the most hugs if you arrive on the
input
third day of the year: hugs.
13 4 3 3

In the third test case, the numbers of the days are 3 2 6 4 1 4 4 7 1 3 3 2 4

. You will get the most hugs if you 4 3 4

come on the twelfth day of the year: your friend will hug you output
times.
-1

Q. Diana and Liana input


2 seconds, 256 megabytes 13 4 1 3

3 2 6 4 1 4 4 7 1 3 3 2 4

At the first holiday in spring, the town Shortriver traditionally conducts a 4 3 4

flower festival. Townsfolk wear traditional wreaths during these festivals. output
Each wreath contains exactly flowers.
9

The work material for the wreaths for all citizens of Shortriver is cut from 1 2 3 4 5 9 11 12 13

the longest flowered liana that grew in the town that year. Liana is a
In the first example, if you don't remove any flowers, the machine would
sequence , , ..., , where is an integer that denotes the type of
put out two workpieces with flower types and . Those
flower at the position . This year the liana is very long ( ), and
workpieces don't fit Diana's schematic. But if you remove flower on -th
that means every citizen will get a wreath.
place, the machine would output workpieces and . The
Very soon the liana will be inserted into a special cutting machine in order second workpiece fits Diana's schematic.
to make work material for wreaths. The machine works in a simple
In the second example there is no way to remove flowers so that every
manner: it cuts flowers from the beginning of the liana, then another
citizen gets a wreath and Diana gets a workpiece that fits here schematic.
flowers and so on. Each such piece of flowers is called a workpiece.
The machine works until there are less than flowers on the liana. In the third example Diana is the only citizen of the town and that means
she can, for example, just remove all flowers except the ones she needs.
Diana has found a weaving schematic for the most beautiful wreath
imaginable. In order to weave it, flowers must contain flowers of types
, , ..., , while other can be of any type. If a type appears in this R. Race
sequence several times, there should be at least that many flowers of that
2 seconds, 256 megabytes
type as the number of occurrences of this flower in the sequence. The
order of the flowers in a workpiece does not matter.
Today s kilometer long auto race takes place in Berland. The track is
Diana has a chance to remove some flowers from the liana before it is represented by a straight line as long as s kilometers. There are n cars
inserted into the cutting machine. She can remove flowers from any part taking part in the race, all of them start simultaneously at the very
of the liana without breaking liana into pieces. If Diana removes too many beginning of the track. For every car is known its behavior — the system
flowers, it may happen so that some of the citizens do not get a wreath. of segments on each of which the speed of the car is constant. The j-th
Could some flowers be removed from the liana so that at least one segment of the i-th car is pair (vi, j, ti, j), where vi, j is the car's speed on
workpiece would conform to the schematic and machine would still be the whole segment in kilometers per hour and ti, j is for how many hours
able to create at least workpieces? the car had been driving at that speed. The segments are given in the
order in which they are "being driven on" by the cars.

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 7/8
1/10/22, 5:53 AM Problems - Codeforces
Your task is to find out how many times during the race some car output
managed to have a lead over another car. A lead is considered a situation
1

when one car appears in front of another car. It is known, that all the leads
happen instantly, i. e. there are no such time segment of positive length,
during which some two cars drive "together". At one moment of time on input
one and the same point several leads may appear. In this case all of them 2 33

should be taken individually. Meetings of cars at the start and finish are 2 1 3 10 3

1 11 3

not considered to be counted as leads.


output
Input
6 0

The first line contains two integers n and s (2 ≤ n ≤ 100, 1 ≤ s ≤ 10 ) —


the number of cars and the length of the track in kilometers. Then follow n
lines — the description of the system of segments for each car. Every input
description starts with integer k (1 ≤ k ≤ 100) — the number of segments 5 33

in the system. Then k space-separated pairs of integers are written. Each 2 1 3 3 10

1 11 3

pair is the speed and time of the segment. These integers are positive and 2 5 3 3 6

don't exceed 1000. It is guaranteed, that the sum of lengths of all 2 3 1 10 3

segments (in kilometers) for each car equals to s; and all the leads 2 6 3 3 5

happen instantly. output


Output 2

Print the single number — the number of times some car managed to take
the lead over another car during the race.

input
2 33

2 5 1 2 14

1 3 11

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov


The only programming contests Web 2.0 platform

https://codeforces.com/group/8lnePmWc8m/contest/345456/problems 8/8

You might also like