• 应用
• 登录
• 注册

P3492 [POI2009]TAB-Arrays

• 41通过
• 66提交
• 题目提供者 洛谷OnlineJudge
• 评测方式 云端评测
• 标签 模拟 POI 2009 高性能
• 难度 提高+/省选-
• 时空限制 1000ms / 128MB
• 提示：收藏到任务计划后，可在首页查看。

题目描述

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.

给出两个n*m的矩阵，保证每个矩阵内元素互不相同且权值均在[-10^6,10^6]之间，请能否把其中一个矩阵通过若干次交换两行或者交换两列的操作变成另外一个矩阵

输入输出格式

输入格式：

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.

输入输出样例

输入样例#1： 复制
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

输出样例#1： 复制
TAK
NIE

提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。