A solution I implemented for Problem #7 of the Southern California region's ACM ICPC.