|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||256 MB||0||0||0||0.000%|
You must help would-be painter Vincent van Dinsky mix colors for his paintings. His master gave him a book of color mixing rules plus a color palette, and told him to produce the set of colors that are required for a painting, by experimenting until he finds the minimum number of color mixes that is required for each color in the painting.
For an input that contains, in order
you should produce an output that contains one line for each painting (i.e. each data set); on that line, for each color in the painting, the minimum number of color mixes that will produce the desired color (starting from the colors available initially on the palette; the result is ‘-1’ if it’s impossible to obtain the desired color)
You can assume that the input is correct, there are less than 50000 color mixing rules in the rule book and less than 1000 colors
cyan yellow green cyan magenta blue yellow magenta red red green black cyan yellow magenta pink cyan black pink red brown cyan yellow red blue black
0 3 0 1 -1 -1 2