Emoji Grades
Professor Pedro needs your help. While writing a research program, he
piped the Programming Challenges grades into a text-to-emoji converter
without keeping a copy of the source file. The converter replaced
letters and digits with Unicode symbols and added spaces to the end of
each line. Its generator seed was 42.
Recover the grade sheet and present it as a readable table. Write a
program in C, without external libraries, whose result
is independent of the computer’s locale.
Your task
Decode the header and every name/grade pair. Preserve the students’
order and single spaces inside names. Ignore the added trailing spaces
and align the columns again.
The converter lost the distinction between uppercase and lowercase
letters. Therefore, all names and the output header use
uppercase letters. The original capitalisation cannot be
recovered unambiguously.
Symbol conversion
Only the following forms are accepted:
A to Z |
A to Z |
Plain ASCII letters. |
| 🇦 to 🇿 |
A to Z |
Regional indicators U+1F1E6 to U+1F1FF, in alphabetical order. Each
code point represents one letter, even when two appear as a flag. |
| 🅰, 🅱, Ⓜ, 🅾, 🅿 |
A, B, M, O, P |
U+1F170, U+1F171, U+24C2, U+1F17E, U+1F17F. Each may be followed by
U+FE0F. |
0 to 9 |
0 to 9 |
ASCII digits. |
| 0⃣ to 9⃣, or 0️⃣ to 9️⃣ |
0 to 9 |
An ASCII digit, optionally U+FE0F, then U+20E3. |
| ASCII space |
Space |
U+0020. |
U+FE0F is a presentation selector: in the positions specified, it
changes a symbol’s appearance, not its meaning. It is not accepted
alone, after a regional indicator, or after a digit without U+20E3. A
line may mix all accepted forms. Names contain no accents or lowercase
letters.
- UTF-8 text on standard input until end of file. Lines end with LF or
CRLF; the final line may have no terminator.
- The first non-empty line contains
NOME, between
2 and 32 spaces, and NOTA, using the forms
above. These literal Portuguese field names are used in both language
versions.
- There are 1 to 10000 students, one per line. Each
decoded name has 1 to 80 characters, begins and ends
with a letter, and contains only A–Z and single spaces between
words.
- A name and grade are separated by 2 to 32 spaces. The grade has one
or two digits and represents an integer from 0 to 20,
inclusive. A leading zero is allowed.
- Each line may end with 0 to 16 extra spaces. Empty lines or
space-only lines may occur before the header and after the last student,
but not within the sheet.
- Judge data obey these rules.
Output
Let W be the maximum of 4 and the length of the longest
name, measured after decoding. Print:
NOME, padded on the right to W characters, followed by
two spaces and NOTA.
- Each student’s name padded to W characters, two spaces, and the
decimal grade without leading zeros.
- The literal line
Cumprimentos algorítmicos!.
Do not add spaces after grades. Every output line, including the
last, ends with LF. The final sentence keeps its accent and is encoded
in UTF-8.
Example
Input:
🇳🅾️Ⓜ️🇪 🇳🅾️🇹🅰️
🅰️🇳🅰️ 2⃣0⃣
🇱🇺🇮🇸 0️⃣7️⃣
Output:
NOME NOTA
ANA 20
LUIS 7
Cumprimentos algorítmicos!
ANA has one padding space and two separator spaces.
Limits
Time: 2 seconds. Memory: 64
MiB.
Downloadable examples
Input · Expected output · Twenty-student sheet · Its expected output.
Diogo Peralta Cordeiro · Programming Challenges (CC3036) · DCC/FCUP ·
2021