欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1287B.Hyperset
Hyperset
CF1287B · Hyperset
- 难度:1500
- 标签:brute force、data structures、implementation
- 链接:https://codeforces.com/problemset/problem/1287/B
- 时间限制:3 seconds 内存限制:256 megabytes
- 出现位置:Day28-阶段模拟7-S T1-T3综合卷
英文原题面
Statement
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every feature — color, number, shape, and shading — the three cards must display that feature as either all the same, or pairwise different. The picture below shows how sets look.
Polina came up with a new game called "Hyperset". In her game, there are cards with features, each feature has three possible values: "S", "E", or "T". The original "Set" game can be viewed as "Hyperset" with . Similarly to the original game, three cards form a set, if all features are the same for all cards or are pairwise different. The goal of the game is to compute the number of ways to choose three cards that form a set. Unfortunately, winter holidays have come to an end, and it's time for Polina to go to school. Help Polina find the number of sets among the cards lying on the table.
Input
The first line of each test contains two integers and (, ) — number of cards and number of features. Each of the following lines contains a card description: a string consisting of letters "S", "E", "T". The -th character of this string decribes the -th feature of that card. All cards are distinct.
Output
Output a single integer — the number of ways to choose three cards that form a set.
样例
样例 1
输入:
3 3
SET
ETS
TSE
输出:
1
样例 2
输入:
3 4
SETE
ETSE
TSES
输出:
0
样例 3
输入:
5 4
SETT
TEST
EEET
ESTE
STES
输出:
2
样例解释(英文原文)
In the third example test, these two triples of cards are sets:
- "SETT", "TEST", "EEET"
- "TEST", "ESTE", "STES"
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |