#P14745. [ICPC 2021 Seoul R] Trio
[ICPC 2021 Seoul R] Trio
题目描述
Let be any set of natural numbers whose decimal representations consist of exactly four digits without in any decimal place.
A trio is a set of three numbers chosen from such that the following conditions are fulfilled simultaneously:
- The ones decimals of three numbers are either all equal or all distinct.
- The tens decimals of three numbers are either all equal or all distinct.
- The hundreds decimals of three numbers are either all equal or all distinct.
- The thousands decimals of three numbers are either all equal or all distinct.
For examples, is a trio if the three numbers are members of because the ones decimals of the three numbers are all distinct, their tens decimals are all distinct, their hundreds decimals are all distinct, and their thousands decimals are all equal. The set , however, is not a trio, even if contains those three numbers.
Given a set as input, write a program that computes and prints out the number of different trios.
输入格式
Your program is to read from standard input. The input starts with a line consisting of a single integer () that represents the number of members in . Each of the following lines consists of a positive integer in decimal form that consists of exactly four digits without in any decimal place. These numbers are supposed to be all distinct and the members of the input set .
输出格式
Your program is to write to standard output. Print exactly one line. The line should consist of a single integer that represents the number of different trios for the input set .
6
1234
1235
1244
1233
7133
8133
1
9
1234
5678
9123
4567
8912
3456
7891
2345
6789
84