Codeforces Round #178 Problem D Shaass and Painter Robot