#P15106. [ICPC 2025 LAC] LED Counter

[ICPC 2025 LAC] LED Counter

题目描述

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.

:::align{center} :::

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.

:::align{center} :::

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 00000\cdots0 (NN zeros) to 99999\cdots9 (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.

:::align{center} :::

输入格式

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

The ii-th of the next NN lines contains a string SiS_i of length 77 describing the seven LEDs in the ii-th position of the counter. Each character of SiS_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 SiS_i describes valid states for the LEDs in the ii-th position of the counter. For instance, SiS_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.

10
GGGgGGG
gggggGG
gGGGGGg
ggGGGGG
GggGgGG
GgGGGgG
GGGGGgG
ggGggGG
GGGGGGG
GgGGGGG
0123456789
3
GGGg+GG
GgGGGgG
GGGGGgG
056
3
GGGg+GG
G-GGGgG
GGGGGgG
0*6
2
+++gG--
---gG++
00
1
-+-+-+-
*