Identifying Sections

Given a sequence of integers, we specify a “section” of it using two
integers @a@ and @b@. The section is the part of the sequence that
starts immediately after the first occurrence of @a@, if any, and ends
immediately before the first occurrence of @b@ after the first
occurrence of @a@, if any.

For instance, given the sequence 6, 5, 1, 2, 1, 4, 3, 5, 4, 3, 5, 1 with
@a = 1@ and @b = 5@ we specify the subsequence 2, 1, 4, 3 that starts
just after the first 1 and ends just before the first 5 after that 1.

Write a program that reads in a number of cases, each case specifying a
section, and prints out the sections specified. The input indicates, for
each case, first @a@ and @b@, followed by the length of the sequence
@n@, all three in one line, separated with whitespace; the subsequent
line (or lines) bring @n@ integers constituting the sequence, and after
them, in a separate line, may start a new case.

For each case, the sequence identified can be empty; there are three
such cases: (1) when @a@ does not appear in the sequence, (2) when it
appears but @b@ does not appear subsequently, and (3) when both appear
but there are no intervening numbers. In these cases, your program must
print appropriately nothing.

The sections indentified must be printed on one line each. After each
case, print a line with ten dashes: ———-.

Problem information

Author: José Luis Balcázar

Generation: 2026-01-25T17:35:33.598Z

© Jutge.org, 2006–2026.
https://jutge.org
