#P11001. [蓝桥杯 2024 省 Python B] 连连看
[蓝桥杯 2024 省 Python B] 连连看
Problem Description
Xiao Lan is playing a new link-up game with friends. In an rectangular grid, each cell contains an integer. The integer in row and column is . The player needs to find a pair of cells and such that the integers in these two cells and are equal, and their positions satisfy . Please determine how many pairs of cells in this rectangular grid satisfy the condition.
Input Format
The first line contains two positive integers and , separated by a single space.
Next are lines. The -th line contains positive integers , separated by single spaces.
Output Format
Output one line containing one integer representing the answer.
3 2
1 2
2 3
3 2
6
Hint
There are the following 6 pairs of cells: , , , , , .
Constraints
For of the test cases, .
For all test cases, , .
Translated by ChatGPT 5