#K10096. Data Timestamp Consistency Checker
Data Timestamp Consistency Checker
Data Timestamp Consistency Checker
You are given a set of data items along with several lists of node updates. Each node update is given as a pair (node id, timestamp). Your task is to verify if, in every update list, the timestamps are in non-decreasing order. In other words, for a given list of timestamps, each timestamp should be greater than or equal to the previous one.
If all update lists follow this order, print Consistent
. Otherwise, print Inconsistent
.
Note: Although the problem statement mentions 'strictly increasing', duplicate timestamps (i.e. non-decreasing order) are considered valid.
inputFormat
The input is given via standard input (stdin) with the following format:
n <data_item_1> <data_item_2> ... <data_item_n> m p1 <node_1> <timestamp_1> ... <node_p1> <timestamp_p1> p2 <node_1> <timestamp_1> ... <node_p2> <timestamp_p2> ... pm <node_1> <timestamp_1> ... <node_pm> <timestamp_pm>
Where:
n
is the number of data items (this value is provided for completeness but is not used in the verification process).- The next line contains
n
integers representing the data item identifiers. m
is the number of node update lists.- Each update list starts with an integer
p
indicating the number of updates in that list followed byp
pairs. Each pair consists of a node id and its corresponding timestamp.
outputFormat
Output a single line to standard output (stdout) containing either Consistent
if all update lists have timestamps in non-decreasing order, or Inconsistent
if at least one list does not.
2
4 5
2
3 1 2000 2 3000 3 4000
2 2 1000 3 2000
Consistent