Efficient algorithms and data structures [c++03][topcoder][spoj]