#P3492. [POI2009] TAB-Arrays
[POI2009] TAB-Arrays
题目描述
Let us consider an array of size filled with pairwise different integers.
The following operations are allowed on the array:
interchanging two rows, interchanging two columns.
We call two arrays alike if one of them can be obtained from the other by a sequence of aforementioned operations.
Write a programme that for a given set of pairs of arrays tells which pairs are alike.
输入格式
The first line of the standard input contains one integer () denoting the number of pairs of arrays.
Then descriptions of successive array pairs follow in subsequent lines.
Each description starts with a line holding two integers and (), separated by a single space, that denote the common number of rows and columns of the arrays, respectively.
The lines that follow describe the first array.
In the -th of them there are integers (), separated by single spaces…
输出格式
Your programme should print out lines to the standard output.
The -th of these should hold one word: "TAK" (yes in Polish) if the arrays of the -th pair are alike, or "NIE" (no in Polish) otherwise.
题目大意
多组数据(不超过 组),每组数据给出两个 行 列的矩阵 (),保证每个矩阵内元素互不相同且权值均在 之间,你需要报告能否把其中一个矩阵通过若干次交换两行或者交换两列的操作变成另外一个矩阵。
单个读入数据可达 130MB 左右,请优化读入效率。
2
4 3
1 2 3
4 5 6
7 8 9
10 11 12
11 10 12
8 7 9
5 4 6
2 1 3
2 2
1 2
3 4
5 6
7 8
TAK
NIE