eolymp
bolt
Try our new interface for solving problems
Problems

Inverse Range Minimum Query

Inverse Range Minimum Query

Inverse problems represent a quickly growing area in computer science. Unlike traditional problems, where given some data \textbf{D}, the task is to solve some optimization or calculation problem \textbf{P}, in the inverse problem you are given a problem \textbf{P} and the result \textbf{R} of the optimization/calculation. You have to restore the original data \textbf{D}. In this problem you are asked to solve inverse range minimum query problem. Consider an array \textbf{a\[1..n\]}. The answer to a range minimum query \textbf{Q(i, j)} is the minimal value among \textbf{a\[i\]}, ..., \textbf{a\[j\]}. You are given \textbf{n} and a series of range minimum queries with answers. Restore the original array \textbf{a}. \InputFile The first line of the input file contains \textbf{n} - the size of the array, and \textbf{m} - the number of queries (\textbf{1} ≤ \textbf{n}, \textbf{m} ≤ \textbf{100000}). The following \textbf{m} lines contain three integer numbers each: numbers \textbf{i}, \textbf{j} and \textbf{q} mean that \textbf{Q(i, j) = q} (\textbf{1} ≤ \textbf{i} ≤ \textbf{j} ≤ \textbf{n},\textbf{-2^31} ≤ \textbf{q} ≤ \textbf{2^31-1}). \OutputFile If data in the input file is inconsistent, i.e. no such array \textbf{a} exists, output "\textbf{inconsistent}" at the first line of the output file. In the other case output "\textbf{consistent}" at the first line of the output file. The second line must contain the array. The elements of the array must be integers between \textbf{-2^31} and \textbf{2^31-1}. If there are several solutions, output any one.
Time limit 3 seconds
Memory limit 256 MiB
Input example #1
3 2
1 2 1
2 3 2
Output example #1
consistent
1 2 2
Author Andrew Stankevich
Source Andrew Stankevich Contest 32, Petrozavodsk Summer Training Camp, Wednesday, September 3, 2008