F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Word Crosses

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2282    Accepted Submission(s): 696


Problem Description
A `word cross' is formed by printing a pair of words, the first horizontally and the second vertically, so that they share a common letter. A `leading word cross' is one where the common letter is as near as possible to the beginning of the horizontal word, and, for this letter, as close as possible to the beginning of the vertical word. Thus DEFER and PREFECT would cross on the first 'E' in each word, PREFECT and DEFER would cross on the 'R'. `Double leading word crosses' use two pairs of words arranged so that the two horizontal words are on the same line and each pair forms a leading word cross.

Write a program that will read in sets of four words and form them (if possible) into double leading word crosses.

 

Input
Input will consist of a series of lines, each line containing four words (two pairs). A word consists of 1 to 10 upper case letters, and will be separated from its neighbours by at least one space. The file will be terminated by a line consisting of a single #.
 

Output
Output will consist of a series of double leading word crosses as defined above. Leave exactly three spaces between the horizontal words. If it is not possible to form both crosses, write the message `Unable to make two crosses'. Leave 1 blank line between output sets.

 

Sample Input
MATCHES CHEESECAKE PICNIC EXCUSES PEANUT BANANA VACUUM GREEDY A VANISHING LETTER TRICK #
 

Sample Output
[bk]C [bk]H [bk]E [bk]E [bk]S [bk]E[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]E [bk]C[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]X MATCHES[bk][bk][bk]PICNIC [bk]K[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]U [bk]E[bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]S [bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]E [bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk][bk]S Unable to make two crosses V A[bk][bk][bk]LETTER N[bk][bk][bk][bk][bk]R I[bk][bk][bk][bk][bk]I S[bk][bk][bk][bk][bk]C H[bk][bk][bk][bk][bk]K I N G
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 21:04:54, Gzip enabled