IBEvaluator
SRM 182 · 2004-02-07 · by dgarthur
Problem Statement
For the International Baccalaureate (IB) diploma, students are assigned integer grades between 1 and 7 inclusive, based on exams taken at the end of high school. Unfortunately, these results are never available in time to assist universities with admissions decisions. To counteract this problem, IB teachers are required to predict in advance how well each student will perform on the exams. As these predictions can have an enormous impact on a student's future, schools are naturally very interested in evaluating their accuracy.
Create a class IBEvaluator that contains a method getSummary, which is given a
Constraints
- predictedGrades and actualGrades will each contain between 1 and 50 elements inclusive.
- predictedGrades and actualGrades will contain the same number of elements.
- Each element of predictedGrades will be between 1 and 7 inclusive.
- Each element of actualGrades will be between 1 and 7 inclusive.
{1,5,7,3}
{3,5,4,5}
Returns: { 25, 0, 50, 25, 0, 0, 0 }
The grade distribution is shown below. Student | Predicted grade | Actual grade | Difference --------+-----------------+--------------+----------- 1 | 1 | 3 | 2 2 | 5 | 5 | 0 3 | 7 | 4 | 3 4 | 3 | 5 | 2 Out of four predictions, one (25%) is off by 0 points, two (50%) are off by 2 points, and one (25%) is off by 3 points.
{1,1,1}
{5,6,7}
Returns: { 0, 0, 0, 0, 33, 33, 33 }
Note that percentages are rounded down.
{3}
{3}
Returns: { 100, 0, 0, 0, 0, 0, 0 }
{1,5,3,5,6,4,2,5,7,6,5,2,3,4,1,4,6,5,4,7,6,6,1}
{5,1,3,2,6,4,1,7,5,2,7,4,2,6,5,7,3,1,4,6,3,1,7}
Returns: { 17, 13, 21, 17, 21, 4, 4 }
{6,7,4,7,2,7,6,1,4,2,4,1,2,3,5,4,6,2,4,3,5,7,1,1,7,4,3,4,7,3,3,3,6,1,4,7}
{2,2,7,4,6,4,4,6,7,5,5,2,4,3,6,3,6,7,7,7,4,1,6,1,7,6,2,2,3,5,1,6,5,6,6,1}
Returns: { 11, 19, 19, 19, 11, 13, 5 }
Submissions are judged against all 54 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class IBEvaluator with a public method vector<int> getSummary(vector<int> predictedGrades, vector<int> actualGrades) · 54 test cases · 2 s / 256 MB per case