The ideas for some of the algorithms presented in this paper were developed in the following contexts: - the first author was the coach of the ACM ICPC team of the second author several years in a row (at the Politehnica University of Bucharest) - the two authors were members of the scientific committee of the Romanian ACM ICPC national contest Under these conditions many algorithmic problems were both solved and developed by the two authors (some examples can be seen in the related_materials.zip archive)