#P16064. [CSPro 32] 仓库规划
[CSPro 32] 仓库规划
Background
Luogu's testdata is only for community sharing and is not official testdata. Official judging link: https://www.cspro.org/.
Problem Description
There are warehouses on Xixi Aifu Island, numbered in order. Each warehouse has an -dimensional vector as its location code, which is used to describe the logistics relationship between warehouses.
Specifically, each warehouse may have a parent warehouse such that, in every dimension, the corresponding element of warehouse 's location code is strictly greater than that of warehouse . For example, a warehouse with code can be the parent of , but it cannot be the parent of . If multiple warehouses satisfy this condition, choose the one with the smallest index as the parent warehouse of warehouse . If no warehouse satisfies the condition, then warehouse is a logistics center and has no parent warehouse.
Given the location codes of warehouses, compute the index of the parent warehouse for each warehouse.
Input Format
Read from standard input.
There are lines in total.
The first line contains two positive integers and , representing the number of warehouses and the dimension of the location codes.
The next lines give the location codes of the warehouses in order. The -th line () contains integers, representing the location code of warehouse .
Output Format
Write to standard output.
There are lines in total.
The -th line () outputs one integer, the index of the parent warehouse of warehouse . If warehouse has no parent, output on the -th line.
4 2
0 0
-1 -1
1 2
0 -1
3
1
0
3
Hint
Sample Explanation
For warehouse : , both warehouse : and warehouse : satisfy the parent condition, so we choose warehouse with the smaller index as its parent.
Subtasks
of the testdata satisfies .
All testdata satisfies , , and every element in the location codes is an integer with absolute value not greater than .
Translated by ChatGPT 5