欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1735D.Meta-set
Meta-set
CF1735D · Meta-set
- 难度:1700
- 标签:brute force、combinatorics、data structures、hashing、math
- 链接:https://codeforces.com/problemset/problem/1735/D
- 时间限制:4 seconds 内存限制:256 megabytes
- 出现位置:Day21-字符串综合-hash-二分-构造/选做
英文原题面
Statement
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?
Input
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
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
样例 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
输出:
3
样例 3
输入:
9 2
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
输出:
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
输出:
0
样例解释(英文原文)
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.
In the second test, the following groups of five cards are meta-sets: , , .
In there third test, there are meta-sets.
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |