It's that month of the year! __jk__, a proud fan of rainbows and pride, decides to celebrate this festivity with his astounding painting skills. That's why he has set his sights on painting his very own Rainbow Road!
The road consists of $N$ segments, each of which has a color denoted as $A_i$, where each segment is initially painted white ($A_i=0$). With his $K$ different paint buckets, where bucket $i$ ($1\le i\le K$) has color $i$, he decides to paint $K$ consecutive strips of road in a row.
__jk__ starts at segment 1, for each color $i$, he starts from his previous position $p$ and paints all segments from $p$ to $Q_i$ to color $i$, ($A_j=i$ for $\min(p, Q_i) \le j \le \max(p, Q_i)$). After each painting operation, he moves to position $Q_i$ and performs the next operation. Note that previously painted cells may be painted over by future operations.
__jk__ plans his painting routine but struggles to envision how his rainbow masterpiece will turn out. Determine the final configuration of the rainbow road to help __jk__ achieve his prideful journey!
Input
The first line of input contains two integers $N$ and $K$.
The next line of input contains $K$ integers, denoting $Q_i$.
Output
Output $N$ integers $A_i$, denoting the final color of each segment of the rainbow road.
Constraints
For all test cases, $1\le N,K\le 2\times10^5$ and $Q_i\le N$.
Subtask 1 (15 points): $N=3$.
Subtask 2 (15 points): $Q_i\le Q_j$ for all $i\lt j$.
Subtask 3 (35 points): $N, K\le 3000$.
Subtask 4 (35 points): No additional constraints.
Sample Test Cases
Input | Output | |
---|---|---|
5 4 4 2 2 3 |
1 4 4 2 0 |
Scoring: Per Subtask
Authored by s19x17 and tosivanmak
Appeared in Joint-School Pre-HKOI Mini Competition 2 and Joint-School Pre-HKOI Mini Competition 2 [Early Session]