22185_UniversityRankings

2022-5-16 18:21| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506182919200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22185

Title

University Rankings

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22185

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    At present, the university rankings are very popular. They help senior high school students to choose universities for further study. For example, you can find the CHINESE UNIVERSITY RANKINGS at http://www.netbig.com/.

    Figure 1

    As we know, a university usually has many different departments, such as department of Computer Science (CS), department of Electronic Engineering (EE), and School of Foreign Languages (FLS). Some of them are quite good when comparing to the other universities, but others are not. So, most of the university rankings are composed of several ranking lists, each list for one department.

    But here comes a problem that sometimes it's hard to determine which university is better, when comparing two universities with each other. Fortunately, Doctor Bob has advanced a new concept named "absolutely better", with which the problem above can be partially solved.

    Now, here is an example to explain the concept "absolutely better":

    Assume that there are three universities (X, Y, Z) and every university has three departments: CS, EE and FLS. And the rankings of different departments are as followed:

    The ranking of CS: X > Y > Z ( X > Y means X have a better CS department than Y )

    The ranking of EE: X > Z > Y

    The ranking of FLS: Z > X > Y

    Obviously, each department of University X is better than that of University Y. Then, it's called that X is absolutely better than Y. Using the "absolutely better" concept, it becomes possible to compare some pairs of the universities.

    Now Bob has the complete rankings of different departments of many universities, and he wants to find k universities ( U1, ..., Uk ) such that Ui is absolutely better that Uj ( for any i < j ). Could you tell Bob the maximum value of k ?

    输入

    The first line of the input is a positive integer C. C is the number of test cases followed.

    The first line of each test case is two positive integer N, M ( 0 < N, M ≤ 100 ), N is the number of universities and M is the number of departments. And then M lines follow. The i-th ( 1 ≤ iM ) line contains N numbers Ui ( 1 ≤ iN, 1 ≤ UiN ), indicating the ranking of the i-th department. If University Ui precedes to University Uj in line k, then the k-th department of Ui is better than the k-th department of Uj.

    输出

    Description

    At present, the university rankings are very popular. They help senior high school students to choose universities for further study. For example, you can find the CHINESE UNIVERSITY RANKINGS at http://www.netbig.com/.

    Figure 1

    As we know, a university usually has many different departments, such as department of Computer Science (CS), department of Electronic Engineering (EE), and School of Foreign Languages (FLS). Some of them are quite good when comparing to the other universities, but others are not. So, most of the university rankings are composed of several ranking lists, each list for one department.

    But here comes a problem that sometimes it's hard to determine which university is better, when comparing two universities with each other. Fortunately, Doctor Bob has advanced a new concept named "absolutely better", with which the problem above can be partially solved.

    Now, here is an example to explain the concept "absolutely better":

    Assume that there are three universities (X, Y, Z) and every university has three departments: CS, EE and FLS. And the rankings of different departments are as followed:

    The ranking of CS: X > Y > Z ( X > Y means X have a better CS department than Y )

    The ranking of EE: X > Z > Y

    The ranking of FLS: Z > X > Y

    Obviously, each department of University X is better than that of University Y. Then, it's called that X is absolutely better than Y. Using the "absolutely better" concept, it becomes possible to compare some pairs of the universities.

    Now Bob has the complete rankings of different departments of many universities, and he wants to find k universities ( U1, ..., Uk ) such that Ui is absolutely better that Uj ( for any i < j ). Could you tell Bob the maximum value of k ?

    Input

    The first line of the input is a positive integer C. C is the number of test cases followed.

    The first line of each test case is two positive integer N, M ( 0 < N, M ≤ 100 ), N is the number of universities and M is the number of departments. And then M lines follow. The i-th ( 1 ≤ iM ) line contains N numbers Ui ( 1 ≤ iN, 1 ≤ UiN ), indicating the ranking of the i-th department. If University Ui precedes to University Uj in line k, then the k-th department of Ui is better than the k-th department of Uj.

    Output

    The output should consist of C lines, one line for each test case. Each line only contains one integer -- the maximum value of k as described above. No redundant spaces are needed.

    Sample Input

    1
    3 3
    1 2 3
    1 3 2
    3 1 2

    Sample Output

    2

    Source

    样例输入

    1
    3 3
    1 2 3
    1 3 2
    3 1 2

    样例输出

    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部