CandidatesSelectionEasy
SRM 620 · 2013-12-22 · by cgy4ever
SRM 620 · 2013-12-22 · by cgy4ever · Brute Force
Problem Statement
Problem Statement
Fox Ciel wants to hire a new maid.
There are n candidates for the position.
There are m different skills a maid should have, such as cooking, cleaning, or discreetness.
Ciel numbered the candidates 0 through n-1 and the skills 0 through m-1.
Ciel evaluated the level each candidate has in each of the skills. You are given this information encoded in aString[] score with n elements, each consisting of m characters.
For each i and j, the character score[i][j] represents the level candidate i has in skill j.
Said character will always be between 'A' and 'Z', inclusive, where 'A' means the best possible and 'Z' the worst possible candidate.
You are also given anint x.
Ciel thinks that skill x is the most important skill a maid should have.
Return aint[] with n elements: the numbers of all candidates, ordered according to their level in skill x from the best to the worst.
Candidates who have the same level in skill x should be ordered by their number in ascending order.
Ciel evaluated the level each candidate has in each of the skills. You are given this information encoded in a
You are also given an
Return a
Constraints
- n will be between 1 and 50, inclusive.
- m will be between 1 and 50, inclusive.
- score will contain exactly n elements.
- Each element of score will contain exactly m characters.
- Each character in each element of score will be an uppercase English letter ('A'-'Z').
- x will be between 0 and m-1, inclusive.
Examples
0)
{"ACB", "BAC", "CBA"}
1
Returns: {1, 2, 0 }
The output should be {1, 2, 0}, because the level of candidate 1 in skill 1 is 'A', the level of candidate 2 in this skill is 'B', and the level of candidate 0 is 'C'.
1)
{"A", "C", "B", "C", "A"}
0
Returns: {0, 4, 2, 1, 3 }
Note that when 2 candidates have same level, they will remain in the original order.
2)
{"LAX","BUR","ONT","LGB","SAN","SNA","SFO","OAK","SJC"}
2
Returns: {5, 3, 8, 7, 4, 6, 1, 2, 0 }
3)
{"BBCBABAC","BCBACABA","CCCBAACB","CACABABB","AABBBBCC"}
6
Returns: {0, 1, 3, 2, 4 }
4)
{"XXYWZWWYXZ","YZZZYWYZYW","ZYZZWZYYWW","ZWZWZWZXYW","ZYXWZXWYXY","YXXXZWXWXW","XWWYZWXYXY","XYYXYWYXWY","ZZYXZYZXYY","WXZXWYZWYY"}
3
Returns: {0, 3, 4, 5, 7, 8, 9, 6, 1, 2 }
5)
{"X"}
0
Returns: {0 }
Note that we may have only one candidate as well as only 1 skill.
Submissions are judged against all 76 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class CandidatesSelectionEasy with a public method vector<int> sort(vector<string> score, int x) · 76 test cases · 2 s / 256 MB per case