luogu#P6920. [ICPC2016 WF] Clock Breaking

[ICPC2016 WF] Clock Breaking

题目描述

After numerous unfortunate freak fatalities and the lawsuits, settlements, protests, and boycotts that naturally followed, the beleaguered executives at ACME Clock Manufacturers have decided they need to finally fix their disastrous quality control issues. It has been known for years that the digital clocks they manufacture have an unacceptably high ratio of faulty liquid-crystal display (LCD) screens, and yet these heartless souls have repeatedly failed to address the issue, or even warn their hapless consumers!

You have been called in as a quality consultant to finally put a stop to the madness. Your job is to write an automated program that can test a clock and find faults in its display.

These clocks use a standard 7-segment LCD display for all digits (shown on the left in Figure 1), plus two small segments for the ‘:’, and show all times in a 24-hour format. The minute before midnight is 23:59, and midnight is 0:00. The ‘:’ segments of a working clock are on at all times. The representation of each digit using the seven segments is shown on the right in Figure 1.

Figure 1: LCD display of each digit.

Your program will be given the display of a clock at several consecutive minutes, although you do not know exactly what time these displays start. Some of the LCD segments are burnt out (permanently off) and some are burnt in (permanently on). Your program must determine, where possible, which segments are definitely malfunctioning and which are definitely in working order.

输入格式

The first input line contains a single integer nn (1n1001 \leq n \leq 100), which is the number of consecutive minutes of a clock’s display. The next 8n18n-1 lines contain nn ASCII images of these clock displays of size 7×217 \times 21, with a single blank line separating the representations.

All digit segments are represented by two characters, and each colon segment is represented by one character. The character ‘X’ indicates a segment that is on. The character ‘.’ indicates anything else (segments that are off or non-segment portions of the display). See the sample input/output for details; the first output shows every possible LCD segment along with the smaller segments used to represent the ‘:’. No clock representation has an ‘X’ in a non-segment position or only half of a segment showing.

输出格式

Display a 7×217 \times 21 ASCII image with a ‘0’ for every segment that is burnt out, a ‘1’ for every segment that is burnt in, a ‘W’ for every segment that is definitely working, and a ‘?’ for every segment for which the status cannot be determined. Use ‘.’ for non-segments. If the given displays cannot come from consecutive minutes, display impossible.

题目大意

题目描述

在无数不幸的畸形死亡事件以及随之而来的诉讼、和解、抗议和抵制之后,ACME时钟制造商的高管们决定最终解决灾难性的质量控制问题。多年来,人们都知道,他们制造的数字钟的液晶显示屏故障率高得令人无法接受,然而,这些无情的人们却一再未能解决这个问题,甚至未能警告他们不幸的消费者!

你被邀请担任质量顾问,最终制止了这种疯狂。你的工作是编写一个自动程序,可以测试时钟并发现其显示中的故障。

这些时钟使用标准的7段LCD显示屏显示所有数字(如图1左侧所示),加上两个小段显示,并以24小时计时法显示所有时间。午夜前一分钟是23:59,午夜是0:00。工作时钟的段始终打开。图1右侧显示了使用七段表示的0~9每个数字。

图1:每个数字的LCD显示。

图1:每个数字的LCD显示。

输入格式

第一行有一个数n(1  n  100)n(1\ \le\ n\ \le\ 100),这是时钟显示的连续分钟数。

接下来8n18n-1行包括nn个时钟显示的7×217\times 21的ASCII图像,每两个之间会有一行的空白用于间隔

所有表示数字的段由两个连续的字符表示,每个表示冒号的段由一个字符表示。字符X表示打开的段。字符.指示其他任何内容(显示的分段或非分段部分)。详见样本输入、输出;第一个输出显示每个可能的LCD段以及用于表示的较小段。没有时钟表示在非段位置有X,或仅显示段的一半。

输出格式

显示一个7×217\times 21ASCII图像,每个烧坏的段显示一个0,每个烧进的段显示1,每个正常工作的段显示为W,以及一个对于无法确定状态的每个段。使用.对于非分段。如果给定的显示不能来自连续分钟,则显示impossible

输入输出样例

说明/提示

时间限制:3000ms=3s

空间限制:1048576KB=1024MB=1GB

出处:2016年国际大学生编程大赛(ACM-ICPC)世界总决赛

3
......XX.....XX...XX.
.....X..X...X..X....X
.....X..X.X.X..X....X
.............XX...XX.
.....X..X......X.X..X
.....X..X......X.X..X
......XX.....XX...XX.

......XX.....XX...XX.
.....X..X...X..X....X
.....X..X.X.X..X....X
.............XX...XX.
.....X..X......X.X..X
.....X..X......X.X..X
......XX.....XX...XX.

.............XX...XX.
........X...X..X....X
........X.X.X..X....X
.............XX......
........X...X..X.X..X
........X...X..X.X..X
......XX.....XX...XX.

.??...WW.....??...??.
?..?.W..?...?..1.0..?
?..?.W..?.?.?..1.0..?
.??...??.....11...WW.
?..?.W..?.0.W..?.1..?
?..?.W..?...W..?.1..?
.??...11.....??...??.

2
......XX.....XX...XX.
...X....X...X..X.X..X
...X....X.X.X..X.X..X
......XX..........XX.
...X.X....X.X..X.X..X
...X.X......X..X.X..X
......XX.....XX...XX.

......XX.....XX......
...X....X...X..X.....
...X....X.X.X..X.....
......XX.............
...X.X....X.X..X.....
...X.X......X..X.....
......XX.....XX......

impossible

提示

Time limit: 3000 ms, Memory limit: 1048576 kB.

International Collegiate Programming Contest (ACM-ICPC) World Finals 2016