Editorial - 2023 Mini Contest 1
C2311 - Funny String
Recall that the ASCII codes for A-Z
run from 65 to 90
and those for a-z
run from 97 to 122.
For each character, determine if it is lowercase or uppercase,
then convert it depending on whether the index is odd/even.
C2312 - Homework Distribution
Solution 1
Create a 2D array representing the $N \times M$ students and populate it according to the input.
The tricky part is that this question counts rows and column numbers
starting from 1 rather than 0 (called 1-based indexing).
You should be careful in setting array size (int ans[501][501];
)
and the indices in for-loops (for (int i = 1; i <= n; i++)
and for (int j = 1; j <= m; j++)
).
Or, you can just subtract one from every row and column number in the input,
then solve the problem using 0-based indexing.
Solution 2 (More Efficient)
Instead of creating a 2D array, create two arrays $R[1..N]$ and $C[1..M]$. $R[i]$ stores how many pieces of homework row $i$ receieves, similarly $C[j]$ for column $j$. After processing all the input, the student sitting at row $i$, column $j$ receives a total of $R[i] + C[j]$ pieces of homework.
C2313 - GPA Calculator
Perhaps the most annoying part of this question is handling the conversion from letter grade to its numerical value.
Observe that the numerical value of A+
is the numerical value of A
plus 0.3,
and the numerical value of A-
is the numerical value of A
minus 0.3.
This is also the case for B
, C
and D
.
You can use this information to make your code shorter.
For calculating the weighted mean, maintain a sum of value-times-weights and another sum of just weights. Then divide the first sum by the second sum to get the GPA.
C2314 - Among Us
Create an array to count the number of tasks created by each Crewmate. $K$ is the maximum value in this array. Then, for each Crewmate, check if their number of complete tasks is $K$. If not, they are the Impostor. If every Crewmate completed $K$ tasks, then we cannot determine the Impostor.