시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 2048 MB | 5 | 3 | 3 | 60.000% |
The exam of the First Programming Course (FPC) was a success: all students have passed, with excellent grades! In fact, they have done so well, that it is somewhat suspicious. It is time to do a fraud check, but nobody has time to sift through the hundreds of code submissions manually. Therefore, you have been tasked with finding code submissions that are similar in structure: you should make a fraud report if the only difference between two pieces of code is the renaming of some variables.
More precisely, one piece of code issimilar to another when it is possible to make the two pieces of code identical to each other by processing a sequence of word replacements. When, after processing all word replacements, the first piece of code is identical to the second piece of code, and this also applies vice versa, then the two pieces of code are similar.
Each word replacement should replaceall occurrences of a word. A word replacement can only replace acomplete word. Spaces between words or at the start/end of a line should be ignored, but newlines cannot be ignored: for two pieces of code to be similar, each line of the first piece should have the same number of words as the same line in the second piece.
Given two pieces of code, check whether theysimilar. If they are similar, print a fraud report that gives the sorted list of word replacements.
The input consists of:
The lines of code consist of only spaces (''), letters from the English alphabet ('
A-Z
' and 'a-z
'), numbers ('0-9
'), and underscores ('\_
'). The lines of code are at least $1$ and at most $120$ characters long, excluding the newline character.
If the two pieces of code are not similar, output "-1
".
If the two pieces of code are similar, output:
4i is 42while i subtract iprint ij is 1337while j add jprint j
342 1337i jsubtract add
3ans is 42if ans is 42 print ansans is 42if ans is not 42 print ans
-1
2ans is 42print itemsans is 42print ans
-1