Problem A
Artist Who Shall Not Be Named
You are visiting the beautiful country of Genovia. Given its location in the world, you meet people from all over.
You find yourself in a bar: to your right is Don, and to your left is Зеленський.
You have just returned from a Unicode convention and notice that each letter of Don’s name takes one byte in UTF-8, since it consists entirely of ASCII characters. Each letter of Зеленський takes two bytes because they are non-ASCII characters.
Unicode represents all characters of the world’s writing systems by mapping them to numbers (code points) between 0 and just over one million. Since data is stored in bytes, UTF-8 encodes these code points efficiently. In UTF-8, the high bits of the first byte indicate how many bytes are needed:
-
If the top bit is 0, the code point is less than 128 and represented by a single byte (ASCII). For example, ‘D‘ is encoded as 0x44 or 0b01000100.
-
If the top two bits are 10, the byte is part of a multi-byte sequence; the lower six bits contribute to the code point.
-
Otherwise, the leading bits start with 110, 1110, or 11110, indicating a 2-, 3-, or 4-byte encoding respectively. The remaining bits after the prefix are the most significant bits of the code point.
This can also be summarized in the following table:
|
Range |
Byte 1 |
Byte 2 |
Byte 3 |
Byte 4 |
|
0x00–0x7F |
0zzzzzzz |
|||
|
0x80–0x7FF |
110yyyzz |
10zzzzzz |
||
|
0x800–0xFFFF |
1110yyyy |
10yyyyzz |
10zzzzzz |
|
|
0x10000–0x10FFFF |
11110xxx |
10xxyyyy |
10yyyyzz |
10zzzzzz |
For example, З has the binary representation 10000010111, requiring two bytes: 11010000 and 10010111.
You proudly demonstrate your UTF-8 expertise to Don and Зеленський, then ask the bartender for her name. She writes a name using the byte sequence (0xc0, 0x0l, 0xd0, 0x0d), which cannot be represented in standard Unicode. Many people in Genovia have “artistic” names that contain invalid UTF-8 byte sequences.
Names are recorded in your notebook using nibble encoding, where each byte is split into two 4-bit nibbles and written as hexadecimal. For example, Don (bytes 0x44, 0x6f, 0x6e) is recorded as 446f6e. (A nibble is simply a half-byte, representing a single hexadecimal digit.)
You decide to survey all the names in the bar and categorize them as follows:
-
Boring: All bytes represent single-byte Unicode characters (ASCII only).
-
Cool: Valid UTF-8 with at least one multi-byte character.
-
Artistic: Contains at least one invalid UTF-8 byte sequence. This includes, but is not limited to:
-
A byte sequence with an odd number of nibbles.
-
A multi-byte start byte followed by too few or too many continuation bytes (or the sequence ends prematurely).
-
A continuation byte (starting with 10) without a preceding valid multi-byte start byte.
-
A code point in the surrogate range 0xD800–0xDFFF, which is reserved for UTF-16 and not valid in UTF-8.
-
Code points that are non-characters (e.g., 0xFDD0–0xFDEF, 0xFFFE, 0xFFFF, etc.).
-
Input
The first line contains an integer $N$ ($0 < N \le 1000$), the number of names. The following $N$ lines each contain a nibble-encoded name. No name exceeds 100 nibbles.
Output
Output a single line with three integers: the counts of boring, cool, and artistic names, separated by spaces.
| Sample Input 1 | Sample Output 1 |
|---|---|
3 446f6e d097d0b5d0bbd0b5d0bdd181d18cd0bad0b8d0b9 c001d00d |
1 1 1 |
