Programming contests

ECN programozó csapatverseny, 2019. május 11.

May 11, 2019, 10:15 AM – May 11, 2019, 3:15 PM

FIPS Groups

In the research department of an automotive vehicle manufacturer company, a very important task is the testing of compatibility of existing and new electric and electronic components (sensors, controllers, computers, etc.). In order to avoid the manufacturing of a prototype car for every configuration, there is the possibility to examine certain configurations on the existing test cars. These test cars are stored in different locations across Germany, and within one location, they are grouped. These groups are called FIPS Groups. A FIPS Group can contain one or several vehicles.

With the help of a software, a user has the possibility to select from the FIPS Groups any desired group and order them according to their importance. For the ease of understanding, the FIPS Groups are represented by capital letters in this description (but not in the input and output!). For example, if a user selects 5 FIPS Groups [A, B, C, D, E], he will have the possibility to order the groups with the following (sort) operations:

  • ONE_LEVEL_UP
  • ONE_LEVEL_DOWN
  • TO_HIGHEST_LEVEL
  • TO_LOWEST_LEVEL

An example explained:

  • Input: [A, B, C, D, E], the user would like the [B, D] groups to increase their level of importance with one (ONE_LEVEL_UP) -> Output: [B, A, D, C, E], meaning that group B has taken the place of group A and group D has taken the position of group C.
  • Input: [B, A, D, C, E] -> Operation: TO_HIGHEST_LEVEL on [B, A, D] -> Output: [B, A, D, C, E]
  • Input: [B, A, D, C, E] -> Operation: TO_LOWEST_LEVEL on [B, A, D, E] -> Output: [C, B, A, D, E]
  • Input: [C, B, A, D, E] -> Operation: ONE_LEVEL_DOWN on [C, A, E] -> Output: [B, C, D, A, E]
  • Input: [B, C, D, A, E] -> Operation: TO_LOWEST_LEVEL on [C, A, E] -> Output: [B, D, C, A, E]
  • Input: [B, D, C, A, E] -> Operation: TO_HIGHEST_LEVEL on [C, A, E] -> Output: [C, A, E, B, D]
  • Input: [C, A, E, B, D] -> Operation: ONE_LEVEL_UP on [B] -> Output: [C, A, B, E, D]

Input Specification

The input begins with the comma-separated list of FIPS Groups in their initial succession. Each FIPS Group is represented as a string of at most 10 characters. This is followed by a minus sign ('-') and the sort operations. A sort operation (e.g., ONE_LEVEL_UP:B,D;) contains the sort command (ONE_LEVEL_UP in the example), then a colon character (':'), then a list of FIPS Groups on which the command should be performed ([B, D] in the example), and a semicolon character (';'). The FIPS Groups are separated from each other by comma characters (','). There will be at most 1 000 000 FIPS Groups and 1 000 000 sort operations.

Output Specification

Print in one line the order of groups after the required operations are performed as a comma-separated list of strings.

Sample Input

  1. A,B,C,D,E-ONE_LEVEL_UP:B,D;TO_LOWEST_LEVEL:B,A,D,E;
download as text file

Output for Sample Input

  1. C,B,A,D,E
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024