Problem A
Code Theft
The screening would work as follows: Every time new code was checked in, the full contents of the changed files where matched against a repository of known open source code. For each file the longest match, in number of consecutive lines, should be reported.
Comparison is done line by line. Empty lines, and lines only containing space, are ignored during comparison and not counted. Leading and trailing spaces should be ignored completely and consecutive space characters inside the lines are treated as one single space. The comparison is case-sensitive.
Input
Test data starts with the number
After the fragments in the repository have all been listed, comes the actual code snippet to find matches for. This snippet is also terminated by ***END*** on a line by its own.
Lines are guaranteed to be no longer than
Output
Output the number of matching consecutive lines (empty lines not counted) in a longest match from the repository, followed by a space-separated list of the file names of each fragments containing a match of this length, given in the order that the matching fragments were presented in the repository description. If no fragments match, write the number 0 on a line of its own.
Sample Input 1 | Sample Output 1 |
---|---|
2 HelloWorld.c int Main() { printf("Hello %d\n",i); } ***END*** Add.c int Main() { for (int i=0; i<10; i++) sum += i; printf("SUM %d", sum); } ***END*** int Main() { printf("Hello %d\n",i); printf("THE END\n"); } ***END*** |
2 HelloWorld.c |
Sample Input 2 | Sample Output 2 |
---|---|
2 HelloWorld1.bas 10 PRINT "*******************" 20 PRINT "*******************" 30 PRINT "--- HELLO WORLD ---" 40 PRINT "*******************" 50 PRINT "*******************" ***END*** HelloWorld2.bas 10 PRINT "-------------------" 20 PRINT "*******************" 30 PRINT "--- HELLO WORLD ---" 40 PRINT "*******************" 50 PRINT "-------------------" ***END*** 10 REM Hello ver 1.0 (c) Acme 2008 20 PRINT "*******************" 30 PRINT "--- HELLO WORLD ---" 40 PRINT "*******************" 50 END ***END*** |
3 HelloWorld1.bas HelloWorld2.bas |