CF47C.Crossword
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The words are arranged in the form of a rectangular "eight" or infinity sign, not necessarily symmetrical.
The top-left corner of the crossword coincides with the top-left corner of the rectangle. The same thing is correct for the right-bottom corners. The crossword can't degrade, i.e. it always has exactly four blank areas, two of which are surrounded by letters. Look into the output for the samples for clarification.
Help Vasya — compose a crossword of the described type using the given six words. It is allowed to use the words in any order.
瓦西娅正在练习编写填字游戏。目前,他只能编写一种非常简单的类型。所有这类填字游戏均由恰好六个单词组成;这些单词只能从上到下(纵向)或从左到右(横向)阅读。这些单词被排列成一个矩形的“八”字形(即无穷大符号 ∞ 的形状),该形状不一定是轴对称的。
填字游戏的左上角与该矩形的左上角重合;同样地,其右下角也与该矩形的右下角重合。该填字游戏不能退化,即它必须恰好包含四个空白区域,其中两个被字母完全包围。请参见样例输出以进一步明确结构。
请帮助瓦西娅——使用给定的六个单词,构造一个符合上述描述的填字游戏。允许以任意顺序使用这六个单词。
输入格式
Six lines contain the given words. Every word consists of no more than 30 and no less than 3 uppercase Latin letters.
六行包含给定的单词。每个单词由不少于3个、不多于30个大写拉丁字母组成。
输出格式
If it is impossible to solve the problem, print Impossible. Otherwise, print the sought crossword. All the empty squares should be marked as dots.
If there can be several solutions to that problem, print the lexicographically minimum one. I.e. the solution where the first line is less than the first line of other solutions should be printed. If the two lines are equal, compare the second lines and so on. The lexicographical comparison of lines is realized by the < operator in the modern programming languages.
如果无法解决该问题,请输出 Impossible。否则,输出所求的填字游戏。所有空格均需用英文句点(.)标记。
若该问题存在多个解,则输出字典序最小的解。即:首先比较各解的第一行,选择第一行字典序更小的解;若第一行相同,则比较第二行,依此类推。行之间的字典序比较方式与现代编程语言中的 < 运算符一致。
输入输出样例
输入#1
NOD BAA YARD AIRWAY NEWTON BURN
输出#1
BAA... U.I... R.R... NEWTON ..A..O ..YARD
输入#2
AAA AAA AAAAA AAA AAA AAAAA
输出#2
AAA.. A.A.. AAAAA ..A.A ..AAA
输入#3
PTC JYNYFDSGI ZGPPC IXEJNDOP JJFS SSXXQOFGJUZ
输出#3
JJFS.... Y..S.... N..X.... Y..X.... F..Q.... D..O.... S..F.... G..G.... IXEJNDOP ...U...T ...ZGPPC
输入解题思路,AI测评打分。不知道怎么写?