Bocchi the Builder just finished constructing her latest project: a laneway consisting of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck! She accidentally spilled black paint on some of the tiles. Now, some of the tiles are wet and the other tiles are dry. Bocchi must place warning tape around the perimeters of all wet areas. Can you help her determine how many metres of tape she needs?
The first triangular tile will point upwards. Each pair of adjacent tiles (that is, tiles that share a common side) will point in opposite directions. Each tile has a side length of 1 metre.
The first line of input will consist of one positive integer
The next two lines will each consist of
The following table shows how the available 15 marks are distributed:
Marks | Description | Bound |
---|---|---|
3 | The laneway is not very long, black tiles are never adjacent and the second row is fully white. | |
3 | The laneway is not very long, black tiles may be adjacent and the second row is fully white. | |
5 | The laneway is not very long, black tiles may be adjacent and may appear in the second row. | |
4 | The laneway may be very long, black tiles may be adjacent and may appear in the second row. |
Output a single integer representing the length of tape Bocchi needs, in metres.
5
1 0 1 0 1
0 0 0 0 0
9
The tiles are painted as follows, creating three wet areas. Bocchi will need 9 metres of warning tape as shown in yellow.
7
0 0 1 1 0 1 0
0 0 1 0 1 0 0
11
The tiles are painted as follows, creating three wet areas. Bocchi will need 5 metres of warning tape to surround one area and 3 metres of warning tape to surround each of the other two areas as shown in yellow.
Rebecca is a tour guide and is trying to market the Rocky Mountains
for her magazine. She recently took a beautiful picture consisting of
We will measure the asymmetric value of a crop as the sum of
the absolute difference for every pair of mountains equidistant from the
midpoint of the crop. To help understand that definition, note that the
absolute value of a number
Because Rebecca does not know how wide the picture needs to be, for all possible crop lengths, find the asymmetric value of the most symmetric crop (the crop with the minimum asymmetric value).
The first line consists of an integer
The second line consists of
The following table shows how the available 15 marks are distributed:
Marks | Bounds on |
Bounds on |
Additional Constraints |
---|---|---|---|
5 | None | ||
5 | Height of mountains are in non-decreasing order from left to right. | ||
5 | None |
Output on one line
7
3 1 4 1 5 9 2
0 2 0 5 2 10 10
We will show why the fifth value from the left is 2. Let us try to compute all the asymmetric values of crops with length 5.
The height of the mountains in the first crop is
The height of the mountains in the second crop is
The height of the mountains in the last crop is
Hence, the most symmetric crop of length 5 is 2.
4
1 3 5 6
0 1 3 7
This sample satisfies the second subtask. Note that the only crop of
length 4 is
Ryo and Kita are designing a new poster for Kessoku Band. After some
furious brainstorming, they came to the conclusion that the poster
should come in the form of a 2-D grid of lowercase English letters (i.e.
a
to z
), with
Furthermore, it is known that Ryo and Kita both have peculiar tastes
in palindromes. Ryo will only be satisfied with the poster if exactly
Note: A string is considered a palindrome
if it is the same when read forwards and backwards. For example,
kayak
and bb
are palindromes, whereas
guitar
and live
are not.
The first and only line of input consists of
The following table shows how the available 15 marks are distributed:
Marks | Bounds on |
Bounds on |
Bounds on |
Bounds on |
---|---|---|---|---|
2 marks | ||||
2 marks | ||||
4 marks | ||||
7 marks |
If it is impossible to design a poster that will satisfy both Ryo and
Kita, output IMPOSSIBLE
on a single line.
Otherwise, your output should contain
4 5 1 2
union
radar
badge
anime
In the given design, only the second row (namely radar
)
and the second and third columns (namely naan
and
iddi
) are palindromes. Since exactly
2 2 2 1
IMPOSSIBLE
In this case, it can be proven that it is impossible to satisfy both Ryo and Kita.
As the newly elected mayor of Kitchener, Alanna’s first job is to improve the city’s road plan.
Kitchener’s current road plan can be represented as a collection of
To lower the city’s annual spending, Alanna would like to minimize
the plan’s cost. However, the city also requires that she minimizes
travel distances between intersections and will reject any plan that
does not conform to those rules. Formally, for any pair of intersections
The first line contains the integers
Each of the next
The following table shows how the available 15 marks are distributed.
Marks | Bounds on |
Bounds on |
Bounds on |
Additional Constraints |
---|---|---|---|---|
None | ||||
There is at most one road between any unordered pair of intersections. | ||||
None |
Output one integer, the minimum possible cost of a road plan that meets the requirements.
5 7
1 2 15 1
2 4 9 9
5 2 5 6
4 5 4 4
4 3 3 7
1 3 2 7
1 4 2 1
25
Here is a diagram of the intersections along with a valid road plan with minimum cost.
Each edge is labeled with a pair
It can be shown that we cannot create a cheaper plan that also respects the city’s requirements.
Alice, the mathematician, likes to study real numbers that are between 0 and 1. Her favourite tool is the filter.
A filter covers part of the number line. When a number reaches a filter, two events can happen. If a number is not covered by the filter, the number will pass through. If a number is covered, the number will be removed.
Alice has infinitely many filters. Her first 3 filters look like this:
In general, the
Consider the number line from 0 to 1.
Split this number line into
The
Alice has instructions for constructing the Cantor set. Start with the number line from 0 to 1. Apply all filters on the number line, and remove the numbers that are covered. The remaining numbers form the Cantor set.
Alice wants to research the Cantor set, and she came to you for help.
Given an integer
The first line contains the integer
The following table shows how the available 15 marks are distributed.
Marks | Bounds on |
Additional Constraints |
---|---|---|
3 marks | ||
4 marks | None | |
8 marks | None |
Output all integers
Output the answers in increasing order. The number of answers will
not exceed
12
0
1
3
4
8
9
11
12
Here is a diagram of the fractions and the first 4 filters. In reality, there are infinitely many filters.
Furthermore,
It can be shown that the remaining fractions will pass through all filters.