题库练习 Meta-set
← 上一题 下一题 →

A15437 | Meta-set

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You like the card board game "Set". Each card contains $k$ features, each of which is equal to a value from the set $\{0, 1, 2\}$ . The deck contains all possible variants of cards, that is, there are $3^k$ 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 $k$ features are good for them.

For example, the cards $(0, 0, 0)$ , $(0, 2, 1)$ , and $(0, 1, 2)$ form a set, but the cards $(0, 2, 2)$ , $(2, 1, 2)$ , and $(1, 2, 0)$ 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 $n$ distinct cards?

输入格式

The first line of the input contains two integers $n$ and $k$ ( $1 \le n \le 10^3$ , $1 \le k \le 20$ ) — the number of cards on a table and the number of card features. The description of the cards follows in the next $n$ lines.

Each line describing a card contains $k$ integers $c_{i, 1}, c_{i, 2}, \ldots, c_{i, k}$ ( $0 \le c_{i, j} \le 2$ ) — card features. It is guaranteed that all cards are distinct.

输出格式

Output one integer — the number of meta-sets.

输入输出样例

输入 #1
8 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
1 0 0 0
2 2 0 0
输出 #1
1
输入 #2
7 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
0 2 0 0
输出 #2
3
输入 #3
9 2
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
输出 #3
54
输入 #4
20 4
0 2 0 0
0 2 2 2
0 2 2 1
0 2 0 1
1 2 2 0
1 2 1 0
1 2 2 1
1 2 0 1
1 1 2 2
1 1 0 2
1 1 2 1
1 1 1 1
2 1 2 0
2 1 1 2
2 1 2 1
2 1 1 1
0 1 1 2
0 0 1 0
2 2 0 0
2 0 0 2
输出 #4
0
C++ 编辑器
输入
输出