Reconstructing Tape Art
면접 대비시간 제한2초메모리 제한1024 MB
길이 n의 각 위치에 보이는 최종 색이 주어질 때, 색마다 테이프 한 조각씩만 써서 그림을 재현하는 적층 순서를 출력하거나 불가능을 판정한다.
문제
Raelynn is trying to learn the newest craze in modern art: Tape Art! This wonderful new type of art is created by taking a wooden plank and pieces of tape of different colors. Each artwork is constructed by taking multiple pieces of tape and placing them on the plank. For each color that appears in the artwork, only a single piece of tape is used. Tapes can be placed on top of each other in which case the tape placed last obscures already placed pieces of tape with which it overlaps.
Raelynn has decided the best way to learn is by copying Sheila, the world famed tape artist. Unfortunately those pieces of art are under lock and key and Raelynn can see only pictures of these marvels. Since Raelynn is having trouble reverse engineering the artwork from the picture, she has hired you to create a set of instructions with which she can copy the art.
Since Raelynn is spoiled by the ease of IKEA catalogs she requires instructions to be given in the following format: there should only be one instruction per color of tape and instructions should be given in the order they should be executed.
입력
The input consists of a single test case. The first line of this test case contains one integer (), where is the length of the tape art in inches. The next line contains integers () representing the color of one inch of the plank. Planks are divided into -inch sections numbered through .
출력
Output any set of instructions that, when executed, will result in the tape art given by the input. The set of instructions should start with the number of instructions that follow. Each instruction must consist of three numbers: where represents the inclusive range on which the tape should be placed and represents the color of the tape piece.
Output the string "IMPOSSIBLE" if the piece of tape art cannot be reconstructed using only one piece of each color (Sheila must have broken the rules to make it or this piece is a forgery).