RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
R03654

Comparing Code

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Comparing Code
Competition Day One
August 18, 2003
Version 1.10
code
Comparing Code

TASK

Racine Business Networks (RBN) has taken the Heuristic Algorithm Languages (HAL)
company to court, claiming that HAL has taken source code from RBN UNIX and
contributed it to the open-source operating system HALnix.

RBN and HAL both use a programming language with one statement per line, each of the
form: STOREA = STOREB + STOREC where STOREA, STOREB, and STOREC are
variable names. In particular, the first variable name starts in the first column and is
followed by a space, an equals sign, a space, a second variable name, a space, the
addition symbol, a space, and a third variable name. The same variable name might
appear more than one time on a single line. Variable names consist of 1...8 uppercase
ASCII letters (‘A’...‘Z’).

RBN claims that HAL copied a consecutive sequence of lines directly from RBN's source
code, making only minor modifications:
• RBN claims that HAL changed some of the variable names in order to disguise
their crime. That is, HAL took a series of lines from RBN’s program and, for each
variable in it, changed all occurrences of that variable to a new variable name,
although the new variable name might be the same as the original. Of course, no
two variables were changed to the same new variable name.
• RBN also claims HAL might have changed the order of the right-hand side of
some lines: STOREA = STOREB + STOREC might have been changed to
STOREA = STOREC + STOREB.
• RBN claims that HAL did not change the order of the lines of RBN’s source code.

Given source code for programs from RBN and HAL, find the longest consecutive
sequence of lines from HAL's program that could have come from a consecutive
sequence of lines from RBN's program using the modifications above. Note that the
sequences of lines from the two programs do not have to start at the same line number in
both files.

Input: code.in

• The first line of input contains two space-separated integers, R and H (1 ≤ R ≤
1000; 1 ≤ H ≤ 1000). R is the number of lines of source code in RBN's program;
H is the number of lines of source code in HAL's program.
• The next R lines contain RBN's program.
• The next H lines contain HAL's program.

Comparing Code
Competition Day One
August 18, 2003
Version 1.10
code

Example input

4 3
RA = RB + RC
RC = D + RE
RF = RF + RJ
RE = RF + RF
HD = HE + HF
HM = HN + D
HN = HA + HB

Output: code.out

The output file should contain a single line with a single integer that is the length of the
longest consecutive sequence of lines that HAL might have copied from RBN and
transformed.

Example output:
2

Lines 1-2 of RBN's program are the same as lines 2-3 of HAL's program, if the following
variable name substitutions are performed on RBN's program: RA → HM, RB → D,
RC → HN, D → HA, RE → HB. There is no matching with three or more lines.

Note (RiseOJ) — The original statement describes file-based input/output; on this judge your program must read from standard input and write to standard output instead.

제약

Running time
2 seconds of CPU
Memory
64 MB

You will receive full points on each test case for which your program produces a correct
output file. No partial credit will be given on any test case.

입력 형식
출력 형식
문제 정보

생성자가 기록되지 않았습니다.

출처 IOI 2003

평가 및 의견

Comparing Code

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Comparing Code

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8