Art Class
InterviewTime limit0.5sMemory limit512 MB
Given N cells and Q range queries that paint only still-uncolored cells, print the final color of each cell.
- Level
Medium4 of 10
- Topics
- Union-find, Array
- Solved
- No attempts yet
Problem
Minkyu suddenly wanted to draw one day. Nearby, Jeonghwan, who has mastered both art and competitive programming, was solving a problem. Minkyu asked Jeonghwan how to draw well, and Jeonghwan handed him a long rectangular sheet of uncolored paper with cells. He said that a beautiful picture would be finished if Minkyu followed these instructions:
a b x: paint every uncolored cell from the -th to the -th cell with color .
However, Minkyu finds this process too tedious and wants someone else to do it. Let's complete Minkyu's drawing for him.
Input
The first line contains the number of cells and the number of queries , separated by a space (, ). Each of the next lines contains one query (, ).
Output
After all queries are performed, print the color of each cell on one line, separated by spaces. Cells that were never painted are printed as .