Mock CCC '26 J4 - The Hidden Vault
View as PDFMock Canadian Computing Competition: 2026 Junior #4
Dr. Bronstein is a famous scientist that does top-secret research. He keeps all of his most prized and the secretive research done in a hidden vault in the basement of a library, which is closed off by a giant vault door.
The vault door is circular, and acts like a large combination lock. There are numerical bits that appear along the circumference, each either a
or
. Specifically, the
bit is adjacent to the
and
bit, with the
being adjacent to the
.
In order for the vault to open, the following conditions must be met:
- each
bit must be directly adjacent to an odd number of
bits
- each
bit must be directly adjacent to an even number of
bits
What is the minimum number of bit flips needed such that the vault will open?
Input Specification
The first line contains a single integer , the number of bits.
The next line contains a string of bits, each being
or
, indicating the initial state of bits on the combination lock.
The following table shows how the available 15 marks are distributed.
| Marks | Bounds on |
Description |
|---|---|---|
| The number of bits are small | ||
| At most | ||
| The number of bits are large |
Output Specification
Output the number of bits that need to be flipped in order for the vault to open.
Sample Input 1
6
101110
Output for Sample Input 1
2
Explanation of Output for Sample Input 1
By flipping the and
bits, we get
101110
101101, where the new set of bits allow for the gate to be open.
It can be shown that bit flips are the minimum needed.
Sample Input 2
4
1000
Output for Sample Input 2
1
Explanation of Output for Sample Input 2
By flipping the bit, we get
1000
0000, where the new set of bits allow for the gate to be open.
Comments