LED Counter

면접 대비

시간 제한0.5초메모리 제한2048 MB

요약
일곱 개 LED의 상태(정상 켜짐/꺼짐, 항상 켜짐, 항상 꺼짐)가 주어진 N개의 일곱 세그먼트 자리마다 표시되는 숫자를 판별하고, 여러 숫자가 가능하면 *로 표시한다.
난이도

보통10점 중 4점

유형
구현, 완전 탐색, 비트 연산, 배열
정답자
아직 제출이 없습니다

문제

A LED counter is a device having NN positions arranged in a single row. Each position is able to display a digit from 00 to 99, and is made of seven LEDs, as this picture shows.

To display a specific digit, just the appropriate LEDs are turned on. The following picture indicates which LEDs are turned on for each possible digit.

As you can see, all but the middle LED are turned on to display the digit 00, the upper-right LED and the bottom-right LED are turned on to display the digit 11, and so on.

By turning on the appropriate LEDs in each of the NN positions of the counter, the device is able to display 10N10^N distinct values, from 00⋯000 \cdots 0 (NN zeros) to 99⋯999 \cdots 9 (NN nines). Note that leading zeros are displayed.

Astro Void has owned a LED counter for quite some time, and so the device might have some malfunctioning LEDs. While a good LED turns on or off when needed, a malfunctioning LED is always turned on or always turned off, independently of the intended value of the counter.

Given the description of the state of each LED in Astro Void’s LED counter (good LED that is turned on, good LED that is turned off, always-on LED, or always-off LED), you must tell the intended value of the counter, indicating which positions cannot be determined without ambiguity.

As an example of a LED counter with N=3N = 3 positions, consider the picture below. If all the LEDs are good, then the intended value of the counter is of course 056056. If the bottom LED of the first position is an always-on LED, then the intended value of the counter is still 056056, because no other value would be displayed as the picture shows. However, if the bottom-left LED of the second position is an always-off LED, then the second position of the counter cannot be determined without ambiguity, since 056056 and 066066 would be displayed as shown.

입력

The first line contains an integer NN (1≤N≤1051 ≤ N ≤ 10^5) indicating the number of positions in the LED counter.

The ii-th of the next NN lines contains a string S_iS\_i of length 77 describing the seven LEDs in the ii-th position of the counter. Each character of S_iS\_i describes a particular LED, from left to right and from top to bottom, that is, in the following order: upper-left, bottom-left, top, middle, bottom, upper-right and bottom-right. The character is either an uppercase letter “G” (good LED that is turned on), a lowercase letter “g” (good LED that is turned off), a plus sign “+” (always-on LED) or a hyphen “-” (always-off LED). It is guaranteed that S_iS\_i describes valid states for the LEDs in the ii-th position of the counter. For instance, S_iS\_i is not “ggggggg”, because when all LEDs are good, no digit would be displayed with all of them turned off.

출력

Output a single line with a string of NN digits indicating the intended value of the counter. If a position of the counter cannot be determined without ambiguity, output the character “*” (asterisk) instead of the corresponding digit.

예제5

  1. 예제 1

    입력
    10
    GGGgGGG
    gggggGG
    gGGGGGg
    ggGGGGG
    GggGgGG
    GgGGGgG
    GGGGGgG
    ggGggGG
    GGGGGGG
    GgGGGGG
    
    예상 출력
    0123456789
    
  2. 예제 2

    입력
    3
    GGGg+GG
    GgGGGgG
    GGGGGgG
    
    예상 출력
    056
    
  3. 예제 3

    입력
    3
    GGGg+GG
    G-GGGgG
    GGGGGgG
    
    예상 출력
    0*6
    
  4. 예제 4

    입력
    2
    +++gG--
    ---gG++
    
    예상 출력
    00
    
  5. 예제 5

    입력
    1
    -+-+-+-
    
    예상 출력
    *