#K51292. Arrange the Paintings
Arrange the Paintings
Arrange the Paintings
You are given 10 paintings and an integer f representing the number of frames. Each painting is described by four fields: name, artist, year, and type. There is a relation score defined between any two paintings:
- 3 points if the paintings are by the same artist.
- 2 points if they were painted in the same year.
- 1 point if they are of the same type.
An arrangement of paintings is valid if, for the first f paintings in the order, the relation score between the i-th and (i+1)-th painting is at least i+1 (with i starting at 0). For instance, if f = 3, then the score between painting 1 and painting 2 must be at least 1, and the score between painting 2 and painting 3 must be at least 2.
Your task is to determine whether there exists an arrangement of the 10 paintings that satisfies this condition. If such an arrangement exists, output yes
; otherwise, output no
.
inputFormat
The input is given via standard input. The first line contains an integer f (the number of frames). The following 10 lines each contain four space-separated strings representing a painting's name, artist, year, and type.
outputFormat
Output a single line to standard output containing either yes
if there exists a valid arrangement or no
otherwise.
0
MonaLisa LeonardoDaVinci 1503 Portrait
StarryNight VanGogh 1889 Landscape
GirlWithAPearlEarring Vermeer 1665 Portrait
ThePersistenceOfMemory Dali 1931 Surrealism
TheScream Munch 1893 Expressionism
Guernica Picasso 1937 Mural
TheNightWatch Rembrandt 1642 Portrait
TheKiss Klimt 1908 Symbolism
ImpressionSunrise Monet 1872 Impressionism
AmericanGothic Wood 1930 Portrait
no