Given weights and a feature matrix, print the indices of the rows whose weighted sum is largest, in ascending order, for each of K data sets.
Easy2ImplementationArrayMathInterviewNo attempts yetTime limit2sMemory limit512 MBOne of the symbiotic relationships among marine animals is the cleaning station. A cleaning station is a place such as a sea mount where cleaner fish gather in large numbers. A large fish such as a shark swims up to a cleaning station and picks out cleaner fish to take the parasites off its skin. The cleaner fish get a meal and the shark gets cleaned. Both profit.
A shark is defenseless while it is being cleaned, so it is very picky about which fish it lets near. If anything seems off, it leaves at once. The caution is earned. Some cleaner fish take small bites out of the shark along with the parasites.
A shark judges a cleaner fish by several features, and it assigns every feature a weight that is either positive or negative. One shark may prefer a larger cleaner fish, want a shorter distance to swim, and want the cleaner fish to move slowly. Given the feature values of every cleaner fish, find all the cleaner fish whose weighted sum of feature values is the largest.
The first line contains the number K of data sets. K data sets follow, each in the format below.
The first line of a data set contains two integers n and m. n is the number of cleaner fish, with 1≤n≤100, and m is the number of features the shark judges by, with 1≤m≤10.
The next line contains m integers x1,x2,…,xm, the weights the shark assigns to the m features. Every weight is between −20 and 20.
Then come n lines, one per cleaner fish. The i-th of those lines contains m integers yi,1,yi,2,…,yi,m, the feature values of cleaner fish i. Every yi,j is an integer between −20 and 20.
For each data set, first print Data Set x: on a line of its own, where x is the number of the data set counting from 1.
Then print, in ascending order and one per line, the numbers of all cleaner fish whose weighted sum ∑j=1mxjyi,j is the largest. Cleaner fish are numbered 1 through n in input order.
Print one blank line after the output of each data set.