Track Mixing
You are producing a song with tones, and you must assign an integer intensity to each tone, forming an array
of length
(1-indexed). Your label gives you
constraints you must satisfy, detailing the musical preferences of your audience.
Each constraint is a tuple , where
is either
atmost or atleast, , and
is an integer.
- If
atmost, then every tone in the segment must satisfyfor all
.
- If
atleast, then every tone in the segment must satisfyfor all
.
If there exists such an array, output any one of them. Otherwise, report that it is impossible. All array elements you output must be in the range (otherwise you would blow out your speakers from the volume).
Input
The first line contains two integers and
representing the amount of tones in the song and the amount of constraints from your label.
Each of the next lines contains a constraint in the form
t l r v, where is either
atmost or atleast, , and
is an integer
.
Output
If a valid array exists, on a single line print integers
satisfying all constraints.
If no valid array exists, print NO.
Example
Input 1
5 3
atleast 1 3 2
atmost 2 5 7
atleast 4 5 0
Output 1
2 2 2 0 0
There are many possible outputs. For instance, here are some more valid arrays:
2 5 5 2 25 5 5 5 5
Input 2
3 3
atleast 1 2 5
atmost 2 3 3
atleast 3 3 4
Output 2
NO
The constraints on positions and
are contradictory, so there are no valid arrays.
Comments