icpc2013 problem1 solution