#C3401. Track Queries Under Unique Constraint

    ID: 46825 Type: Default 1000ms 256MiB

Track Queries Under Unique Constraint

Track Queries Under Unique Constraint

In this problem, you are given an integer (L) representing the maximum number of unique queries allowed in a session, and a sequence of queries, each represented by an integer. The task is to determine for each query whether it can be allowed or not based on the following rules:

  1. A query is allowed (output (True)) if it has appeared before in the session.
  2. If a query is encountered for the first time and the number of unique queries encountered so far is less than (L), then it is allowed (output (True)) and counted as a unique query.
  3. If a query appears for the first time and adding it would exceed the limit (L), then it should be restricted (output (False)).

You need to process the input from (stdin) and output the results to (stdout) as space-separated Boolean values (i.e., (True) or (False)).

The problem tests your ability to implement simulation logic and manage the state of encountered queries efficiently.

inputFormat

The input consists of two lines. The first line contains a single integer (L) which is the maximum number of unique queries allowed. The second line contains a sequence of integers separated by spaces representing the queries. If there are no queries, the second line will be empty.

outputFormat

Output a single line containing space-separated Boolean values ((True) or (False)). Each Boolean corresponds to a query in the order they appear, indicating whether that query is allowed or not.## sample

3
1 2 1 3 2
True True True True True