#C14115. Filter and Deduplicate Car Models
Filter and Deduplicate Car Models
Filter and Deduplicate Car Models
Problem Description:
You are given an integer (filter_year) and a list of cars, where each car is described by its make, model, and production year. Your task is to filter out the cars whose production year is not strictly greater than (filter_year) and deduplicate the remaining ones based on their model. Only the first occurrence of each unique car model (satisfying (year > filter_year)) should be output, in the order they appear in the list.
Input Format:
The first line contains the integer (filter_year).
The second line contains an integer (n), the number of cars.
Each of the next (n) lines contains three space-separated entries: the car's make (a string), model (a string), and year (an integer).
Output Format:
Print a single line with the unique car models (space-separated), in the order they first appear, that have a production year strictly greater than (filter_year). If no such car exists, output an empty line.
inputFormat
Standard input (stdin) is used for input. The input has the following structure:
Line 1: An integer representing (filter_year).
Line 2: An integer (n), denoting the number of cars.
Next (n) lines: Each line contains three space-separated values: a string for the make, a string for the model, and an integer for the year.
outputFormat
Print a single line to standard output (stdout) containing the unique car models that satisfy the condition (i.e., production year > (filter_year)), separated by a single space. If there are no models that meet the criteria, print an empty line.## sample
2020
2
Toyota Camry 2021
Honda Accord 2022
Camry Accord
</p>