In the country of Voronoi, there are
Each village defines its neighbourhood as all
points along the road which are closer to it than to any other village.
A point which is equally close to two distinct villages
Each neighbourhood has a size which is the difference between the minimum (leftmost) point in its neighbourhood and the maximum (rightmost) point in its neighbourhood.
The neighbourhoods of the leftmost and rightmost villages are defined to be of infinite size, while all other neighbourhoods are finite in size.
Determine the smallest size of any of the neighbourhoods (with exactly 1 digit after the decimal point).
The first line will contain the number
Output the smallest neighbourhood size with exactly one digit after the decimal point.
5
16
0
10
4
15
3.0
The neighbourhoods around
Barbara plants
She records each of these measurements in a table, with one row for each plant, with the first row recording the shortest sunflower’s growth and the last row recording the tallest sunflower’s growth. The leftmost column is the first measurement for each sunflower, and the rightmost column is the last measurement for each sunflower.
If a sunflower was smaller than another when initially planted, it remains smaller for every measurement.
Unfortunately, her children may have altered her measurements by rotating her table by a multiple of 90 degrees.
Your job is to help Barbara determine her original data.
The first line of input contains the number
Output Barbara’s original data, consisting of
2
1 3
2 9
1 3
2 9
The data has been rotated a multiple of 360 degrees, meaning that the input arrangement is the original arrangement.
3
4 3 1
6 5 2
9 7 3
1 2 3
3 5 7
4 6 9
The original data was rotated 90 degrees to the right/clockwise.
3
3 7 9
2 5 6
1 3 4
1 2 3
3 5 7
4 6 9
The original data was rotated 90 degrees to the left/counter-clockwise.
A robot has stolen treasure from a factory and needs to escape without
getting caught. The factory can be modelled by an
Each cell of the grid is either empty, a wall, a camera, a conveyor,
or the robot’s initial position. The robot can only walk on empty cells
(denoted by .
) or conveyors. The first row,
last row, first column and last column of the grid consists of walls
(denoted by W
), and there may be walls in
other cells.
Conveyors cause the robot to move in a specific direction, denoted by
L
, R
,
U
, D
for left,
right, up, down respectively. The robot is unable to move on its own
while on a conveyor. It is possible that the robot can become stuck
forever on conveyors.
Cameras (denoted by C
) can see in all four
directions up, down, left, and right, but cannot see through walls. The
robot will be caught if it is in the same cell as a camera or is seen by
a camera while on an empty cell. Conveyors are slightly elevated, so the
robot cannot be caught while on a conveyor, but cameras can see empty
cells on the other side of conveyors.
The robot is initially at the cell denoted by
S
. The exit could be at any of the empty
cells. For each empty cell, determine the minimum number of steps needed
for the robot to move there without being caught, or determine that it
is impossible to move there. A step consists of moving once up, down,
left or right. Being moved by a conveyor does not count as a step.
The first line of input contains two integers W
, .
,
C
, S
,
L
, R
,
U
, or D
.
There will be exactly one S
character and
at least one .
character. The first and last
character of every row and column will be
W
.
For 5 of the 15 marks available, there are no cameras or conveyors.
For an additional 5 of the 15 marks available, there are no conveyors.
For each empty cell, print one line with one integer, the minimum number
of steps for the robot to move to this empty cell without being caught
or
The output should be in row major order; the order of empty cells seen if the input is scanned line by line top-to-bottom and then left-to-right on each line. See the sample outputs for examples of row major order output.
4 5
WWWWW
W.W.W
WWS.W
WWWWW
-1
2
1
The robot cannot move to the top left empty cell because it is blocked by walls.
The top right empty cell can be reached in
5 7
WWWWWWW
WD.L.RW
W.WCU.W
WWW.S.W
WWWWWWW
2
1
3
-1
-1
1
The empty cell to immediate left of the robot is seen by the camera so the robot cannot move there.
The empty cell right below the R
conveyor
is also seen by the camera as conveyors do not block the the sight of
cameras.
Note that the robot can use the U
and
L
conveyors to avoid the getting caught by the
camera.
If the robot moves to the R
conveyor, it
will become stuck forever there.
Trees have many fascinating properties. While this is primarily true for trees in nature, the concept of trees in math and computer science is also interesting. A particular kind of tree, a perfectly balanced tree, is defined as follows.
Every perfectly balanced tree has a positive integer weight.
A perfectly balanced tree of weight
In particular, all
Given
The input will be a single line containing the integer
For
For an additional
For an additional
Output a single integer, the number of perfectly balanced trees with
weight
4
3
One tree has a root with four subtrees of weight 1; a second tree has a root with two subtrees of weight 2; the third tree has a root with three subtrees of weight 1.
10
13
A long time ago in a galaxy far, far away, there are
There are
There are
It is possible to travel between any two cities in the galaxy using only flights and/or portals.
Hard times have fallen on the galaxy. It was decided that some flights and/or portals should be shut down to save as much energy as possible, but it should remain possible to travel between any two cities afterwards.
What is the maximum sum of energy that can be saved daily?
The first line contains four space-separated integers
Then
Then
It is guaranteed that it will be possible to travel between any two cities using flights and/or portals. There may be multiple flights/portals between the same pair of cities or a flight/portal between a city and itself.
For 2 of the 15 available marks,
For an additional 2 of the 15 available marks,
For an additional 5 of the 15 available marks,
Output a single integer, the maximum sum of energy that can be saved daily.
2 2 1 2
1 2 1
2 1 1
2 1 1
3
2 3 4 1
2 3 5
3 2 7
1 2 6
1 1 8
2 1 5
41
One possible way is to shut down the flights between cities