At a recent social gathering,
Each person looks at the person who is directly across (diametrically opposite) them in the circle.
Determine the number of people who see someone with a hat with the same number as their own.
The first line of input will consist of one even positive integer
The next
The following table shows how the available
Marks | Description | Bounds on |
Bounds on |
---|---|---|---|
Very small number of people; only two hat numbers | |||
Only one hat number | |||
People in even numbered seats have hat number 1; people in odd numbered seats have hat number 0 | |||
Medium number of people | |||
Large number of people and hat numbers |
Output a single integer representing the number of people who see their hat number on the person directly across from them.
4
0
1
0
1
4
The four seats around the table are shown below. Hat numbers are shown inside each seat and seat numbers are shown beside each seat.
Notice that every person sees their hat number. The people in seats
4
1
0
0
1
0
The four seats around the table are shown below. Hat numbers are shown inside each seat and seat numbers are shown beside each seat.
Notice that no person sees their hat number. The people in seats
In a string containing only lowercase letters of the alphabet ("a" through "z"), we say a letter is heavy if it appears more than once in the string, and light otherwise.
We will be given a number of strings. For each string, we would like to determine whether the letters of the string alternate between light and heavy.
The first line of input will consist of two positive integers
The next
The following table shows how the available
Marks | Bounds on |
Bounds on |
Other Restrictions |
---|---|---|---|
Only the letters "a" and "b" will be used | |||
None | |||
Only the letter "a" will be heavy; all other letters are light | |||
None |
Output T
or F
. If the T
; and otherwise, the F
.
3 4
abcb
bcbb
babc
T
F
T
The first string is composed of a light letter, then a heavy letter, then a light letter, and then a heavy letter.
The second string ends in two consecutive heavy letters.
The third string is composed of a heavy letter, then a light letter, then a heavy letter, and then a light letter.
2 3
abc
bcb
F
T
The first string is composed of all light letters.
The second string is composed of a heavy letter, then a light letter, and then a heavy letter.
Swipe is a new mobile game that has recently exploded in popularity.
In each level of Swipe, you are given
There are two swipe operations you can perform on array
Swipe right: Select the subarray
Swipe left: Select the subarray
For example, starting with array
Unfortunately, the game is bugged and contains levels that are
impossible to beat. Determine if it is possible to transform array
The first line of input will consist of one positive integer
The second line of input contains
The third line of input contains
The following table shows how the available
Marks | Bounds on |
Bounds on |
---|---|---|
Note that for a subtask worth
The first line of output will contain YES
if there is a
sequence of swipes that can transform array NO
.
If the first line of output is YES
, the next line
contains a non-negative integer
Each of the next R
or
L
, indicating that the
3
3 1 2
3 1 1
YES
1
R 1 2
4
1 2 4 3
1 4 2 3
NO
4
2 1 4 3
2 1 4 3
YES
0
Alanna, the mayor of Kitchener, has successfully improved the city’s road plan. However, a travelling salesperson from the city of RedBlue complained that the roads are not colourful enough. Alanna’s second job is to paint some of the roads.
Kitchener’s road plan can be represented as a collection of
Whenever there is a grey road that connects
To lower the city’s annual spending, Alanna would like to minimize the number of painted roads. Can you help Alanna design a plan that meets all the requirements?
The first line contains two integers
The
There is at most one road between any unordered pair of intersections.
The following table shows how the available 15 marks are distributed:
Marks | Additional Constraints |
---|---|
There is a road connecting intersection
|
|
We can reach any intersection from any
other intersection, and |
|
No road belongs to two or more simple cycles (see Definition below). | |
None |
Definition: if we denote a road between intersections
Output a string of R
if the B
if G
(for "grey") if the
Remember that you must minimize the number of painted roads while satisfying the condition. If there are multiple possible such plans, output any of them.
5 7
1 2
2 4
5 2
4 5
4 3
1 3
1 4
RGGRGRB
A diagram of the intersections along with a valid paint plan that minimizes the number of painted roads is shown below. Note that the colours are shown on each road as R (red), B (blue), or G (grey).
All the unpainted roads satisfy the condition:
The
The
The
4 2
1 2
3 4
BB
Note that it is possible for Kitchener to be disconnected.
Maxwell has a chocolate bar that he wants to share with his friends.
The chocolate bar can be represented as a
A part is considered connected if you can visit every cell by moving up, down, left or right.
The first line of input will consist of one positive integer
The second line of input contains
Similarly, the third line of input contains
The following table shows how the available
Marks | Bounds on |
Bounds on |
---|---|---|
Output a single integer, representing the maximum number of connected parts Maxwell can split his chocolate bar into.
2
5 4
6 5
2
An example of how to split this chocolate bar optimally into
Each piece will have an average tastiness of
5
1 0 1 2 0
0 2 0 3 1
5
One way to get the optimal split is shown in the following picture:
Note that each piece has an average tastiness of