Имя: Пароль: Зарегистрироваться Восстановить пароль
28/01/2023 14:37:55

# Рабочее место участника

## Задачи

240. Set me

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)

The game of Set is played with a deck of eighty-one cards, each having the following four characteristics:
• Symbol: diamonds, ovals, or squiggles
• Count: 1, 2, or 3 symbols
• Color: red, green, or purple
• Shading: outlined, filled, or striped
The cards are shuffled and a tableau of twelve cards is laid out. Players then attempt to be the first to identify "sets" which exist in the tableau. Sets are removed as they are identified and new cards are dealt in their place. Play continues in this manner until all cards have been used. The winner is the player with the most sets.
A set is a collection of three cards in which each characteristic is either the same on all three cards or different on all three cards. For example, the cards shown below form a set.
To see how the cards above form a set, take each characteristic in turn. First, each card has different symbol: the first card has squiggles, the second diamonds, and the third ovals. Second, each card has the same count of symbols, three. Third each card has a different color, and finally, each card has a different shading. Thus, each characteristic is either the same on all three cards or different on all three cards, satisfying the requirement for a set.
Consider the following example of three cards which do not form a set.
Again, take each characteristic in turn. Each card has a different symbol, each card has a different count of symbols, and each card is the same color. So far this satisfies the requirements for a set. When the shading characteristic is considered, however, two cards are filled and one card is striped. Thus, the shading on all three cards is neither all the same nor all different, and so these cards do not form a set.
The input for this program consists of tableau of cards listed one card per line. Each card in a tableau is specified by four consecutive characters on the input line. The first identifies the type of symbol on the card, and will be either a "D", "O", or "S", for Diamond, Oval, or Squiggle, respectively. The second character will be the digit 1, 2, or 3, identifying the number of symbols on the card. The third identifes the color and will be an "R", "G", or "P" for Red, Green, or Purple, respectively. The final character identifes the shading and will be an "O", "F", or "S" for Outlined, Filled, or Striped. All characters will be in uppercase.
The output for the program is a list of all possible sets which could be formed using cards in the tableau. The order in which the sets are output must match with the order of cards in the input. Your output should adhere to the format illustrated by the example below. In the event that no sets exist in a tableau, report "*** None Found ***".

Sample Input #1

S1PS
D3PO
S2GF
O2GS
O2GF
O3PO
S2RF
S3GS
D2GS
O1GS
O1GF
S2PS

Sample Output #1

D3PO S2RF O1GS
S3GS D2GS O1GS

Sample Input #2

O2GF
O1PF
D2PO
D3RO
S2PO
O1GF
O1GS
D2GO
S3PF
S2GF
D2GS
S1RS

Sample Output #2

*** None Found ***
Source: Greater New York Regional, 2002