P29702 [洛谷] [COCI 2011-2012#5] CROSSWORD
普及-
题目描述

Problem Description

Given two words \( A \) and \( B \), place \( A \) horizontally and \( B \) vertically such that the overlapping part of the two words is the same letter, and this letter must be the first occurrence in both \( A \) and \( B \).

For example, when \( A = "ABBA" \) and \( B = "CCBB" \), the output should look like this:

.C..
.C..
ABBA
.B..

Input Format

A single line containing two strings, both consisting of uppercase letters, representing \( A \) and \( B \) respectively.

Output Format

A matrix representing the placement result. Use . to indicate empty spaces.

Sample Input and Output

Sample Input #1

BANANA PIDZAMA

Sample Output #1

.P....
.I....
.D....
.Z.... 
BANANA
.M....
.A....

Sample Input #2

MAMA TATA

Sample Output #2

.T..
MAMA
.T..
.A..

Sample Input #3

REPUBLIKA HRVATSKA

Sample Output #3

H........
REPUBLIKA
V........
A........
T........
S........
K........
A........

Notes

The data guarantees a solution exists.

Both strings consist of uppercase letters.

This problem is translated from COCI 2011/2012 #5 T1.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
BANANA PIDZAMA
样例输出
.P.... .I.... .D.... .Z.... BANANA .M.... .A....