Hey. With you Olympiad hobby. Here we choose an olympiad programming problem, analyze it, work out possible solutions and implement our plans, then send it to the court. We will need knowledge of one of the programming languages: c, c ++, java, pascal, patience, dexterity and basic knowledge of the English language in order to understand the condition of the problem, although the last point is optional, because I will freely retell the condition in Russian.A brief translation of the conditions of the problem (free translation):
')
Kerbside garbage collection technology has arrived in New Zealand. Five recycle bins of different colors: red (red), orange (orange), yellow (yellow), green (green) and blue (blue), which define 5 types of waste: plastic waste (Plastic), glass (Glass), aluminum (Aluminum), steel (Steel) and paper (Newspaper). Unfortunately, there was no coordination between the cities, so each city assigned an arbitrary type of waste to the colored baskets. Now that the government has been able to solve all the unimportant tasks (such as reorganizing health care, social services, and education), it has decided to tackle other problems. The Minister of Environmental Protection submitted to the Parliament a document on the regulation of the conformity of waste types with colored baskets, but for this it needs to choose its own distribution of waste by color. A supporter of democracy, he explored all the cities that use Kerbside. Using the data he wants, he wants to choose a city whose scheme of matching waste types to colored baskets (being distributed throughout the country) will cause the least amount of changes. The size of the city does not matter, according to democracy: 1 city - 1 vote.
It is necessary to write a program that counts data on the distribution of waste types by color in each city, and will determine which scheme should be chosen. Keep in mind that there will always be a clear leader.
Input : a series of blocks. Each block will contain several lines expressing the distribution of waste types by color, 1 line per city. There can be up to 100 cities. Each block ends in a line, starting with an āeā. The end of the input data is marked with a string of one "#" character.
Output : For each incoming block, you must output the ordinal number of the city, whose distribution scheme should be chosen as a reference.:
r/P,o/G,y/S,g/A,b/N
r/G,o/P,y/S,g/A,b/N
r/P,y/S,o/G,g/N,b/A
r/P,o/S,y/A,g/G,b/N
e
r/G,o/P,y/S,g/A,b/N
r/P,y/S,o/G,g/N,b/A
r/P,o/S,y/A,g/G,b/N
r/P,o/G,y/S,g/A,b/N
ecclesiastical
#
:
1
4
r / P, o / G, y / S, g / A, b / N
r / P, o / S, y / A, g / N, b / G
r / S, o / G, y / P, g / N, b / G
r / A, o / S, y / P, g / N, b / G
r / G, o / S, y / P, g / A, b / N
Reference scheme in accordance with clause 2:
r / Po / S, y / P, g / N, b / G
| Scheme | The number of differences from other cities |
|---|---|
| r / P, o / G, y / S, g / A, b / N r / G, o / P, y / S, g / A, b / N r / P, y / S, o / G, g / N, b / A r / P, o / S, y / A, g / G, b / N | 1 + 2 + 1 + 2 + 1 = 7 <- the best option 3 + 3 + 1 + 2 + 1 = 10 1 + 2 + 1 + 3 + 3 = 10 1 + 3 + 3 + 3 + 1 = 11 |
| r / P, o / G, y / S, g / A, b / N r / P, o / S, y / A, g / N, b / G r / S, o / G, y / P, g / N, b / G r / A, o / S, y / P, g / N, b / G r / G, o / S, y / P, g / A, b / N | 3 + 3 + 4 + 3 + 3 = 16 3 + 2 + 4 + 2 + 2 = 13 4 + 3 + 2 + 2 + 2 = 13 4 + 2 + 2 + 2 + 2 = 12 <- the best option 4 + 2 + 2 + 3 + 3 = 14 |
Source: https://habr.com/ru/post/108689/
All Articles