You are trying to pass the time while at the optometrist. You notice there is a grid of four numbers:
1 | 2 |
3 | 4 |
You see lots of mirrors and lenses at the optometrist, and wonder how flipping the grid horizontally or vertically would change the grid.
Specifically, a “horizontal” flip (across the horizontal centre line) would take the original grid of four numbers and result in:
3 | 4 |
1 | 2 |
A “vertical” flip (across the vertical centre line) would take the original grid of four numbers and result in:
2 | 1 |
4 | 3 |
Your task is to determine the final orientation of the numbers in the grid after a sequence of horizontal and vertical flips.
The input consists of one line, composed of a sequence of at least one
and at most 1 000 000 characters. Each character is either
H
, representing a horizontal flip, or
V
, representing a vertical flip.
For 8 of the 15 available marks, there will be at most 1 000 characters in the input.
Output the final orientation of the four numbers. Specifically, each of the two lines of output will contain two integers, separated by one space.
HV
4 3
2 1
VVHH
1 2
3 4
For various given positive integers
Recall that a prime number is an integer
The first line of input is the number
For 6 of the available 15 marks, all
The output will consist of
If there are more than one possible
It will be the case that there will always be at least one set of
values
4
8
4
7
21
3 13
5 3
7 7
13 29
Notice that:
You may have heard about Goldbach’s conjecture, which states that every even integer greater than 2 can be expressed as the sum of two prime numbers. There is no known proof, yet, so if you want to be famous, prove that conjecture (after you finish the CCC).
This problem can be used to help verify that conjecture, since every
even integer can be written as
You are given a
Some of the 9 elements in the grid will have a value already, and the remaining elements will be unspecified.
Your task is to determine values for the unspecified elements such that each row, when read from left-to-right is an arithmetic sequence, and that each column, when read from the top-down, is an arithmetic sequence.
Recall that an arithmetic sequence of length
three is a sequence of integers of the form
The input will be 3 lines long. Each line will have three
space-separated values. Each value will either be an integer in the
range from X
.
For 4 of the 15 marks available, there will be at most 3
X
symbols in the input.
For an additional 3 of the 15 marks available, all integer values in the input will be between -10 and 10, inclusive.
For an additional 4 of the 15 marks available, there will be at least
7 X
symbols in the input.
For an additional 2 of the 15 marks available, all integer values in the input will be even numbers.
The output will be 3 lines long. Each line will have three space-separated integers. All integers that were given in the input must be in their same position (i.e., same row and same column as in the input). All rows and columns must form arithmetic sequences. All integers in the output must be between -1 000 000 000 and 1 000 000 000, inclusive.
If there is more than one solution, output any solution. There is guaranteed to be at least one solution.
8 9 10
16 X 20
24 X 30
8 9 10
16 18 20
24 27 30
Notice that the second element of the second row must be
14 X X
X X 18
X 16 X
14 20 26
18 18 18
22 16 10
This is one of many possible solutions. For example, another solution is:
14 16 18
14 16 18
14 16 18
You are planning a trip to visit
Under these constraints, you want to find a schedule that has a nice
balance between the attractions visited each day. To be precise, we
assign a score
The first line contains two space-separated integers
The next line contains
For 3 of the 15 available marks,
For an additional 3 of the 15 available marks,
Output a single integer, the maximum possible total score.
5 3
2 5 7 1 4
12
We need to have at least two days to visit all the attractions, since we cannot visit all attractions in one day.
Visiting the first two attractions on day 1 will give a score of 5, and visiting the last three attractions on day 2 will give a score of 7, for a total score of 12.
Visiting three attractions on day 1, and two attractions on day 2,
which is the only possibility to visit in the fewest number of days
possible, would yield a total score of
In a parallel universe, the most important data structure in computer
science is the triangle. A triangle of size
A triangle contains sub-triangles. For example, the triangle above
contains ten sub-triangles of size 1, six sub-triangles of size 2 (two
of which are the triangle containing
You are given a triangle of size
The first line contains two space-separated integers
Following this are
For 4 of the 15 available marks,
Output the integer sum of the maximum elements of every sub-triangle of
size
4 2
3
1 2
4 2 1
6 1 4 2
23