IPSC Logo

Internet Problem Solving Contest

IPSC 2016

Problem L – Luxor Catch-ya!

Egyptian pharaohs were quite wealthy people. Moreover, they brought a lot of this wealth along with them to their afterlife. It is therefore not a big surprise that tomb raiding was a very good way of making a fortune, that is, assuming you lived through the experience. In order to regulate this industry, pharaohs had many traps built into their tombs. One of their latest inventions was an ingenious device called “catch-ya” – the device shows you some random hieroglyphs and you are required to decipher them; if you decipher the symbols wrongly, the device would catch you in a deadly trap. Catch-ya devices were quite successful at the time, mainly because only a few people could read and write hieroglyphs and these people were usually at high state positions anyway.

Problem specification

Because of some unnamed circumstances involving a lot of gambling, you found yourself in a rather intricate situation marked by the fact that you owe a not-really-small amount of money to some not-really-friendly people. In order to resolve this problem you decided to raid a tomb of a wealthy Egyptian pharaoh. The planning paid off and now you are deep inside the pyramid, still alive, standing in front of the catch-ya device. This is the last thing that stands between you and lots of gold. So, the only task left is to decode the provided catch-ya prompts. Fortunately, you are a clever thief and therefore you got a hold of a reference mapping between hieroglyphs and letters you need to enter on the keyboard in front of you.

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

(Source: the Meroitic Hieroglyphics font by Reinhold Kainhofer.)

You can find both PNG and textual representation of the glyphs in the directory l/alphabet. Note that Egyptians did not have sounds for F, H and X so there is no glyph for them.

Input specification

The input files can be found in directories l/l1 and l/l2. Each subdirectory contains exactly t = 800 test cases, the i-th of which is stored in two files i.in and i.png.

Each test case file i.in represents a greyscale image with dimensions 600 x 70 pixels – the catch-ya prompt. The file consists of 70 lines, each line containing 600 integers between 0 and 255. i.png contains the same image as i.in, but in the PNG format.

Each subdirectory also has a file named sample.out, which contains the correct decoding for the first 200 test cases of the subproblem.

Output specification

Output a single line for each test case. The line should contain a 6-character lower-case string with the decoded catch-ya. Note that your output should not contain characters “f”, “h”, or “x”.

For the easy subproblem L1, your output must be completely correct.

For the hard subproblem L2, your output must have the correct format: for each test case you must output one string of 6 allowed lowercase letters. At least 98% of those strings must be correct. In other words, your output may have at most 16 wrong lines.

Example (easy subproblem)

Input:

(799 more catch-yas)
Output:
mweaul
(799 more lines)