시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 40 | 11 | 11 | 44.000% |
To speed a work of cashiers, each product is marked with a series of black and white vertical bars called bar code. It can be transformed to a sequence of zeroes and ones with an optical reader. That sequence represents a code of a product.
Bar code consists of black and white vertical bars, which can be thin or thick. White and black bars alternate, i.e. no two adjacent bars are of the same color. Thin bar represent 0 and thick bar represent 1, regardless of its color. Thus a bar code represents a sequence of binary digits.
Each bar in a bar code on a product appears as five ‘squares’ high column (see the picture below). Width of a thin bar is one and of a thick bar are two ‘squares’. For example, bar code depicted below represents the sequence 010001.
Bar code reader used in this problem fell on a floor and since then was unable to properly recognize a color of some ‘squares’ of a bar code.
Write a program that will from a given scanning of a bar code with our faulty reader determine which sequence of binary digits it represents if it is possible.
The first line of input file contains an integer N, 1 ≤ N ≤ 100, representing total width of scanned bar code.
Each of next five lines contains N characters, each of which can be ‘X’, ‘.’ (dot) or ‘?’ (question mark), where X represents successfully recognized black ‘square’, a dot represents successfully recognized white ‘square’ and question mark means that our reader didn’t determine the colour of the ‘square’.
The first and only line of output file should contain a sequence of binary digits represented with bar code given in input file if it can be determined. If a sequence cannot be determined, word ‘UNDETERMINABLE’ should be written to the first line instead.
4 .X?? .??. ??.? ?X.? .X?.
001
8 ?.?X?X?? ??.X??.. ???????? ?.???X.. ?..X?X??
010001
9 XX.?X..?X ?X.?X?.?X XX.?X..?? X?.?X..?X XX.?X?.?X
UNDETERMINABLE