Movatterモバイル変換


[0]ホーム

URL:


Logo

33234번 -Fraud Checking다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초2048 MB53360.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:

  • A line with one integer $n$ ($1\leq n\leq 1000$), the number of lines of each code submission.
  • $n$ lines of code for the first submission.
  • $n$ lines of code for the second submission.

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:

  • A line containing a non-negative number $r$, indicating the number of word replacements.
  • $r$ lines, each containing a word replacement. A word replacement consists of two words, separated by a space. The list should be lexicographically ordered by ASCII values.

제한

예제 입력 1

4i is 42while i    subtract iprint ij is 1337while j    add jprint j

예제 출력 1

342 1337i jsubtract add

예제 입력 2

3ans is 42if ans is 42    print ansans is 42if ans is not 42    print ans

예제 출력 2

-1

예제 입력 3

2ans is 42print itemsans is 42print ans

예제 출력 3

-1

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2021 F번

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일:contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호


[8]ページ先頭

©2009-2025 Movatter.jp