I'm not sure how to approach these two problems:
http://main.edu.pl/en/archive/oi/2/obc
http://main.edu.pl/en/archive/oi/14/wag
The first one seems like some dfs, and I really have no clue about the second one (maybe dp?).
Any ideas or hints? Thanks!