0% found this document useful (0 votes)
55 views6 pages

ZIO 2025 Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views6 pages

ZIO 2025 Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ZIO 2025

December 14, 2024

1 Problem 1
There are N displays placed in a row. Each display can show a single digit from
0 to 9. Thus, together, N displays can show any non-negative number that is
less than 10N . Each display has 7 lights. The figure below shows how each digit
is represented and how many lights there are per digit.

Digit 0 1 2 3 4 5 6 7 8 9
No. of Lights 6 2 5 5 4 5 6 3 7 6

Figure 1: Representation of digits on a display, and number of lights required


to display each digit

An operation consists of turning on or turning off a single light. You can


convert any digit to any another one using a sequence of operations. For exam-
ple, a 2 can be converted to a 6 with 3 operations (two lights being turned on
and one being turned off) as shown in the next figure.

1
Figure 2: Operations required to make 6 from 2

Given the number of displays N and a number X shown on them, determine


the minimum number of operations you will have to perform to obtain a number
greater than X. Note that N is constant for a given test case, and if a number
is smaller than 10N −1 , it will be padded with leading 0s.

(a) N = 2, X = 77
(b) N = 10, X = 0000942274

(c) N = 15, X = 127932412749752

2
2 Problem 2
You need to select a passcode consisting of N numeric digits. Each digit can
be between 0 and 9, both inclusive, and your passcode may have leading 0s.
Therefore, there are 10N possible passcodes. Let Di denote the ith digit of your
passcode.
To make your passcode difficult to guess, you make sure that:

• No two adjacent digits are equal. That is, for all 1 ≤ i < N , Di ̸= Di+1 .
• For any three consecutive digits, they are not all increasing. That is, there
must be no 1 ≤ i ≤ N − 2 such that Di < Di+1 and Di+1 < Di+2 .
• For any three consecutive digits, they are not all decreasing. That is, there
must be no 1 ≤ i ≤ N − 2 such that Di > Di+1 and Di+1 > Di+2 .

For a given length N , what is the number of passcodes you can create of
that length? Find this value modulo 997.

(a) N = 3
(b) N = 6
(c) N = 11

3
3 Problem 3
There are N towers in a row. Tower i contains Hi blocks.
You want to make the row of towers special. A row of towers is special
if there exist no three integers 1 ≤ i < j < k ≤ N such that Hi > Hj and
Hj < Hk .
To do this, you can perform some operations. In each operation, you can
pick some index i such that 1 ≤ i ≤ N such that Hi ≥ 1 and then decrease Hi
by one, that is set Hi = Hi − 1.
What is the minimum number of operations you need to perform? If it is
impossible to make the row of towers special using any number of
operations, you should answer −1 (minus 1).

(a) N = 5, H = [3, 1, 3, 4, 1]
(b) N = 12, H = [12, 9, 10, 7, 11, 9, 4, 6, 15, 5, 9, 12]

(c) N = 25, H = [22, 26, 7, 25, 26, 14, 22, 26, 8, 20, 2, 22, 24, 6, 6, 10, 11, 22, 20, 22, 3, 10,
28, 25, 15]

4
4 Problem 4
A distant country has N cities numbered {1, 2, . . . , N }. These cities are con-
nected by N − 1 roads such that it is possible to travel between any pair of cities
using these roads.
For some non-negative integer K, you want to create an array of K pairs
of cities satisfying the following constraints. Let the ith pair in the array be
(Ai , Bi ).

• 1 ≤ Ai < Bi ≤ N for all 1 ≤ i ≤ K


• For all 1 ≤ i < K, either:
– Ai < Ai+1 , or
– Ai = Ai+1 and Bi < Bi+1 .
• For each 1 ≤ i ≤ K, consider any road in the unique simple path between
Ai and Bi . For each of the N − 1 roads, this road must occur exactly
once over all K simple paths.

How many different arrays of pairs can you create? Two arrays of pairs are
considered different if there are a different number of pairs in the array, or if
there is some index i such that the ith pair in the first array is not equal to
the ith pair in the second array. Two pairs are considered equal if their first
elements are equal to each other and their second elements are equal to each
other. Find the number of different arrays of pairs modulo 997.
Consider for example N = 4 with the following 3 roads:
• A road connecting city 1 and city 2
• A road connecting city 1 and city 3
• A road connecting city 3 and city 4
Then, the possible arrays are:
• [(2, 4)] (here, K = 1)
• [(1, 2), (1, 4)] (here, K = 2)
• [(2, 3), (3, 4)] (here, K = 2)
• [(1, 2), (1, 3), (3, 4)] (here, K = 3)
Therefore, there are four possible arrays of pairs, and the answer for this
testcase would be 4.
The input consists of the integer N , the number of cities, followed by an
array of integers P of length N , such that P [1] = −1 and 1 ≤ P [i] < i for all
2 ≤ i ≤ N . For each i such that 2 ≤ i ≤ N , there is a road connecting cities
P [i] and i.
Please remember to provide your answer modulo 997.

5
(a) N = 30, P = [−1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29]
(b) N = 15, P = [−1, 1, 1, 2, 3, 1, 2, 2, 3, 3, 5, 5, 4, 11, 12]
(c) N = 30, P = [−1, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 3, 3, 1, 4, 4, 5, 6, 5, 6, 6, 3, 3, 10]

You might also like