Given the number of arrays (e.g., 4) and number of items (e.g., 5) in the arrays ( note that the number of items are the same for all arrays), find out how many pairs have the same order across all the arrays.
Sample Input: input.txt
4 5
4 1 2 3 5
4 1 3 5 2
4 2 1 3 5
3 4 1 2 5
Sample Output : output.txt
5
For the above sample data, number of pairs matching requirements are 5: [4, 1], [4, 2], [4, 5], [1, 5], [3, 5]
USACO 编程竞赛概要: 铜级题 #1
给定数组数量(例如:4)和数组内数值长度(例如:5),找出在所有数组里面顺序都保持一致的组合数。
输入样例:input.txt
4 5
4 1 2 3 5
4 1 3 5 2
4 2 1 3 5
3 4 1 2 5
输出样例:output.txt
5
譬如上面符合要求的组合数为 5:[4, 1], [4, 2], [4, 5], [1, 5], [3, 5]。
Python Solution: