luogu#P7866. 「EVOI-RD1」小昕昕
「EVOI-RD1」小昕昕
Background
A standard deck of playing cards has cards. After removing the two Jokers, there are cards. In the same deck, each card can appear at most once.
A deck has four suits: spades (), hearts (), clubs (), and diamonds (). Each suit has ranks, from to .
In this problem, the four suits are written as .
We define that any card is written as suit + rank, and we use to represent , for example .
Problem Description
Xinxin has two decks without Jokers. She will take out cards from these cards.
Xinxin created a combination called "Xiao Xinxin". It is defined as follows: take any cards. If these cards have the same rank, and the suits contain exactly two different suits, then this is called one "Xiao Xinxin" set. For example, is one "Xiao Xinxin" set.
After three cards form a "Xiao Xinxin", Xinxin will remove them from the pile, and they cannot be used again.
Now Xinxin wants you to help her count: what is the maximum number of "Xiao Xinxin" sets that can be formed from these cards.
Input Format
The first line contains a positive integer .
Lines to each contain one playing card.
Output Format
Output the maximum number of "Xiao Xinxin" sets that can be formed from these cards.
3
S3
H3
S3
1
7
ST
ST
HT
HT
CT
CT
DT
2
6
DA
HA
D4
C5
DA
D4
1
Hint
This problem uses bundled testdata.
- : .
- : .
- : .
- : .
- : no special constraints.
For of the data, , and it is guaranteed that all input cards exist in two decks without Jokers.
Translated by ChatGPT 5