My acm algorithm problem slove code