Editorial for COCI '11 Contest 5 #1 Križaljka


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

The first part of the solution is detecting the first letter of word A that also appears in word B. It can be solved simply using two nested for-loops (the outer one to iterate over letters of A, the inner one over letters of B). A useful side-effect of such a solution is that the first found letter pair will be the two first (leftmost) such letters in their respective words, i.e. we will have automatically obtained the indices of the word intersection.

After finding the word intersection, we need to output the crossed words. The simplest method is, again, using two nested for-loops, the outer one iterating over indices of B, and the inner one over indices of A. On every iteration of the inner loop, we simply check whether we need to output a letter of B or a letter of A, or none of them (in which case we output a dot).


Comments

There are no comments at the moment.