[Solution] Meta-set Codeforces Solution
You like the card board game "Set". Each card contains features, each of which is equal to a value from the set . The deck contains all possible variants of cards, that is, there are different cards in total.
A feature for three cards is called good if it is the same for these cards or pairwise distinct. Three cards are called a set if all features are good for them.
For example, the cards , , and form a set, but the cards , , and do not, as, for example, the last feature is not good.
A group of five cards is called a meta-set, if there is strictly more than one set among them. How many meta-sets there are among given distinct cards?
The first line of the input contains two integers and (, ) — the number of cards on a table and the number of card features. The description of the cards follows in the next lines.
Each line describing a card contains integers () — card features. It is guaranteed that all cards are distinct.
Output one integer — the number of meta-sets.
Let's draw the cards indicating the first four features. The first feature will indicate the number of objects on a card: , , . The second one is the color: red, green, purple. The third is the shape: oval, diamond, squiggle. The fourth is filling: open, striped, solid.
You can see the first three tests below. For the first two tests, the meta-sets are highlighted.
In the first test, the only meta-set is the five cards . The sets in it are the triples and . Also, a set is the triple which does not belong to any meta-set.
No comments:
Post a Comment