Identifying Sections

Given a sequence of integers, we specify a “section” of it using two
diferent integers, say, 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.

Input

The input indicates, for each case, first a and b, followed by the
length of the sequence n, all three in one line, separated by
whitespace; the subsequent line (or lines) bring n integers constituting
the sequence, and after them, in a separate line, may start a new case.

Output

The sections indentified must be printed on one line each as in the
given examples. Pay attention to the spaces. After each case, print a
line with ten dashes: ----------.

Observation

For each case, the section 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 in the
right order, but there are no intervening numbers. In these cases, your
program must print appropriately nothing inside the corresponding line.

In problem X99803 sections are specified in the same way, although there
are differences: the input is specified differently because each input
brings in only one case, and a different processing is requested.

Problem information

Author: José Luis Balcázar

Generation: 2026-03-25T19:36:31.440Z

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