Editorial for IOI '98 P1 - Contact
Submitting an official solution before solving the problem yourself is a bannable offence.
Contact is a string processing problem conceived to test precise algorithm design abilities.
What is required is an algorithm to count all required patterns by doing a single pass over the file. The file can be rather large. Therefore, the contestants must find a good representation for the patterns and a fast lookup table for keeping the running totals incrementally.
Most of the required techniques are standard, but must be mastered with precision. Moreover, the nature of the inputs makes it difficult to check empirically the correctness of the program (that is, by comparing results). So, great care must be given to the design of the code itself.
Patterns are represented by integers (reading bit patterns as binary numerals). An extra 1
is appended to the left of each pattern to distinguish different amounts of leading zeros (say 001
from 01
). These integers are used to index a table (represented by an array) that keeps the number of occurrences while the file is scanned. After the file is scanned, the relevant section of the table is sorted and the output file is generated.
Comments