Algorithme from ACM ICPC 2014