Untitled
unknown
plain_text
a year ago
5.4 kB
4
Indexable
[Problem Description] You are required to write a program that manages soldiers. Each solider has an identification number, team, and reputation score. The program must have the following features: 1. Recruit soldiers 2. Fire soldiers 3. Change the reputation scores of soldiers 4. Change all the reputation scores of soldiers in a particular team 5. Search for a solider with the highest reputation score within a particular team Implement each required function by referring to the following API description. ※ The function signature below is based on C/C++. As for Java, refer to the provided Solution.java and UserSolution.java. The following is the description of API to be written in the User Code. void init() This function is called in each test case. There are no recruited soldiers in the beginning of the test case. void hire(int mID, int mTeam, int mScore) This function recruits a solider whose identification number is mID, team is mTeam, and reputation score is mScore. It is guaranteed that one solider can only be recruited once in a test case. Parameters mID : Identification number (1 ≤ mID ≤ 100,000) mTeam : Team of the soldier (1 ≤ mTeam ≤ 5) mScore : Reputation score (1 ≤ mScore ≤ 5) void fire(int mID) This function fires a solider whose identification number is mID. It is guaranteed that mID has been recruited when fire() is called. Parameters mID : Identification number (1 ≤ mID ≤ 100,000) void updateSoldier(int mID, int mScore) This function changes the reputation score of mID to mScore. It is guaranteed that mID has been recruited when this function is called. Parameters mID : Identification number (1 ≤ mID ≤ 100,000) mScore : Reputation score (1 ≤ mScore ≤ 5) void updateTeam(int mTeam, int mChangeScore) This function changes all the reputation scores of soldiers in a team named mTeam. It is guaranteed that there are one or more recruited soldiers in mTeam. Scores are changed by updateTeam() according to the following rules: If ‘the score before change + mChangeScore’ is larger than 5, change the score to 5. If ‘the score before change + mChangeScore’ is less than 1, change the score to 1. In other cases, change the score to ‘the score before change + mChangeScore.’ Parameters mTeam : Name of the team (1 ≤ mTeam ≤ 5) mChangeScore : Reputation score to be added (-4 ≤ mChangeScore ≤ 4) int bestSoldier(int mTeam) This function returns the identification number of a soldier with the highest reputation score among the ones in mTeam. If more than one soldier has the highest score, return the largest identification number. It is guaranteed that there are one or more recruited soldiers in mTeam. Parameters mTeam : Name of the team (1 ≤ mTeam ≤ 5) Returns Identification number of the solider with the highest reputation score [Example] [a, b, c] in the below table respectively represent the identification number, team, and reputation score of a solider. Order Function Status Return 1 init() 2 hire(16, 1, 5) [16, 1, 5] 3 hire(21, 1, 5) [16, 1, 5], [21, 1, 5] 4 bestSoldier(1) [16, 1, 5], [21, 1, 5] 21 5 fire(21) [16, 1, 5] 6 bestSoldier(1) [16, 1, 5] 16 7 hire(25, 1, 4) [16, 1, 5], [25, 1, 4] 8 hire(30, 1, 2) [16, 1, 5], [25, 1, 4], [30, 1, 2] 9 updateTeam(1, 1) [16, 1, 5], [25, 1, 5], [30, 1, 3] 10 bestSoldier(1) [16, 1, 5], [25, 1, 5], [30, 1, 3] 25 11 updateTeam(1, 2) [16, 1, 5], [25, 1, 5], [30, 1, 5] 12 bestSoldier(1) [16, 1, 5], [25, 1, 5], [30, 1, 5] 30 13 updateSoldier(30, 2) [16, 1, 5], [25, 1, 5], [30, 1, 2] 14 bestSoldier(1) [16, 1, 5], [25, 1, 5], [30, 1, 2] 25 15 updateTeam(1, -4) [16, 1, 1], [25, 1, 1], [30, 1, 1] 16 hire(1, 1, 3) [16, 1, 1], [25, 1, 1], [30, 1, 1], [1, 1, 3] 17 updateTeam(1, -1) [16, 1, 1], [25, 1, 1], [30, 1, 1], [1, 1, 2] 18 bestSoldier(1) [16, 1, 1], [25, 1, 1], [30, 1, 1], [1, 1, 2] 1 19 hire(100000, 5, 1) [16, 1, 1], [25, 1, 1], [30, 1, 1], [1, 1, 2] [100000, 5, 1] 20 bestSoldier(5) [16, 1, 1], [25, 1, 1], [30, 1, 1], [1, 1, 2] [100000, 5, 1] 100000 [Constraints] 1. init() is called in the beginning of each test case. 2. For each test case, hire() can be called less or equal to 100,000 times. 3. For each test case, fire() can be called less or equal to 100,000 times. 4. For each test case, updateSoldier() can be called less or equal to 100,000 times. 5. For each test case, updateTeam() can be called less or equal to 100,000 times. 6. For each test case, bestSoldier() can be called less or equal to 100 times. [Input and Output] As the input and output are processed in the provided code in the Main, they are not processed separately in the User Code. The output result for the sample input is in the format of “#TC number result.” It is the correct answer if the result is 100; it is the wrong answer if it is 0.
Editor is loading...
Leave a Comment