Time Limit: 1 second
Vera loves hiking and is going to build her own trail network. It
will consist of
Vera considers two places
Vera does not want her network to be too large, so the network should
satisfy
Given
There is one line of input, which contains the integer
For 3 of the 25 available marks,
For an additional 6 of the 25 available marks,
Print a beautiful network in the following format:
the first line should contain the number of vertices,
each of the next
The trails can be printed in any order. The two places of any trail can be printed in any order. If there are multiple beautiful trail networks, print any of them. It is guaranteed that a solution always exists.
2
4 5
1 2
2 1
3 4
4 3
1 4
The two beautifully connected pairs are
6
4 4
1 2
2 3
3 4
4 1
All pairs of places form a beautifully connected pair.
Time Limit: 2 seconds
Long ago, in the land of Cartesia, there ruled the Rectangle Empire. The Empire was large and prosperous, and it had great success with expanding its territory through frequent conquests. The citizens of this ancient civilization followed many curious customs. Unfortunately, the significance of these are now shrouded in mystery.
The Rectangle Empire operated under a system of rectangular districts. These districts were carefully managed to meet three special criteria.
The Empire’s territory is divided into districts such that each piece of land controlled by the Empire belongs to exactly one district.
The boundaries of the districts, when viewed on a map, must be rectangles such that the length of the longer side of the rectangle is twice the length of the shorter side.
The side lengths of the districts must be integers, when measured
in
When the empire was first established, it consisted of a single district. Since then, the empire has gained additional districts through conquest of neighbouring regions. Whenever the empire gained control over a new region of land, they always established a single new district using that exact land. This means that the empire was always mindful about the geometric properties of the land they were hoping to conquer. You can assume that no two of these conquests occurred at the same time.
The addition of new districts was the only way that the boundaries of the empire ever changed. Furthermore, each district, once added, was never modified or merged with another.
The final, most important tradition of the Rectangle Empire was to make sure that the overall territory of the empire was always a rectangle, though it did not necessarily need to satisfy the 2:1 ratio for the side lengths that individual districts satisfy.
Recently, archeologists have discovered that at one point in time,
the empire had dimensions
The input will be a single line, containing two integers
For 5 of the 25 marks available,
For an additional 8 of the 25 marks available,
Output a single line, containing the minimum number of districts, followed by a space, followed by the maximum number of districts.
10 6
5 8
The illustrations below show how this minimum and maximum number of
districts could have been achieved. Districts are labelled #1, #2, #3,
... giving the order in which they were added to the region. The
dimensions of each district is shown in brackets as (
Time Limit: 4 seconds
After being inspired by the great painter Picowso, Vera decided to
make her own masterpiece. She has an empty painting surface which can be
modeled as an infinite 2D coordinate plane. Vera likes powers of two
Vera will paint
Then Vera will ask
Since you are forced to be her art assistant, you will have to answer Vera’s questions.
The first line contains two integers
The next
The next
For 5 of the 25 available marks,
For an additional 5 of the 25 available marks,
For an additional 5 of the 25 available marks,
The output will be
5 6
1 2 1
3 4 2
4 5 3
6 3 4
7 1 5
2 6
7 8
5 9
11 2
10 7
4 5
1
8
0
6
4
3
Let colour
Let
Points
Points
Points
Points
Points
The painting from
We can see that:
Time Limit: 1 second
It was a dark and stormy night. It also rained, and rained, and rained.
Lucy wants to capture some of the rain, but she only has limited materials. She has a collection of pillars, of various heights, which she can configure to capture the rain. Each pillar is an integer height and has length and width of 1. Once Lucy has her configuration of pillars, she has enough other siding material to enclose the front and back to allow rain to fill the all the available space in between pillars. There is more than enough rain and any excess rain will overflow and get absorbed into the earth.
For example, if Lucy has pillars of height 1, 5, 2, 1, 4, she could configure them as follows (all configurations are illustrated from the side):
*
* *
* *
** *
*****
which would capture 5 units of rain (R
) as follows:
*
*RR*
*RR*
**R*
*****
For this first collection of pillars (1, 5, 2, 1, 4), she could also capture 6 units of rain as follows:
*
*RR*
*RR*
**RR*
*****
As another example, if the collection of pillars was 5, 1, 5, 1, 5, Lucy could capture 8 units of rain as follows:
*R*R*
*R*R*
*R*R*
*R*R*
*****
Finally, this configuration of (5, 1, 4, 1, 5) captures 9 units of rain:
*RRR*
*R*R*
*R*R*
*R*R*
*****
Lucy has
The first line contains the integer
For 5 of the 25 marks available,
For an additional 10 of the 25 marks available,
On one line, output a space-separated list of all possible obtainable integer volumes of rain captured, in increasing order.
5
1 5 2 1 4
0 1 2 3 4 5 6 8
This is the first given example.
5
5 1 5 1 5
0 4 8
This is the second given example.
5
5 1 4 1 5
0 1 3 4 5 6 7 8 9
This is the third given example.
Time Limit: 2 seconds
Kevin is developing his professional network within a certain
community. Unfortunately, he has not connected with anybody yet. But he
has his eyes on
However, few people in this community are willing to friend an
outsider. Each of the
Kevin likes his Internet Points very much, and so he doesn’t want to
give away too many. Now it is your job to help Kevin give away the least
number of Internet Points while still making connections with each of
the
The first line will contain the integer
For 2 of the 25 available marks,
For an additional 4 of the 25 available marks,
For an additional 7 of the 25 available marks,
Output one integer on a single line, the minimum number of Internet Points Kevin has to give away.
4
3 3
1 2
0 5
3 4
3
Kevin can connect with person 3 immediately, and with this connection made, he can also connect with person 2. He doesn’t have enough connections to connect with person 1 or person 4, so he gives 3 Internet Points to person 1 to acquire 3 total connections which enables him to connect with person 4.
5
0 9
1 8
2 7
3 6
4 5
0
It is possible that Kevin can connect with everyone without giving away any Internet Points.
3
0 6
2 7
3 8
8
Kevin should connect with person 1 immediately, then give 8 Internet Points to person 3 to connect with them, then connect with person 2.
Time Limit: 2 seconds
You are given a rectangular grid of numbered tiles, with no empty spaces. This grid can only be manipulated using a sequence of shift operations. A shift involves either moving an entire row left or right by some number of units, or moving an entire column up or down by some number of units. Tiles which move outside of the rectangular boundaries wrap around to the opposite side of the grid. For example, in the grid
0 | 1 | 2 | 3 |
4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
a vertical shift downwards by one applied to the second column has the following result:
0 | 13 | 2 | 3 |
4 | 1 | 6 | 7 |
8 | 5 | 10 | 11 |
12 | 9 | 14 | 15 |
Notice that a left shift by
In a grid with
You may have noticed that in the first example given above, the tiles
are in a very organized formation. We call such arrangements
solved. That is, a grid of tiles is solved when the first row
contains the numbers from
Find a sequence of shift operations that restores a scrambled grid to a solved state.
The first line will contain two space-separated integers
Note that both
For 5 of the available 25 marks,
For an additional 10 of the available 25 marks, the puzzle is solvable in at most 2 moves.
Output any sequence of moves that solves the puzzle, in the following format:
The first line of output should contain a single integer
The next 1
2
2 4
4 2 3 0
1 5 6 7
2
2 1 1
1 1 1
We shift the first column down by one to obtain
1 2 3 0
4 5 6 7
then shift the first row right by one to reach the state
0 1 2 3
4 5 6 7
which is solved.
4 2
2 3
5 0
4 1
6 7
7
1 1 1
2 1 1
1 2 1
1 3 1
2 1 2
1 1 1
2 1 1
The sequence of shifts, starting from the input is:
Input | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th |
|
|
|
|
|
|
|
|