#K2066. Filtering Items by Criteria

    ID: 24654 Type: Default 1000ms 256MiB

Filtering Items by Criteria

Filtering Items by Criteria

You are given a list of items and a filtering criterion. Your task is to output only those items that satisfy the criterion. There are two modes:

  • Integer Mode: When the type indicator is 1, the items are integers. An item is kept if it is strictly greater than a specified threshold. Formally, an integer item x is kept if \( x > k \), where \( k \) is the threshold.
  • String Mode: When the type indicator is 2, the items are strings. An item is kept if it contains a given substring (case-sensitive).

The filtered items should be printed in their original order, separated by a single space. If no items satisfy the criterion, output an empty line.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains an integer that indicates the type of items: 1 for integers and 2 for strings.
  2. The second line contains the filtering criterion. For integer mode, this is an integer threshold \( k \); for string mode, this is a substring.
  3. The third line contains an integer \( n \) representing the number of items.
  4. The fourth line contains \( n \) items separated by spaces. In integer mode, these will be valid integers. In string mode, these will be non-empty strings.

outputFormat

Output a single line to standard output (stdout) containing the filtered items in their original order, separated by a single space. If no items satisfy the condition, output an empty line.

## sample
1
3
5
1 2 3 4 5
4 5