1524_SimpleSor

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

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

Pro.ID

1524

Title

Simple Sort

Title链接

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

AC

13

Submit

13

Ratio

100.00%

时间&空间限制

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

    Sorting is a basic function in any databases. Assume there are N entries in the given database. Every entry has M items. To determine the order, we are first required to provide the priorities among the columns. Priorities are measured by Mdistinct integers. The lower integer indicates the higher priority.

    To compare two entries, item in the column with highest priority is used. If equal, the items in the column with the second highest priority are compared. Then the 3rd to N-th highest column, until in which the items are not equal. If two entries are completely the same, the one given earlier in the data will rank first.

    You are now given a job to implement the sorting function with different column priorities.

    输入

    The first integer T ( ≤ 30 ) indicates the number of cases. There follows T cases. In every cases, the first line contain two integer N ( ≤ 100 ), M ( ≤ 10 ). N is the number of entries. M is the number of the column. The N lines is followed, every line contains M integers. The j-th integer in the i-th line correspond with the content in the i-th entry j-th column. Then a number Q ( ≤ 10 ) follows indicating the number of the queries. In every line, there are M integers. The i-th number is the priority of the i-th column.

    输出

    Description

    Sorting is a basic function in any databases. Assume there are N entries in the given database. Every entry has M items. To determine the order, we are first required to provide the priorities among the columns. Priorities are measured by Mdistinct integers. The lower integer indicates the higher priority.

    To compare two entries, item in the column with highest priority is used. If equal, the items in the column with the second highest priority are compared. Then the 3rd to N-th highest column, until in which the items are not equal. If two entries are completely the same, the one given earlier in the data will rank first.

    You are now given a job to implement the sorting function with different column priorities.

    Input

    The first integer T ( ≤ 30 ) indicates the number of cases. There follows T cases. In every cases, the first line contain two integer N ( ≤ 100 ), M ( ≤ 10 ). N is the number of entries. M is the number of the column. The N lines is followed, every line contains M integers. The j-th integer in the i-th line correspond with the content in the i-th entry j-th column. Then a number Q ( ≤ 10 ) follows indicating the number of the queries. In every line, there are M integers. The i-th number is the priority of the i-th column.

    Output

    For every case, output Q lines. Every line contains N distinct integers (numbered from 0 to N-1) in ascending order with given priorities. Number i means the (i+1)-th entry.

    Sample Input

    1
    6 3
    1 1 1
    1 2 3
    2 2 4
    2 2 3
    3 1 2
    3 2 2
    4
    1 2 3
    0 1 2
    30 20 10
    0 -1 1

    Sample Output

    0 1 3 2 4 5
    0 1 3 2 4 5
    0 4 5 1 3 2
    0 4 1 3 2 5

    样例输入

    1
    6 3
    1 1 1
    1 2 3
    2 2 4
    2 2 3
    3 1 2
    3 2 2
    4
    1 2 3
    0 1 2
    30 20 10
    0 -1 1

    样例输出

    0 1 3 2 4 5
    0 1 3 2 4 5
    0 4 5 1 3 2
    0 4 1 3 2 5

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部